esp32s3: fix booting large DROM images - #5567
Open
rdon-key wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.