-
Notifications
You must be signed in to change notification settings - Fork 7.6k
BLE+WiFi+heap_caps_malloc_extmem_enable
crash.
#6666
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
Comments
I've tested it with ESP32-WROVER-E Module. Investigation indicates that the issue is related to PSRAM being activated in the Arduino Core. Using an ESP32-WROVER-E board, when the board selected in Arduino IDE is ESP32 Wrover Module, the issue happens. It seems initially related to Dynamic/Static memory allocation within WiFi and how Arduino has set it up. Investigation will continue. |
Testing the sketch with different Arduino Core versions:
It seems that this issue has been there since the change from IDF 3.3 to IDF 4.4. Failure Messages:
Decoding stack:
|
Why do you need this? // Comment this line and the crash does not happen.
heap_caps_malloc_extmem_enable(0); Default value is 4096 and that is the smallest memory block size of PSRAM that can be allocated from PSRAM. |
So far I see no issue... it sounds like bad usage. |
This does indeed seem to have stopped the crash. But I am seeing:
Please can you point me to where this default of 4096 can be found? Every example I can find - granted there aren't many - for using I will do more testing ASAP my side. The bug above is showing up in my main application I will need to see if I can replicate it in the test code. |
Arduino sets it here: CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL is defined for each SoC by IDF. Thus, its default value is 4096. |
Is the correct usage then to just set And to not call heap_caps_malloc_extmem_enable() at all? |
I think so.... can't tell for sure for your application case. I'm pretty sure that setting |
@SuGlider thank you for that insight. I'm still doing some more testing on my side. Setting:
Or not setting those and calling: heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL); Works fine on the test code I provided above but in my actual project I get:
However, everything seems to work if I reduce this down to say: heap_caps_malloc_extmem_enable(64); I am going to do some more stability testing on this but I would appreciate your thoughts on using 64 instead of 4096. |
64 is a lot better than Zero ;-) I think that 64 bytes may cover a big part of The exception in the original code, apparently, has to do with part of memory that are not accessible from the Arduino Core - which indicates that critical data structures were in PSRAM instead of HEAP because of |
If this is a more professional application, I would go with the 4096, to play safe. |
It is a more professional application. But WiFi won't start with 4096. I think 4096 just puts too much stuff on the HEAP and there isn't enough place to start the WiFi up. It is looking very stable so far at 64. We will have to go with long term stability testing for now. I am going to close the issue at this point. Thanks for all your help. |
Board
ESP32 Dev Module
Device Description
Chip is ESP32-D0WD-V3 (revision 3); Auto-detected Flash size: 16MB
Hardware Configuration
None
Version
other
IDE Name
CLion with PIO
Operating System
Windows 10
Flash frequency
80 MHz
PSRAM enabled
yes
Upload speed
921600
Description
Using
BLE
+WiFi
+heap_caps_malloc_extmem_enable(0)
causes a spontaneous crash when the AP is not found and also at other random times. The AP not found case is most easily replicated.PIO version:
Sketch
Other Steps to Reproduce
Please note the comments in the code.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: