Skip to content

Commit bcd80c9

Browse files
committed
Merge branch 'fix/reduce_rtc_text_size' into 'master'
fix(system): linker script: free unused .rtc.text memory for esp32c3, esp32s2 See merge request espressif/esp-idf!33972
2 parents f297a9d + 3c5d24e commit bcd80c9

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

components/esp_system/ld/esp32c3/sections.ld.in

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ SECTIONS
1919
{
2020
ALIGNED_SYMBOL(4, _rtc_fast_start)
2121

22+
HIDDEN(_rtc_code_start = .);
23+
2224
mapping[rtc_text]
2325

2426
*rtc_wake_stub*.*(.text .text.*)
2527
*(.rtc_text_end_test)
2628

27-
/* Padding for possible CPU prefetch + alignment for PMS split lines */
28-
. += _esp_memprot_prefetch_pad_size;
29-
. = ALIGN(_esp_memprot_align_size);
29+
HIDDEN(_rtc_code_end = .);
30+
31+
/* Padding for possible CPU prefetch + 4B alignment for PMS split lines. */
32+
. = ((_rtc_code_end - _rtc_code_start) == 0) ?
33+
ALIGN(0) : _esp_memprot_prefetch_pad_size + ALIGN(4);
3034

3135
_rtc_text_end = ABSOLUTE(.);
3236
} > rtc_iram_seg

components/esp_system/ld/esp32s2/sections.ld.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ SECTIONS
2626
{
2727
ALIGNED_SYMBOL(4, _rtc_text_start)
2828

29+
HIDDEN(_rtc_code_start = .);
30+
2931
mapping[rtc_text]
3032

3133
*rtc_wake_stub*.*(.literal .text .literal.* .text.*)
3234

33-
/* Padding for possible CPU prefetch + alignment for PMS split lines */
34-
. += _esp_memprot_prefetch_pad_size;
35-
. = ALIGN(_esp_memprot_align_size);
35+
HIDDEN(_rtc_code_end = .);
36+
37+
/* Possibly align + 16B for CPU dummy speculative instruction fetch. */
38+
. = ((_rtc_code_end - _rtc_code_start) == 0) ? ALIGN(0) : ALIGN(4) + 16;
3639

3740
_rtc_text_end = ABSOLUTE(.);
3841
} > rtc_iram_seg

components/esp_system/ld/esp32s3/sections.ld.in

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@ SECTIONS
2020
ALIGNED_SYMBOL(4, _rtc_fast_start)
2121
ALIGNED_SYMBOL(4, _rtc_text_start)
2222

23+
HIDDEN(_rtc_code_start = .);
24+
2325
*(.rtc.entry.literal .rtc.entry.text)
2426

2527
mapping[rtc_text]
2628

2729
*rtc_wake_stub*.*(.literal .text .literal.* .text.*)
2830
*(.rtc_text_end_test)
2931

30-
/* Padding for possible CPU prefetch + alignment for PMS split lines */
31-
. += _esp_memprot_prefetch_pad_size;
32-
. = ALIGN(_esp_memprot_align_size);
32+
HIDDEN(_rtc_code_end = .);
33+
34+
/* Padding for possible CPU prefetch + 4B alignment for PMS split lines. */
35+
. = ((_rtc_code_end - _rtc_code_start) == 0) ?
36+
ALIGN(0) : _esp_memprot_prefetch_pad_size + ALIGN(4);
3337

3438
_rtc_text_end = ABSOLUTE(.);
3539
} > rtc_iram_seg

0 commit comments

Comments
 (0)