Skip to content

espressif: fix Wi-Fi IRQ issue during SPI Flash operations#18709

Merged
xiaoxiang781216 merged 2 commits intoapache:masterfrom
fdcavalcanti:bugfix/esp-wifi-fix-irq
Apr 11, 2026
Merged

espressif: fix Wi-Fi IRQ issue during SPI Flash operations#18709
xiaoxiang781216 merged 2 commits intoapache:masterfrom
fdcavalcanti:bugfix/esp-wifi-fix-irq

Conversation

@fdcavalcanti
Copy link
Copy Markdown
Contributor

Summary

Wi-Fi interrupt setup in the ESP32/ESP32-S2/ESP32-S3 (Xtensa) and ESP32-C3/C6 (RISC-V) Wi-Fi adapters now uses the HAL’s global vector descriptor (get_desc_for_int) instead of a separately allocated vector_desc, and registers each line as not in IRAM via esp_intr_set_in_iram(handle, false). That aligns Wi-Fi IRQs with esp_intr_noniram_disable() so they are masked while SPI flash operations hold the cache disabled, reducing risk of Wi-Fi ISRs running from flash in that window.

  • 3405a94f29 arch/risc-v: register Wi-Fi IRQs in non_iram mask for SPI flash
  • 909177e5b7 arch/xtensa: register Wi-Fi IRQs in non_iram mask for SPI flash

This PR fixes an issue where SPI Flash and Wi-Fi would crash when used together. The reason was that Wi-Fi interrupts were accessing cached functions while it was disabled. The correct operation here is to disable Wi-Fi interrupts while cache is off.

Impact

Impact on user: YES — Wi-Fi stability on Espressif boards when SPI flash holds the cache disabled; no public API change.

Impact on build: NO

Impact on hardware: YES — ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6 (Wi-Fi + SPI flash coexistence).

Impact on documentation: NO

Impact on security: NO

Impact on compatibility: NO

Testing

Building

  • ./tools/configure.sh esp32c6-devkitc
  • make (with usual parallelism)
  • Flash the board with your usual method for this defconfig

Running

  • wapi psk wlan0 <password> 3 2
  • wapi essid wlan0 <ssid> 1
  • renew wlan0
  • wapi save_config wlan0

Results

Before the changes, wapi save_config would simply crash with no warning or backtrace. Now it works properly.

nsh> wapi psk wlan0 espmint123 3 2
nsh> wapi essid wlan0 Nuttx-IOT 1
nsh> renew wlan0
nsh> wapi save_config wlan0
nsh> echo $?
0
nsh> cat /data/wapi.conf
{"wlan0":{"mode":2,"auth":4,"cmode":8,"alg":3,"ssid":"Nuttx-IOT","bssid":"e0:1c:fc:00:??:??","psk":"espmint123"}}nsh> 

@github-actions github-actions Bot added Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Size: M The size of the change in this PR is medium labels Apr 10, 2026
@fdcavalcanti fdcavalcanti changed the title Bugfix/esp wifi fix irq espressif: fix Wi-Fi IRQ issue during SPI Flash operations Apr 10, 2026
@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 10, 2026

@fdcavalcanti I opened an Issue about this wapi.conf keeping the password in plain text:

#18710

Comment thread arch/risc-v/src/esp32c3/esp_wifi_adapter.c Outdated
Wi-Fi used a locally allocated vector_desc, so those CPU interrupt lines
were never recorded in the HAL non_iram_int_mask.
During SPI flash, esp_intr_noniram_disable() therefore did not mask them,
and Wi-Fi ISRs could still run with the cache off.
Now, Wi-Fi IRQs are treated as non-IRAM and get masked while flash/cache is suspended.

Signed-off-by: Filipe Cavalcanti <[email protected]>
Wi-Fi used a locally allocated vector_desc, so those CPU interrupt lines
were never recorded in the HAL non_iram_int_mask.
During SPI flash, esp_intr_noniram_disable() therefore did not mask them,
and Wi-Fi ISRs could still run with the cache off.
Now, Wi-Fi IRQs are treated as non-IRAM and get masked while flash/cache is suspended.

Signed-off-by: Filipe Cavalcanti <[email protected]>
@fdcavalcanti fdcavalcanti force-pushed the bugfix/esp-wifi-fix-irq branch from 909177e to 09502b5 Compare April 10, 2026 16:58
@xiaoxiang781216 xiaoxiang781216 merged commit 8fb8c2d into apache:master Apr 11, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants