diff options
Diffstat (limited to 'tools/image.zig')
| -rw-r--r-- | tools/image.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/image.zig b/tools/image.zig index dea843f..ba60064 100644 --- a/tools/image.zig +++ b/tools/image.zig @@ -13,7 +13,10 @@ //! ships as a 1.4 KB image instead of a 66 KB one. Verified on ESP32-P4 rev v1.3 silicon. //! //! Rules the loader enforces, each learned by flashing a deliberately broken image at the board: -//! * exactly two segments must land in the mapped range (bootloader_utility.c:842) +//! * exactly two segments must land in the mapped range: on a chip with shared D/I external +//! vaddr (the P4, soc.h:146-149) the loader collects them positionally and asserts +//! rom_index == 2 (bootloader_utility.c:805-851); one segment aborts the boot and a third +//! trips an assert inside the loop (bootloader_utility.c:842) //! * every segment length must be a multiple of 4 (esp_image_format.c:857) //! * image offset 0x20 begins an esp_app_desc_t, and min/max_efuse_blk_rev_full are read from //! it whether or not it is really a descriptor (esp_image_format.c:796-806) @@ -116,6 +119,14 @@ pub const Layout = struct { } off += seg_header_len + s.len; } + // EXACTLY two, and the bootloader is what says so. On a chip whose D/I external vaddr ranges + // are shared - the P4's are (soc.h:146-149) - ESP-IDF takes the SOC_MMU_DI_VADDR_SHARED + // branch of `unpack_load_app` (bootloader_utility.c:805-851), which does not classify + // segments as D or I at all: it collects them positionally into rom_addr[2] and ends with + // `assert(rom_index == 2)`. One mapped segment aborts the boot with + // "Assert failed in unpack_load_app, bootloader_utility.c:842 (rom_index == 2)" - measured, + // by shipping one - and a third trips `assert(rom_index < 2)` inside the loop. Enforcing it + // here turns a boot-time abort into a build-time error. if (mapped != 2) return error.NotTwoMappedSegments; // One MMU entry per vaddr page: any two mapped segments in the same vaddr page must come |
