RTEMS | Draft: bsps/riscv/esp32: Give the BSP a region for code that executes from RAM (!1557)

Sam Price (@TheSamPrice) gitlab at rtems.org
Tue Nov 3 04:19:31 UTC 2026



Sam Price created a merge request: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1557

Project:Branches: TheSamPrice/rtems:esp32c3-iram-region to rtems/rtos/rtems:main
Author: Sam Price

`REGION_FAST_TEXT` is aliased to `CODE_FLASH_MAPPED`, so the region meant for RAM-resident code points at flash. Anything placed in `.fast_text` faults at boot: `bsp_start_copy_sections()` tries to copy it into memory-mapped flash and gets a store access fault. Nothing in the tree uses the section today, so nobody noticed.

The C3 sees one SRAM through two windows: `0x3fc80000` on the data bus and `0x40380000` on the instruction bus. This change carves a `RAM_CODE` region of `ESP32C_IRAM_REGION_SIZE` bytes from the bottom of that SRAM and starts `RAM` that much higher, so the two never overlap.

- **New option `ESP32C_IRAM_REGION_SIZE`, default 0.** A configuration that needs no RAM code builds exactly as before. One that puts code in `.fast_text` without raising the option gets a link error that names `RAM_CODE`.
- **The boot copy writes through the data window.** It writes at `0x3fc8xxxx`, which is the access the part guarantees and how ESP-IDF loads its own IRAM. The offset between the windows, `esp32c_iram_to_dram_delta`, comes from the linker script so the layout lives in one place.

Users: a SPI flash driver needs a few hundred bytes of this (it can't execute from the flash it's erasing), and the Espressif WiFi libraries need about 40 KiB.

**Testing:** `riscv/esp32c3db` and its samples build with no warnings at the default of 0. With a region configured, a function marked `BSP_FAST_TEXT_SECTION` links at `0x40380000`, is copied from flash at boot, and runs correctly from RAM. With the default and something in `.fast_text`, the link fails as described above.

Assisted-by: Claude Opus 5 (1M context) <noreply at anthropic.com>

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1557
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-8mprnd402h0t354c6i9xnimhn-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20261103/aa868fa8/attachment-0001.htm>


More information about the bugs mailing list