diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-09-23 18:39:31 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-11 19:15:36 +0000 |
commit | f050111663cb33a061cfbdc07dc836a5af13d362 (patch) | |
tree | 0a2266b910027c12b8f4b2c06e09f288e908a987 /core | |
parent | 187f9155f684d0aeda4546bf04451ae8825f2de8 (diff) | |
download | chrome-ec-f050111663cb33a061cfbdc07dc836a5af13d362.tar.gz |
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/<board>/<image>/ec.<image>.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 <tomhughes@chromium.org>
Change-Id: I7c64b6ba9bceeeb4044559188c1c1bebbf60471d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3179314
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/ec.lds.S | 9 | ||||
-rw-r--r-- | core/cortex-m0/ec.lds.S | 9 | ||||
-rw-r--r-- | core/nds32/ec.lds.S | 9 | ||||
-rw-r--r-- | core/riscv-rv32i/ec.lds.S | 13 |
4 files changed, 32 insertions, 8 deletions
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index c5314111d0..fcf7a1fecc 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -488,11 +488,16 @@ SECTIONS #endif /* - * __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 = FLASH_USED_END - ORIGIN(EC_IMAGE_LMA_MEM_REGION); + __flash_size = LENGTH(EC_IMAGE_LMA_MEM_REGION); #ifndef CONFIG_CHIP_INIT_ROM_REGION #if !(defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 4)) __image_size = __flash_used; 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) diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S index 4993593f87..da65f1a1f0 100644 --- a/core/nds32/ec.lds.S +++ b/core/nds32/ec.lds.S @@ -278,11 +278,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) - FW_OFF(SECTION); + __flash_size = LENGTH(FLASH); __image_size = __flash_used; #if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0) diff --git a/core/riscv-rv32i/ec.lds.S b/core/riscv-rv32i/ec.lds.S index 2b88b14f24..9e7acd684b 100644 --- a/core/riscv-rv32i/ec.lds.S +++ b/core/riscv-rv32i/ec.lds.S @@ -348,9 +348,13 @@ 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. */ #if defined(CHIP_FAMILY_IT8XXX2) __flash_used = LOADADDR(.data) + SIZEOF(.data) + \ @@ -358,6 +362,11 @@ SECTIONS #else __flash_used = LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION); #endif +#if defined(CONFIG_FLASH_PHYSICAL) + __flash_size = LENGTH(FLASH); +#else + __flash_size = LENGTH(IROM); +#endif __image_size = __flash_used; #if defined(SECTION_IS_RW) && (CONFIG_FLASH_WRITE_SIZE > 0) |