feat(esp32s3): add PSRAM support - #5554
Conversation
141f8e7 to
c163bd8
Compare
8d9dea3 to
39c1a4c
Compare
|
I am removing QSPI support for now. The boards I got also have PSRAM connected via Octo-SPI. Apparently all ESP32-S3 boards with 8M PSRAM use OctoSPI. OctoSPI is verified on 2 different ESP32-S3 boards now. |
39c1a4c to
dad7399
Compare
|
works fine with XIAO ESP32S3 |
|
@deadprogram I believe this is ready |
|
#5567 changes how ESP32-S3 IROM/DROM are placed in flash and mapped through the MMU, in order to support larger flash images. This PR also changes the ESP32-S3 MMU and linker layout for PSRAM, and as far as I can tell it still assumes the current flash mapping (see Since both touch the same memory-layout area, @deadprogram would it make sense to settle #5567 first, and then review this one against the resulting layout? Happy to help with the rebase either way. @digitalentity does that match your reading, or do you think the two are independent enough to review separately? |
|
I tested #5554 with the same large-DROM reproduction case used for #5567. It still fails in the ROM bootloader before TinyGo startup is reached: So #5554 does not appear to fix the large image boot issue. #5567 still seems to be needed to change how the IROM/DROM segments are laid out in the ESP image. |
|
@rdon-key how do you test? Is it sufficient to put 1M data into the DROM to make it fail? I suspect it's merely the image layout issue. The #5567 is still needed to fix it, but I'm wondering if changes to the linker script and the image builder would be sufficient. I'll try blending our changes together and see what happens. |
|
@digitalentity I haven't tested the exact minimum failing size separately. It appears to be around 1 MiB. If you're testing it, I'd also try a case near the flash limit. |
|
@rdon-key apparently your entire change is necessary to support large image boot. I'll have to figure out how to change the MMU mapping to support PSRAM on top of it. |
|
@digitalentity Using #5567 as the base and adapting the PSRAM MMU mapping on top of it sounds good to me. Once you have a combined branch, I'm happy to test the large-image case again on the M5Stamp-S3A. |
Add runtime initialization, MMU layout, linker script mappings, and targets for ESP32-S3 Octal PSRAM.
dad7399 to
f4ada9e
Compare
The ROM bootloader rejects an image whose DROM segment exceeds 1MB, so any application with more than 1MB of read-only data failed to boot. DROM and IROM are now kept out of the ROM-loaded segment table entirely and appended to the image at 64KB-aligned flash offsets. Those offsets are patched into .data before the checksum and hash are computed, and the startup code programs the flash cache MMU from them, which decouples virtual pages from flash pages. Because the ESP32-S3 IBUS and DBUS windows share one 512-entry MMU table, .text and .rodata must occupy disjoint linear ranges. The linker script now places .rodata one whole page past the end of .text and sizes the DROM region so that an overlarge link fails at link time instead of silently colliding with the PSRAM window. Co-Authored-By: Konstantin Sharlaimov <konstantin.sharlaimov@gmail.com>
|
This PR now absorbes the #5567. @rdon-key @deadprogram, the change is tested and confirmed to boot large images correctly on a generic ESP32-S3 and ESP32-S3 w/ PSRAM ( Thanks a lot @rdon-key for fixing the large image boot. This will be extremely useful once we also have #5556 and will need to store high-res sprites in the image itself. |
|
@digitalentity Nice work getting the large-image case booting. One concern: the plan here was to use #5567 as the base and adapt the PSRAM MMU mapping on top of it. Absorbing #5567 into this PR, together with the builder refactor, makes the scope significantly larger and harder to review. This now combines PSRAM support, the IROM/DROM layout fix, and a builder refactor in one PR. Keeping those changes separate would make review and testing easier, and regressions much easier to isolate. My preference would still be #5567 first, then rebase the PSRAM work on top of it. @deadprogram thoughts? |
|
Here are some generated comments regarding the latest changes: Reviewed locally by fetching the branch, building Main concern: every S3 image grows ~124 KB. Same This looks avoidable: base got zero padding from the Also worth noting: the flash-segment rework touches all esp32s3 targets, not just PSRAM ones, so I'd want boot confirmation on a couple of plain S3 boards before merge. Correctness items:
Verified working: |
PSRAM support for ESP32-S3. Enabled via
numa_psram_qspiandnuma_psram_octalbuild tags.Test on QSPI board with:
./build/tinygo flash -size=short -serial=uart -target=esp32s3-psram-qspi -monitor -panic=trap examples/psramTest on OPI board with:
./build/tinygo flash -size=short -serial=uart -target=esp32s3-psram-octal -monitor -panic=trap examples/psram, should be getting something like this:Partly fixes #3772