Skip to content

Commit a7a4583

Browse files
sylvioalvesdanieldegrasse
authored andcommitted
soc: esp32: loader: skip non-valid segment after the last valid one
Some ESP32 images may not end with a segment whose load_addr is 0xFFFFFFFF, especially if the flash was not fully erased or the image tool does not write an explicit end marker. This can cause the loader to process leftover or unrelated data as additional segments, resulting in boot failures. Update the IS_LAST() macro to treat any segment not matching a valid memory region as the end of the segment list. This ensures only valid segments are loaded and any trailing invalid data is safely skipped. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 0f8b7b7 commit a7a4583

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

soc/espressif/common/loader.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
#endif
7070
#define IS_SRAM(o) (IS_IRAM(o) || IS_DRAM(o))
7171
#define IS_MMAP(o) (IS_IROM(o) || IS_DROM(o))
72-
#define IS_LAST(o) (o.load_addr == 0xffffffff)
72+
#define IS_LAST(o) \
73+
(!IS_IROM(o) && !IS_DROM(o) && !IS_IRAM(o) && !IS_DRAM(o) && !IS_PADD(o) && !IS_RTC(o))
7374

7475
#define HDR_ATTR __attribute__((section(".entry_addr"))) __attribute__((used))
7576

0 commit comments

Comments
 (0)