From c29dbda5fd7626d662badfcc26b6a5ce63c4abda Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Tue, 23 Mar 2021 11:23:52 +0800 Subject: [PATCH] build: fix cache issue when .flash.text section alignment is uncommon rodata dummy section has now the same alignment as flash text section, and at least the same size. For these reasons, the cache will map correctly the following rodata section. --- components/esp32c3/ld/esp32c3.project.ld.in | 11 ++++++++++- components/esp32s3/ld/esp32s3.project.ld.in | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/components/esp32c3/ld/esp32c3.project.ld.in b/components/esp32c3/ld/esp32c3.project.ld.in index 342a968a95..bcbbf1859e 100644 --- a/components/esp32c3/ld/esp32c3.project.ld.in +++ b/components/esp32c3/ld/esp32c3.project.ld.in @@ -283,9 +283,18 @@ SECTIONS _flash_cache_start = ABSOLUTE(0); } > default_code_seg + /** + * This dummy section represents the .flash.text section but in default_rodata_seg. + * Thus, it must have its alignement and (at least) its size. + */ .flash_rodata_dummy (NOLOAD): { - . = SIZEOF(.flash.text); + /* Start at the same alignement constraint than .flash.text */ + . = ALIGN(ALIGNOF(.flash.text)); + /* Create an empty gap as big as .flash.text section */ + . = . + SIZEOF(.flash.text); + /* Prepare the alignement of the section above. Few bytes (0x20) must be + * added for the mapping header. */ . = ALIGN(0x10000) + 0x20; _rodata_reserved_start = .; } > default_rodata_seg diff --git a/components/esp32s3/ld/esp32s3.project.ld.in b/components/esp32s3/ld/esp32s3.project.ld.in index ff46c4d269..05e8f79e67 100644 --- a/components/esp32s3/ld/esp32s3.project.ld.in +++ b/components/esp32s3/ld/esp32s3.project.ld.in @@ -314,9 +314,18 @@ SECTIONS _flash_cache_start = ABSOLUTE(0); } > default_code_seg + /** + * This dummy section represents the .flash.text section but in default_rodata_seg. + * Thus, it must have its alignement and (at least) its size. + */ .flash_rodata_dummy (NOLOAD): { - . = SIZEOF(.flash.text); + /* Start at the same alignement constraint than .flash.text */ + . = ALIGN(ALIGNOF(.flash.text)); + /* Create an empty gap as big as .flash.text section */ + . = . + SIZEOF(.flash.text); + /* Prepare the alignement of the section above. Few bytes (0x20) must be + * added for the mapping header. */ . = ALIGN(0x10000) + 0x20; _rodata_reserved_start = .; } > default_rodata_seg