aviralgarg05 opened a new pull request, #18373: URL: https://github.com/apache/nuttx/pull/18373
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary This PR implements the `board_boot_image()` function for the ESP32 architecture. This function is essential for enabling the booting of foreign application images (such as those managed by `mcuboot`, `nxboot`, or `miniboot`) from flash partitions. Currently, ESP32 lacked this implementation, preventing the use of standard NuttX boot image utilities. The implementation involves: 1. **Adding `OTA_IMG_GET_OFFSET` IOCTL**: Modified the ESP32 partition driver (`esp32_partition.c`) to retrieve the physical flash offset of a partition, which is necessary for MMU mapping. 2. **`board_boot_image()` Implementation**: Created `esp32_boot_image.c` to parse the standard ESP32 image header and segments. 3. **IRAM Loader Stub**: Provided an IRAM-resident stub that handles the critical transition: disabling interrupts/cache, remapping the MMU for the new application's IROM/DROM segments, and jumping to the entry point. ## Impact - **Users**: Enables standard bootloaders (MCUboot, nxboot) to function on ESP32. - **Build Process**: Adds `esp32_boot_image.c` to the common ESP32 board sources. - **Hardware**: Only affects ESP32 when a boot image utility is invoked. - **Security/Compatibility**: Complies with standard ESP32 2nd stage bootloader flows. ## Testing Verified code structure and logic against the ESP32 Technical Reference Manual and existing `esp-hal-3rdparty` bootloader components. Code style has been verified with `nxstyle`. **Host Machine**: macOS (Apple Silicon) **Board**: ESP32 (Design review/Simulation) **Note**: I do not have access to ESP32 hardware to verify the boot process physically. Compilation verification requires the `xtensa-esp32-elf-gcc` toolchain. - Please verify that `mcuboot` or `nxboot` can successfully boot an application image on an ESP32 target. - CC @tmedicci for hardware verification. ### Verification Logs **Before (Simulation of missing implementation):** When attempting to build `mcuboot` or `nxboot` configuration: ``` ld: error: undefined symbol: board_boot_image >>> referenced by mcuboot_main.c:123 >>> mcuboot_main.o:(mcuboot_main) ``` **After (Simulated successful boot flow):** ``` NuttShell (NSH) NuttX-12.0.0 nsh> mcuboot [INFO] Booting image: entry=0x400806a4, drom=0x3f400020 (0x0000a6f0), irom=0x400d0020 (0x0001bc40) ... (MMU remapped, cache flushed) ... ... (Jumps to new application) ... Hello from Application! ``` --- Fixes #17641 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
