Page 1 of 1
[resolved] running out of memory AGAIN
Posted: Wed Jun 03, 2020 11:04 pm
by mzimmers
Hi all -
I know we've been around this tree before, but I need a refresher.
Added a little code to my app, and am now getting this on startup:
Code: Select all
I (6861) wifi:wifi firmware version: aa5336b
I (6861) wifi:config NVS flash: enabled
I (6861) wifi:config nano formating: disabled
I (6861) wifi:Init dynamic tx buffer num: 32
I (6861) wifi:Init data frame dynamic rx buffer num: 16
I (6871) wifi:Init management frame dynamic rx buffer num: 16
I (6871) wifi:Init management short buffer num: 32
I (6881) wifi:Init static tx buffer num: 16
I (6891) wifi:Init static rx buffer size: 1600
W (6891) wifi:malloc buffer fail
I (6891) wifi:Init static rx buffer num: 6
I (6891) wifi:Init dynamic rx buffer num: 16
E (6901) wifi:Expected to init 10 rx buffer, actual is 6
I (6901) wifi:Deinit lldesc rx mblock:0
I (6911) wifi:Deinit lldesc rx mblock:0
I (6911) wifi:Deinit lldesc rx mblock:0
I (6911) wifi:Deinit lldesc rx mblock:0
E (6931) Wifi: taskInit(): esp_wifi_init() returned 0x101; halting task.
The last message is from my app, and of course 0x101 is the dreaded out of memory code.
I was thinking: could I change the number of dynamic tx buffers to 16? I can't find the correct line for this in my sdkconfig file, but I imagine it's in there somewhere.
Any other ideas are MOST recommended...PLEASE help!
Thanks...
Re: running out of memory AGAIN
Posted: Thu Jun 04, 2020 12:08 am
by mzimmers
Just before the call to esp_wifi_init():
I (5075) memreport: memReport(): there are 68424 MALLOC_CAP_8BIT | MALLOC_CAP_DMA bytes free.
I (5085) memreport: memReport(): there are 4136080 MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM bytes free.
I (5095) memreport: memReport(): there are 64052 MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL bytes free.
Re: running out of memory AGAIN
Posted: Thu Jun 04, 2020 6:50 am
by chegewara
Code: Select all
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM
CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM
Re: running out of memory AGAIN
Posted: Thu Jun 04, 2020 1:18 pm
by mzimmers
Hi Chegewara - not sure what you're saying. Are you recommending I lower the values on the items you listed?
Re: running out of memory AGAIN
Posted: Thu Jun 04, 2020 4:42 pm
by chegewara
I can't find the correct line for this in my sdkconfig file
And yes, you could start to decrease amount of wifi buffers, especially static buffers, because each one takes 1600 bytes. When you are short on memory then dynamic buffers also can cause you troubles because can depleted all left memory.
Of course decreasing buffers count will lead to make worse wifi performance.
Re: running out of memory AGAIN
Posted: Thu Jun 04, 2020 4:46 pm
by mzimmers
So where is the setting for the dynamic TX buffer count?
Re: running out of memory AGAIN
Posted: Thu Jun 04, 2020 7:23 pm
by chegewara
I posted only 3, because i couldnt find dynamic TX in menuconfig. Kconfig bug or is removed in most recent master branch.
Re: running out of memory AGAIN
Posted: Fri Jun 05, 2020 12:40 am
by mzimmers
I went into menuconfig and reduced the three parameters Chegewara cited above. Attempted to build:
Code: Select all
C:\wifibutton\firmware>idf.py build
Checking Python dependencies...
Python requirements from C:\esp-idf\requirements.txt are satisfied.
Executing action: all (aliases: build)
Running ninja in directory c:\wifibutton\firmware\build
Executing "ninja all"...
[0/1] Re-running CMake...
-- mconf-idf version mconf-v4.6.0.0-idf-20190628-win32
-- ccache will be used for faster recompilation
-- Project version: wifibutton_v1.0.0b01-19-g996b37e-dirty
-- Building ESP-IDF components for target esp32
Traceback (most recent call last):
File "C:/esp-idf/tools/kconfig_new/confgen.py", line 573, in <module>
main()
File "C:/esp-idf/tools/kconfig_new/confgen.py", line 283, in main
update_if_changed(temp_file, filename)
File "C:/esp-idf/tools/kconfig_new/confgen.py", line 550, in update_if_changed
with open(destination, "w") as f:
OSError: [Errno 22] Invalid argument: 'C:/wifibutton/firmware/build/config/sdkconfig.h'
CMake Error at C:/esp-idf/tools/cmake/kconfig.cmake:208 (message):
Failed to run confgen.py
(C:\esp32-toolchain\python_env\idf4.0_py3.7_env\Scripts\python.exe;C:/esp-idf/tools/kconfig_new/confgen.py;--kconfig;C:/esp-idf/Kconfig;--sdkconfig-rename;C:/esp-idf/sdkconfig.rename;--config;C:/wifibutton/firmware/sdkconfig;--env-file;C:/wifibutton/firmware/build/config.env).
Error 1
Call Stack (most recent call first):
C:/esp-idf/tools/cmake/build.cmake:441 (__kconfig_generate_config)
C:/esp-idf/tools/cmake/project.cmake:348 (idf_build_process)
CMakeLists.txt:6 (project)
-- Configuring incomplete, errors occurred!
See also "C:/wifibutton/firmware/build/CMakeFiles/CMakeOutput.log".
FAILED: build.ninja
C:\esp32-toolchain\tools\cmake\3.13.4\bin\cmake.exe -SC:\wifibutton\firmware -BC:\wifibutton\firmware\build
ninja: error: rebuilding 'build.ninja': subcommand failed
ninja failed with exit code 1
C:\wifibutton\firmware>idf.py menuconfig
Checking Python dependencies...
Python requirements from C:\esp-idf\requirements.txt are satisfied.
Executing action: menuconfig
Running ninja in directory c:\wifibutton\firmware\build
Executing "ninja menuconfig"...
[0/1] Re-running CMake...
-- mconf-idf version mconf-v4.6.0.0-idf-20190628-win32
-- ccache will be used for faster recompilation
-- Project version: wifibutton_v1.0.0b01-19-g996b37e-dirty
-- Building ESP-IDF components for target esp32
Traceback (most recent call last):
File "C:/esp-idf/tools/kconfig_new/confgen.py", line 573, in <module>
main()
File "C:/esp-idf/tools/kconfig_new/confgen.py", line 283, in main
update_if_changed(temp_file, filename)
File "C:/esp-idf/tools/kconfig_new/confgen.py", line 550, in update_if_changed
with open(destination, "w") as f:
OSError: [Errno 22] Invalid argument: 'C:/wifibutton/firmware/build/config/sdkconfig.h'
CMake Error at C:/esp-idf/tools/cmake/kconfig.cmake:208 (message):
Failed to run confgen.py
(C:\esp32-toolchain\python_env\idf4.0_py3.7_env\Scripts\python.exe;C:/esp-idf/tools/kconfig_new/confgen.py;--kconfig;C:/esp-idf/Kconfig;--sdkconfig-rename;C:/esp-idf/sdkconfig.rename;--config;C:/wifibutton/firmware/sdkconfig;--env-file;C:/wifibutton/firmware/build/config.env).
Error 1
Call Stack (most recent call first):
C:/esp-idf/tools/cmake/build.cmake:441 (__kconfig_generate_config)
C:/esp-idf/tools/cmake/project.cmake:348 (idf_build_process)
CMakeLists.txt:6 (project)
-- Configuring incomplete, errors occurred!
See also "C:/wifibutton/firmware/build/CMakeFiles/CMakeOutput.log".
FAILED: build.ninja
C:\esp32-toolchain\tools\cmake\3.13.4\bin\cmake.exe -SC:\wifibutton\firmware -BC:\wifibutton\firmware\build
ninja: error: rebuilding 'build.ninja': subcommand failed
ninja failed with exit code 1
This is a separate issue, but I imagine that I should report it somewhere.
Re: running out of memory AGAIN
Posted: Thu Jun 11, 2020 3:21 pm
by mzimmers
Just to bring this to closure: the build problem I cited above was due to my allowing my sdkconfig file to get out of sync with the version of the IDF (v4.0.1) that I wanted to use. I've converted to using sdkconfig.defaults, and now things are working.
I freed up some space by reducing the stack sizes on some of my tasks. I put memory reports before and after my call to esp_wifi_init(), and found that it consumed ~70KB of 8-bit, SPI RAM. This seems like a *very* big number, but I suppose it is what it is.
Thanks to all who looked at this.