Skip to content

Commit

Permalink
scripts: gen_relocate_app.py: add custom align size for relocation
Browse files Browse the repository at this point in the history
add custom align size for code relocation to reduce alignment memory
wasting.

Fixes: #17337.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
  • Loading branch information
wentongwu authored and nashif committed Sep 25, 2019
1 parent b813c89 commit 0d02884
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/gen_relocate_app.py
Expand Up @@ -84,7 +84,11 @@
{{
__{0}_{1}_start = .;
{4}
#if {6}
. = ALIGN({6});
#else
MPU_ALIGN(__{0}_{1}_size);
#endif
__{0}_{1}_end = .;
}} {5}
__{0}_{1}_size = __{0}_{1}_end - __{0}_{1}_start;
Expand Down Expand Up @@ -188,6 +192,12 @@ def assign_to_correct_mem_region(memory_type,
iteration_sections["text"] or iteration_sections["rodata"]):
all_regions = True

pos = memory_type.find('_')
if pos in range(len(memory_type)):
align_size = int(memory_type[pos+1:])
memory_type = memory_type[:pos]
mpu_align[memory_type] = align_size

if memory_type in complete_list_of_sections:
for iter_sec in ["text", "rodata", "data", "bss"]:
if ((iteration_sections[iter_sec] or all_regions) and
Expand Down Expand Up @@ -229,9 +239,14 @@ def string_create_helper(region, memory_type,
linker_string += tmp
else:
if memory_type != 'SRAM' and region == 'rodata':
align_size = 0
if memory_type in mpu_align.keys():
align_size = mpu_align[memory_type]

linker_string += LINKER_SECTION_SEQ_MPU.format(memory_type.lower(),
region, memory_type.upper(),
region.upper(), tmp, load_address_string)
region, memory_type.upper(),
region.upper(), tmp,
load_address_string, align_size)
else:
linker_string += LINKER_SECTION_SEQ.format(memory_type.lower(), region,
memory_type.upper(), region.upper(),
Expand Down Expand Up @@ -400,6 +415,8 @@ def create_dict_wrt_mem():


def main():
global mpu_align
mpu_align = {}
parse_args()
searchpath = args.directory
linker_file = args.output
Expand Down

0 comments on commit 0d02884

Please sign in to comment.