Repository navigation
Conversation
|
The #5554 now absorbes this change and is verified to boot and pass the test: |
The ESP32-S3 ROM bootloader cannot load large IROM and DROM segments directly. Separate flash-mapped segments from RAM-loaded segments and place them at dedicated flash offsets. Update the startup code to configure the cache MMU and map IROM and DROM across multiple 64 KB pages.
d9c4528 to
ffa66bc
Compare
The ESP32-S3 image builder aligns IROM and DROM to 64 KB boundaries, introducing approximately 124 KB of unnecessary padding. The flash MMU only requires the lower 16 bits of the physical flash offset and virtual address to match. Calculate the flash offsets accordingly and update the linker script and startup MMU mapping to support the resulting layout.
ffa66bc to
e3b2499
Compare
|
Since PSRAM support in #5554 may take some time, I've rebased As this is an independent bug fix, I'd like to move it forward I've also removed the unnecessary flash padding pointed out in #5554. Tested on M5Stamp-S3A (8 MB flash):
The updated image boots successfully and passes all five The CI smoke test also revealed a 4-byte alignment gap before All CI checks now pass. |
The ROM rejects an image with an IROM or DROM segment of 1 MiB or more. Keep IROM and DROM out of the segments the ROM loads. They follow the RAM part of the image, and the startup code maps them with the MMU. machine.Flash uses the MMU entries after DROM and gets its physical flash offset from the linker script. Based on #5567 by rdon-key.
The ROM rejects an image with an IROM or DROM segment of 1 MiB or more. Keep IROM and DROM out of the segments the ROM loads. They follow the RAM part of the image, and the startup code maps them with the MMU. machine.Flash uses the MMU entries after DROM and gets its physical flash offset from the linker script. Based on #5567 by rdon-key.
|
The fix from this PR has been incorporated into #6001, following the maintainers' decision. The integration also includes changes to ensure compatibility with existing flash operations ( Thanks for carrying this work forward! |
The ROM rejects an image with an IROM or DROM segment of 1 MiB or more. Keep IROM and DROM out of the segments the ROM loads. They follow the RAM part of the image, and the startup code maps them with the MMU. machine.Flash uses the MMU entries after DROM and gets its physical flash offset from the linker script. Based on #5567 by rdon-key.
Status: Superseded by #6001
The fix from this PR has been incorporated into #6001, along with additional changes to ensure compatibility with existing flash operations (
machine.Flash).Please refer to #6001 for further development.
This PR fixes an ESP32-S3 boot failure that occurs when the DROM segment exceeds 1 MiB.
Previously, DROM and IROM were stored as regular ESP image segments visible to the ROM bootloader. When the image contained a large DROM segment, the ROM rejected the image before the TinyGo startup code could run.
The failure looked like this:
Cause
On the ESP32-S3, DROM and IROM are not copied into RAM by the ROM bootloader. They are accessed through the flash cache MMU configured by the startup code.
The previous implementation had the following problems:
As a result, the ROM bootloader attempted to process a large DROM segment and rejected the image before entering the TinyGo startup code.
Changes
This PR makes the following changes:
.data.Hardware verification
The fix was tested on an M5Stamp-S3A with an ESP32-S3 and 8 MiB of flash.
Test data
A 7.5 MiB binary file was embedded in DROM.
The file is 7,864,320 bytes long and consists of the following 256-byte sequence repeated 30,720 times:
The data is deterministic and can be reproduced with the following script:
Details
Expected output:
The expected CRC32 values are:
Verification program
The following program reads the entire 7.5 MiB payload and calculates its CRC32 five consecutive times:
The program was flashed with:
Before this change
On the previous
devrevision, the ROM bootloader attempted to load the 7.5 MiB DROM segment and rejected the image before the TinyGo startup code was reached:After this change
With this change, all five consecutive CRC32 verification passes succeeded:
The complete flash-and-verification procedure was repeated three times, and all runs succeeded.
This confirms not only that an image containing a large DROM region can boot, but also that the complete 7.5 MiB DROM contents remain correctly accessible across repeated full reads.
Other ESP32 targets
The ESP32-C3 and ESP32-C6 paths are implemented in separate files that this PR does not touch.
The ESP32 shares
builder/esp.gowith the ESP32-S3, but the new image layout is applied only to the ESP32-S3 branch, and the existing ESP32 code path remains unchanged. The MMU changes are confined to ESP32-S3-specific files.I do not have ESP32 hardware available, so the ESP32 code path has not been verified on a device.