-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WiFi memory usage much higher when SPIRAM is enabled - ESP32S2 (IDFGH-5446) #7186
Comments
This is probably due to the fact that a few Wi-Fi library configuration options have different default values depending on whether PSRAM is enabled or not. esp-idf/components/esp_wifi/Kconfig Lines 152 to 157 in 1d7068e
You can try adding CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=n to sdkconfig.defaults of your project, then regenerate sdkconfig (rm sdkconfig; idf.py reconfigure ). This should take these options back to their non-PSRAM default values, resulting likely in slightly reduced Wi-Fi performance.
Edit: corrected the Kconfig option name |
Thanks, that makes sense. I have tested this and it still uses a lot of memory compared to when Can you please give me a reference of documentation page where I can read what I can configure to improve the memory usage? Before enabling SPIRAM:
After enabling SPIRAM:
|
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/performance/index.html Can you check 1 thing please? |
@chegewara, Thank you for the link. |
with |
@DCSBL With regards to the logs you posted in #7186 (comment), could you please attach sdkconfig files for both of the cases? |
@chegewara @igrr Here you go: sdkconfig when `ESP32S2_SPIRAM_SUPPORT` is set
sdkconfig when `ESP32S2_SPIRAM_SUPPORT` is not set
I think the most importent question for me is: 'Why is SPIRAM enabled?`. I can't find an external RAM chip on the DevKit. But for having this answered I think I am at the wrong place. |
It should be under the metal lid of the ESP32S2-WROVER module. Doing a diff of these two sdkconfig files, the only seemingly relevant setting is One more thing, could you please explain how these 2 lines are printed/calculated?
The numbers after |
🤦 I thought that there was only a flash chip underneath it, but yeah, you are right. I've found the external RAM. I will look into it to somehow make use of the external RAM.
Memory usage is lowered when setting
These lines after '***' were added by me manually. Sorry for the confusion. |
Looks like setting it to 0 will lower it by 54 kB compared to its default setting 32 (when PSRAM is enabled), which is almost exactly the difference you are observing between PSRAM- and non-PSRAM builds (110-55=55kB). Which seems to explain where the memory is lost when enabling PSRAM! Edit: I just looked at the definition of this Kconfig option and I see now that the minimum allowed value is 16. If you think this is excessive I can invite someone from our Wi-Fi team into this issue. They can comment whether the minimum value could be reduced, or on the reason why this is shouldn't be done. |
Seems great to bring in the some expertise 🙂! For the project I work on every KB that can be freed because some setting is 'wrong' is worth it. Maybe it is worth it to see if the value can be lowered without introducing (stability) problems. |
hi @DCSBL sorry for reply late. |
@MaxwellAlan are there any suggestions for the following ?
WIFI_DYNAMIC_RX_BUFFER_NUM differ significantly across different IDF versions. How are TCP_SND_BUF_DEFAULT and TCP_WND_DEFAULT calculated, as they have a dependency on the MSS size. |
Hi, Thanks for the information. I was able to increase memory while still having a stable connection. IMO this issue can be closed. |
hi @AshUK
|
Thanks for reporting and sharing the updates, feel free to reopen. |
Environment
Problem Description
When enabling
Component config > ESP32S2-specific > Support for external, SPI-connected RAM
in menuconfig (ESP32S2_SPIRAM_SUPPORT
), the memory usage from WiFi increases a huge amount. (from 54KB assigned heap to 110KB)I have no idea if this option needs to be enabled for my project, but in the example project it is enabled by default. I want to know if it is a bug or that this behaviour is intended.
Context
I try to enable WiFi and LVGL (the graphics library) on the HMI DevKit, but It ran out of memory. LVGL takes a lot of memory for the display buffer, but it seemed that WiFi also took a lot of memory for its own (about 110KB). After a bit of digging I've tried the WiFi Station example to remove any overhead from LVGL.
I have used this example to initialise WiFi on the HMI DevKit. I came to the conclusion that the only real difference is the
ESP32S2_SPIRAM_SUPPORT
option. When I turn this off it the memory usage is reduced to 54KB.The moment that the memory is assigned seems to be in the
esp_wifi_init_internal
method, but that code is 'private' or precompiled. So I cannot look further.esp-idf/components/esp_wifi/include/esp_private/wifi.h
Line 104 in 7ab8f79
Expected Behaviour
The memory usage should not change (that drastically).
Actual Behaviour
Initialising WiFi consumes much more memory when
ESP32S2_SPIRAM_SUPPORT
is set.Steps to reproduce
ESP32S2_SPIRAM_SUPPORT
and run example, log result seen below:The text was updated successfully, but these errors were encountered: