From f4bbe276e127077d4896540673b31cb020e32de8 Mon Sep 17 00:00:00 2001 From: Almir Okato Date: Mon, 15 Apr 2024 15:16:21 -0300 Subject: [PATCH] esp32[c3|c6|h2]: Fix simple boot map_rom_segments Currently Simple Boot image have fixed 2 ROM segments and 2 RAM segments, then the parsing iterator must stop when all ROM segments are found. Signed-off-by: Almir Okato --- arch/risc-v/src/common/espressif/esp_start.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/risc-v/src/common/espressif/esp_start.c b/arch/risc-v/src/common/espressif/esp_start.c index cbbeffe58e2c7..cbb45fcc8e5df 100644 --- a/arch/risc-v/src/common/espressif/esp_start.c +++ b/arch/risc-v/src/common/espressif/esp_start.c @@ -240,18 +240,10 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr, bool padding_checksum = false; unsigned int segments = 0; unsigned int ram_segments = 0; + unsigned int rom_segments = 0; size_t offset = CONFIG_BOOTLOADER_OFFSET_IN_FLASH; #endif - ets_printf("\nIROM lma: 0x%lx vma: 0x%lx size: 0x%lx\n", - (uint32_t)_image_irom_lma, - (uint32_t)_image_irom_vma, - (uint32_t)_image_irom_size); - ets_printf("DROM lma: 0x%lx vma: 0x%lx size: 0x%lx\n", - (uint32_t)_image_drom_lma, - (uint32_t)_image_drom_vma, - (uint32_t)_image_drom_size); - #ifdef CONFIG_ESPRESSIF_SIMPLE_BOOT /* Read image header */ @@ -268,7 +260,7 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr, /* Iterate for segment information parsing */ - while (segments++ < 16) + while (segments++ < 16 && rom_segments < 2) { /* Read segment header */ @@ -318,6 +310,7 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr, { app_drom_start = offset + sizeof(esp_image_segment_header_t); app_drom_start_aligned = app_drom_start & MMU_FLASH_MASK; + rom_segments++; } if (IS_IROM(segment_hdr.load_addr) && @@ -325,6 +318,7 @@ static int map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr, { app_irom_start = offset + sizeof(esp_image_segment_header_t); app_irom_start_aligned = app_irom_start & MMU_FLASH_MASK; + rom_segments++; } if (IS_SRAM(segment_hdr.load_addr))