WIFI driver initialization failed due to lack of RAM

Laurent
Posts: 2
Joined: Fri Apr 19, 2024 7:02 am

WIFI driver initialization failed due to lack of RAM

Postby Laurent » Mon Sep 30, 2024 3:43 pm

Hello,

As the following traces show, I don't have enough internal RAM available in the ESP32-S3 when initializing WIFI.
OK, that's possible, my project need a lot of internal RAM. But why when I make PSRAM memory available, I still don't have enough memory available for WIFI?
(KCONFIG with: SPIRAM true, Octal Mode PSRAM enabled, SPIRAM_TYPE Auto-detect, SPIRAM_TRY_ALLOCATE_WIFI_LWIP enabled).
There's 8 MB free in the PSRAM!

Has anyone ever run a project with WIFI using all or part of the PSRAM? I'm on ESP-IDF version 5.3.1.

Thanks in advance.

I (2764) wifi:wifi driver task: 3fccb058, prio:23, stack:6656, core=0
I (2779) wifi:wifi firmware version: ccaebfa
I (2780) wifi:wifi certification version: v7.0
I (2780) wifi:config NVS flash: enabled
I (2780) wifi:config nano formating: disabled
I (2784) wifi:Init data frame dynamic rx buffer num: 32
I (2789) wifi:Init static rx mgmt buffer num: 5
I (2794) wifi:Init management short buffer num: 32
W (2798) wifi:esf_buf_setup_static: alloc eb fail(1)
I (2803) wifi:Deinit lldesc rx mblock:0
I (2806) wifi:Deinit lldesc rx mblock:0
I (2810) wifi:Deinit lldesc rx mblock:0
W (14:37:27.238) wifi_init: Failed to unregister Rx callbacks
E (14:37:27.242) wifi_init: Failed to deinit Wi-Fi driver (0x3001)
E (14:37:27.250) wifi_init: Failed to deinit Wi-Fi (0x3001)
ESP_ERROR_CHECK failed: esp_err_t 0x101 (ESP_ERR_NO_MEM) at 0x42021b69

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: WIFI driver initialization failed due to lack of RAM

Postby ESP_Sprite » Tue Oct 01, 2024 3:07 pm

WiFi always needs some buffers (e.g. dma descriptors) to be in internal memory. Maybe you somehow managed to fill up your internal memory by so much that it cannot allocate that?

nopnop2002
Posts: 111
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: WIFI driver initialization failed due to lack of RAM

Postby nopnop2002 » Wed Oct 02, 2024 8:36 am

>Has anyone ever run a project with WIFI using all or part of the PSRAM? I'm on ESP-IDF version 5.3.1.

Yes, this works fine.
WiFi connection works even without a USB camera.

https://github.com/nopnop2002/esp-idf-video-streaming

Code: Select all

I (27) boot: ESP-IDF v5.3.1 2nd stage bootloader
I (27) boot: compile time Oct  2 2024 17:38:51
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (57) boot: ## Label            Usage          Type ST Offset   Length
I (64) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c0b0020 size=28658h (165464) map
I (129) esp_image: segment 1: paddr=00038680 vaddr=3fc9b500 size=04fech ( 20460) load
I (133) esp_image: segment 2: paddr=0003d674 vaddr=40374000 size=029a4h ( 10660) load
I (137) esp_image: segment 3: paddr=00040020 vaddr=42000020 size=a11c0h (659904) map
I (262) esp_image: segment 4: paddr=000e11e8 vaddr=403769a4 size=14a98h ( 84632) load
I (290) boot: Loaded app from partition at offset 0x10000
I (290) boot: Disabling RNG early entropy source...
I (302) esp_psram: Found 2MB PSRAM device
I (302) esp_psram: Speed: 80MHz
I (302) cpu_start: Multicore app
I (533) esp_psram: SPI SRAM memory test OK
I (542) cpu_start: Pro cpu start user code
I (542) cpu_start: cpu freq: 240000000 Hz
I (542) app_init: Application information:
I (545) app_init: Project name:     video-streaming
I (550) app_init: App version:      613ca49-dirty
I (556) app_init: Compile time:     Oct  2 2024 17:38:43
I (562) app_init: ELF file SHA256:  f53d34af1...
I (567) app_init: ESP-IDF:          v5.3.1
I (572) efuse_init: Min chip rev:     v0.0
I (577) efuse_init: Max chip rev:     v0.99
I (582) efuse_init: Chip rev:         v0.2
I (587) heap_init: Initializing. RAM available for dynamic allocation:
I (594) heap_init: At 3FCA6818 len 00042EF8 (267 KiB): RAM
I (600) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (606) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (612) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM
I (619) esp_psram: Adding pool of 2048K of PSRAM memory to heap allocator
I (627) spi_flash: detected chip: generic
I (630) spi_flash: flash io: dio
W (634) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (648) sleep: Configure to isolate all GPIO pins in sleep state
I (654) sleep: Enable automatic switching of GPIO sleep configuration
I (662) main_task: Started on CPU0
I (672) esp_psram: Reserving pool of 146K of internal memory for DMA/internal allocations
I (672) main_task: Calling app_main()
I (692) pp: pp rom version: e7ae62f
I (692) net80211: net80211 rom version: e7ae62
I (702) wifi:wifi driver task: 3fcd5114, prio:23, stack:6656, core=0
I (702) wifi:wifi firmware version: ccaebfa
I (702) wifi:wifi certification version: v7.0
I (702) wifi:config NVS flash: enabled
I (712) wifi:config nano formating: disabled
I (712) wifi:Init data frame dynamic rx buffer num: 8
I (722) wifi:Init static rx mgmt buffer num: 5
I (722) wifi:Init management short buffer num: 32
I (732) wifi:Init static tx buffer num: 8
I (732) wifi:Init tx cache buffer num: 16
I (732) wifi:Init static tx FG buffer num: 2
I (742) wifi:Init static rx buffer size: 1600
I (742) wifi:Init static rx buffer num: 8
I (742) wifi:Init dynamic rx buffer num: 8
I (752) wifi_init: rx ba win: 8
I (752) wifi_init: accept mbox: 6
I (762) wifi_init: tcpip mbox: 32
I (762) wifi_init: udp mbox: 6
I (762) wifi_init: tcp mbox: 6
I (772) wifi_init: tcp tx win: 15000
I (772) wifi_init: tcp rx win: 5760
I (782) wifi_init: tcp mss: 1440
I (782) wifi_init: WiFi/LWIP prefer SPIRAM
I (792) wifi_init: WiFi IRAM OP enabled
I (792) wifi_init: WiFi RX IRAM OP enabled
I (802) phy_init: phy_version 680,a6008b2,Jun  4 2024,16:41:10
I (832) wifi:mode : sta (48:27:e2:d2:44:38)
I (842) wifi:enable tsf
I (842) example: wifi_init_sta finished.
I (852) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1, snd_ch_cfg:0x0
I (852) wifi:state: init -> auth (0xb0)
I (852) wifi:state: auth -> assoc (0x0)
I (872) wifi:Association refused temporarily time 1024, comeback time 1124 (TUs)
I (2022) wifi:state: assoc -> assoc (0x0)
I (3022) wifi:state: assoc -> init (0x200)
I (3032) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1, snd_ch_cfg:0x0
I (3032) example: retry to connect to the AP
I (3032) example: connect to the AP fail
I (5442) example: retry to connect to the AP
I (5442) example: connect to the AP fail
I (5452) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1, snd_ch_cfg:0x0
I (5452) wifi:state: init -> auth (0xb0)
I (5462) wifi:state: auth -> assoc (0x0)
I (5482) wifi:state: assoc -> run (0x10)
I (5592) wifi:connected with aterm-d5a4ee-g, aid = 9, channel 1, BW20, bssid = f8:b7:97:36:de:52
I (5592) wifi:security: WPA2-PSK, phy: bgn, rssi: -43
I (5602) wifi:pm start, type: 1

I (5602) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (5612) wifi:set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 25000, mt_pti: 0, mt_time: 10000
I (5632) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (6612) esp_netif_handlers: sta ip: 192.168.10.124, mask: 255.255.255.0, gw: 192.168.10.1
I (6612) example: got ip:192.168.10.124

Laurent
Posts: 2
Joined: Fri Apr 19, 2024 7:02 am

Re: WIFI driver initialization failed due to lack of RAM

Postby Laurent » Wed Oct 02, 2024 3:27 pm

Thank you nopnop2002, your project confirms that it can work.

I think ESP_Sprite is right, WIFI needs a minimum amount of internal RAM, whatever the allocation strategy chosen.

I therefore need to monitor the consumption of internal RAM during the initialization of the various modules when my software is launched. I'm not very familiar with the Espressif Framework. Are there any primitives that can be used to monitor the different sections of internal RAM?

I've already tried the esp_get_free_heap_size() function, but that's not enough, it doesn't monitor the sections reserved for running the drivers.

nopnop2002
Posts: 111
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: WIFI driver initialization failed due to lack of RAM

Postby nopnop2002 » Tue Oct 15, 2024 8:53 pm

>Are there any primitives that can be used to monitor the different sections of internal RAM?

You can check your project's memory usage with idf.py size.
You might get some hints.
Click here for details.
https://docs.espressif.com/projects/esp ... -size.html

Who is online

Users browsing this forum: No registered users and 57 guests