From f050111663cb33a061cfbdc07dc836a5af13d362 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 23 Sep 2021 18:39:31 +0000 Subject: core: Fix flash size calculation when linking with lld (clang) The map file generated by lld has a different format than the gnu linker (ld). (We save this map file into build///ec..map during the build.) Instead of trying to parse the different formats in the .map file, use the .smap file (the output of "nm"), which has the values of the symbols and has the same format whether using lld or ld. We need to add a new "__flash_size" symbol so that we can use that symbol to get the size from the .smap. This add flash sizes to a few boards that previously didn't have it: asurada_scp, cherry_scp, and kukui_scp, since the previous logic was always looking for FLASH and these use IROM. BRANCH=none BUG=b:172020503 TEST=make buildall -j TEST=make CC=arm-none-eabi-clang BOARD=elemi TEST=bcompare build_before_change build_after_change => only difference between space_free_flash.txt and space_free_ram.txt files in the two builds is that this change adds the space_free_flash.txt files for asurada_scp, cherry_scp, and kukui_scp. Signed-off-by: Tom Hughes Change-Id: I7c64b6ba9bceeeb4044559188c1c1bebbf60471d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3179314 Reviewed-by: Keith Short --- core/cortex-m0/ec.lds.S | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core/cortex-m0') diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S index c5e66f9bcb..031cb6b1b3 100644 --- a/core/cortex-m0/ec.lds.S +++ b/core/cortex-m0/ec.lds.S @@ -308,11 +308,16 @@ SECTIONS (__shared_mem_buf + CONFIG_SHAREDMEM_MINIMUM_SIZE); /* - * __flash_used is used in flash free calculations by the makefile. + * __flash_used and __flash_size is used in flash free calculations by + * the makefile. Note the difference between __flash_size and + * __config_flash_size. __flash_size is the flash size for the given + * image (RW, RO, etc.), while __config_flash_size is the *total* + * flash size. * __image_size is stored in the struct image_data header and used - * in hash calcuations. + * in hash calculations. */ __flash_used = LOADADDR(.data) + SIZEOF(.data) - ORIGIN(FLASH); + __flash_size = LENGTH(FLASH); __image_size = __flash_used; #if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0) -- cgit v1.2.1