zephyr: ESP32-S3 WiFi does not work if external SPIRAM is enabled
Describe the bug If SPIRAM is enabled, WiFi does not work on ESP32S3 WROOM N16R8.
WiFi Works if SPIRAM is disabled:
west build --pristine -b xiao_esp32s3/esp32s3/procpu samples/net/wifi -DCONFIG_ESP_SPIRAM=n && west flash && west espressif monitor
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x28 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40048df9
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fc94170,len:0x3804
load:0x40374000,len:0x1014c
SHA-256 comparison failed:
Calculated: 8923cad87525e34488aa27e9abb59530d31d7a56f3c68686442b1c27b70b23be
Expected: 0000000070c60000000000000000000000000000000000000000000000000000
Attempting to boot anyway...
entry 0x4037cdd8
I (94) boot: ESP Simple boot
I (94) boot: compile time Jun 14 2024 01:20:43
W (95) boot: Unicore bootloader
I (95) spi_flash: detected chip: gd
I (96) spi_flash: flash io: dio
W (99) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (111) boot: chip revision: v0.2
I (114) boot.esp32s3: Boot SPI Speed : 40MHz
I (118) boot.esp32s3: SPI Mode : DIO
I (122) boot.esp32s3: SPI Flash Size : 8MB
I (126) boot: Enabling RNG early entropy source...
[esp32s3] [INF] DRAM: lma 0x00000020 vma 0x3fc94170 len 0x3804 (14340)
[esp32s3] [INF] IRAM: lma 0x0000382c vma 0x40374000 len 0x1014c (65868)
[esp32s3] [INF] padd: lma 0x00013988 vma 0x00000000 len 0xc670 (50800)
[esp32s3] [INF] IMAP: lma 0x00020000 vma 0x42000000 len 0x53260 (340576)
0x42000000: _stext at ??:?
[esp32s3] [INF] padd: lma 0x00073268 vma 0x00000000 len 0xcd90 (52624)
[esp32s3] [INF] DMAP: lma 0x00080000 vma 0x3c060000 len 0x131ec (78316)
[esp32s3] [INF] Image with 6 segments
[esp32s3] [INF] DROM segment: paddr=00080000h, vaddr=3c060000h, size=131F0h ( 78320) map
[esp32s3] [INF] IROM segment: paddr=00020000h, vaddr=42000000h, size=5325Eh (340574) map
*** Booting Zephyr OS build v3.6.0-5736-gd78a9429450f ***
uart:~$ wifi scan
Scan requested
Num | SSID (len) | Chan (Band) | RSSI | Security | BSSID | MFP
1 | IoT 3 | 1 (2.4GHz) | -67 | WPA2-PSK | | Disable
2 | IoT 3 | 11 (2.4GHz) | -74 | WPA2-PSK | | Disable
3 | IoT 3 | 6 (2.4GHz) | -87 | WPA2-PSK | | Disable
Scan request done
uart:~$
If SPIRAM is enabled, then WiFi returns nothing for wifi scan and will also not connect. I only have octal SPI devices, so I am unable to determine if this is just an octal SPI issue or it it applies to quad SPI as well.
west build --pristine -b xiao_esp32s3/esp32s3/procpu samples/net/wifi -DCONFIG_ESP_SPIRAM=y -DCONFIG_SPIRAM_MODE_OCT=y && west flash && west espressif monitor
I (97) boot: ESP Simple boot
I (97) boot: compile time Jun 14 2024 01:13:09
W (97) boot: Unicore bootloader
I (97) spi_flash: detected chip: gd
I (98) spi_flash: flash io: dio
W (101) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (114) boot: chip revision: v0.2
I (117) boot.esp32s3: Boot SPI Speed : 40MHz
I (121) boot.esp32s3: SPI Mode : DIO
I (124) boot.esp32s3: SPI Flash Size : 8MB
I (128) boot: Enabling RNG early entropy source...
[esp32s3] [INF] DRAM: lma 0x00000020 vma 0x3fc94a30 len 0x3b1c (15132)
[esp32s3] [INF] IRAM: lma 0x00003b44 vma 0x40374000 len 0x10a10 (68112)
[esp32s3] [INF] padd: lma 0x00014568 vma 0x00000000 len 0xba90 (47760)
[esp32s3] [INF] IMAP: lma 0x00020000 vma 0x42000000 len 0x53598 (341400)
[esp32s3] [INF] padd: lma 0x000735a0 vma 0x00000000 len 0xca58 (51800)
[esp32s3] [INF] DMAP: lma 0x00080000 vma 0x3c060000 len 0x1337c (78716)
[esp32s3] [INF] Image with 6 segments
[esp32s3] [INF] DROM segment: paddr=00080000h, vaddr=3c060000h, size=13380h ( 78720) map
[esp32s3] [INF] IROM segment: paddr=00020000h, vaddr=42000000h, size=53596h (341398) map
I (202) octal_psram: vendor id : 0x0d (AP)
I (202) octal_psram: dev id : 0x02 (generation 3)
I (202) octal_psram: density : 0x03 (64 Mbit)
I (204) octal_psram: good-die : 0x01 (Pass)
I (209) octal_psram: Latency : 0x01 (Fixed)
I (213) octal_psram: VCC : 0x01 (3V)
I (217) octal_psram: SRF : 0x01 (Fast Refresh)
I (222) octal_psram: BurstType : 0x01 (Hybrid Wrap)
I (227) octal_psram: BurstLen : 0x01 (32 Byte)
I (231) octal_psram: Readlatency : 0x02 (10 cycles@Fixed)
I (237) octal_psram: DriveStrength: 0x00 (1/1)
I (241) esp_psram: Found 8MB PSRAM device
I (244) esp_psram: Speed: 40MHz
I (978) esp_psram: SPI SRAM memory test OK
*** Booting Zephyr OS build v3.6.0-5736-gd78a9429450f ***
uart:~$ wifi scan
Scan requested
*** SHOULD BE A LIST OF ACCESS POINTS HERE ***
Scan request done
uart:~$
To Reproduce Steps to reproduce the behavior:
- Use an ESP32S3 WROOM N16R8
- Build with SPIRAM enabled:
west build --pristine -b xiao_esp32s3/esp32s3/procpu samples/net/wifi -DCONFIG_ESP_SPIRAM=y -DCONFIG_SPIRAM_MODE_OCT=y && west flash && west espressif monitor - Do a “wifi scan” command
- See that no access points are found. In addition, WiFi will not connect to any known access points
Expected behavior WiFi scan finds access points and allows connecting.
Impact Complete failure of WiFi
Environment (please complete the following information): Zephyr 3.6.99 main @ d78a9429450f89de7829c8af7efe41fdb692fd50
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (10 by maintainers)
Doing a bit more debugging, the issue is that the ESP32-S3 WiFi stack does not support buffers allocated in SPIRAM and the minimum heap size of 51200 is too small, so the heap manager starts allocating out of SPIRAM.
Increasing the heap size to 100KB allows the scan to work and shows that the maximum heap usage is 83400 bytes.
The
HEAP_MEM_POOL_ADD_SIZE_BOARDshould be increased to 86016 or similar to allow WiFi to work.However, this increased memory requirement makes the ESP32-S3 target very difficult to use since the internal SRAM is already in short supply with just this example already using 73% of the available memory. Is there any chance that the ESP32-S3 WiFi stack could be fixed to support using buffers from SPIRAM? That has been a long-term issue.
No, I meant to say that enabling this flag will ask for additional dozens of kB of memory - it is automatically enabled when CONFIG_ESP_SPIRAM is enabled.
They both work for me (I used
xiao_esp32s3/esp32s3/procpusince that is the hardware that I have on hand), so I’m happy to mark this as fixed.@EricNRS thanks for bumping the issue and your patience. I checked the following builds and both work well on my end. Can you update and try again please?
west build -p -b esp32s3_devkitm/esp32s3/procpu samples/net/wifi/shell/ -DCONFIG_ESP_SPIRAM=ywest build -p -b esp32s3_devkitm/esp32s3/procpu samples/net/wifi/shell/ -DCONFIG_ESP_SPIRAM=y -DCONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM=y@sylvioalves does this mean that its coming soon? 😃
It is not fully fixed yet.
@EricNRS, @vigen1980 can you please try to disable the
CONFIG_FEATURE_CACHE_TX_BUF_BITflag from theg_wifi_feature_caps(in theesp_wifi_adapter.c) and give it a try? In my case, allocating those extra TX buffers renders the wifi to not working.