From b7f3c06b09ff8a17e86f1c6943cf8ab64670e805 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Thu, 30 Jul 2026 14:16:01 +0200 Subject: [PATCH] xtensa/esp32s3: keep octal-flash init in IRAM for the protected build The protected kernel linker (kernel-space.ld) placed the octal (OPI) flash bring-up helpers -- esp_rom_spiflash / esp_rom_opiflash_*, spi_flash_oct_flash_init, mmu_hal, mspi_timing_*, bootloader_flash*, efuse_hal/efuse_utility, esp_mmu_map and esp32s3_spi_timing -- in mapped flash. During configure_cpu_caches() / spi_flash_init_chip_state() in __start these run while the flash mapping is being reconfigured, which faults (illegal instruction) on octal-flash modules such as the ESP32-S3-WROOM-2. Quad-flash parts never exercise the OPI path, so the problem was latent. Place those functions in .iram0.text (mirroring the flat sections script) so they are safe to execute during flash reconfiguration. Assisted-by: Claude Opus 4.8 (1M context) Signed-off-by: Marco Casaroli --- boards/xtensa/esp32s3/common/scripts/kernel-space.ld | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boards/xtensa/esp32s3/common/scripts/kernel-space.ld b/boards/xtensa/esp32s3/common/scripts/kernel-space.ld index 942d3d4753f..1e33d5df35b 100644 --- a/boards/xtensa/esp32s3/common/scripts/kernel-space.ld +++ b/boards/xtensa/esp32s3/common/scripts/kernel-space.ld @@ -190,6 +190,7 @@ SECTIONS *libkarch.a:*uart_hal.*(.text .text.* .literal .literal.*) *libkarch.a:*mpu_hal.*(.text .text.* .literal .literal.*) *libkarch.a:*mmu_hal.*(.text .text.* .literal .literal.*) + *libkarch.a:*esp_mmu_map.*(.text .text.* .literal .literal.*) *libkarch.a:*efuse_hal.*(.text .text.* .literal .literal.*) *libkarch.a:*uart_periph.*(.text .text.* .literal .literal.*) *libkarch.a:*esp_rom_uart.*(.text .text.* .literal .literal.*) @@ -217,6 +218,7 @@ SECTIONS *libkarch.a:*mspi_timing_tuning.*(.text .text.* .literal .literal.*) *libkarch.a:*mspi_timing_config.*(.text .text.* .literal .literal.*) + *libkarch.a:esp32s3_spi_timing.*(.text .text.* .literal .literal.*) *libkarch.a:*spi_flash_oct_flash_init.*(.text .text.* .literal .literal.*) *libkarch.a:*spi_flash_hpm_enable.*(.text .text.* .literal .literal.*) #endif