Commit a7a4583e authored by Sylvio Alves's avatar Sylvio Alves Committed by Daniel DeGrasse
Browse files

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: default avatarSylvio Alves <sylvio.alves@espressif.com>
parent 0f8b7b74
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@
#endif
#define IS_SRAM(o) (IS_IRAM(o) || IS_DRAM(o))
#define IS_MMAP(o) (IS_IROM(o) || IS_DROM(o))
#define IS_LAST(o) (o.load_addr == 0xffffffff)
#define IS_LAST(o) \
	(!IS_IROM(o) && !IS_DROM(o) && !IS_IRAM(o) && !IS_DRAM(o) && !IS_PADD(o) && !IS_RTC(o))

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