-
Notifications
You must be signed in to change notification settings - Fork 134
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
Remove SPI RAM requirement #8
base: main
Are you sure you want to change the base?
Conversation
How much internal RAM does the M5Stack board have? I was unable to get the Sonatino to even connect when using only internal RAM. |
CoreS3 SE also uses ESP32-S3, so it have the same internal RAM size of Sonatino. Do you mean that the modification in this PR did not work for Sonatino? |
src/webrtc.cpp
Outdated
#else // CONFIG_SPIRAM | ||
constexpr size_t stack_size = 20000; | ||
StackType_t *stack_memory = (StackType_t *)malloc(stack_size * sizeof(StackType_t)); | ||
#endif // CONFIG_SPIRAM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few notes about this code from a passer-by:
CONFIG_SPIRAM=y
is not a sufficient condition to be sure that we can allocate from SPIRAM. CONFIG_SPIRAM_IGNORE_NOTFOUND
might be set, in which case the application will boot up and ignore the lack of SPI RAM. SPIRAM_USE_MEMMAP
might also be set, in which case SPIRAM will initialized but won't be available for malloc
or heap_caps_malloc
.
We can use heap_caps_malloc_prefer
, instead, and ask it to use SPIRAM and fall back to the internal RAM otherwise:
constexpr size_t stack_size = 20000;
StackType_t *stack_memory = (StackType_t *)heap_caps_malloc_prefer(
20000 * sizeof(StackType_t), 2, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
(we also don't need preprocessor conditions this way)
Another option is to use regular malloc
and adjust CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL
to a smaller value, so that large allocations get placed into SPIRAM automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to use heap_caps_malloc_prefer
and removed CONFIG_SPIRAM
ifdef block.
3e919b5
Rebased to upstream/main |
This PR adjusts the memory usage of the code and remove the requirement of SPI RAM.
Reduce the main task stack size from 16384 to 10240.
Configure ESP-IDF Wi-Fi driver to allocate TX buffer dynamically.
Disable the SPI RAM by default.
Fix that stack buffer allocation fails and launching audio_publisher fails silently when SPI RAM is disabled.
I have checked with M5Stack CoreS3 SE with some modification for porting.
But I cannot check this code with Freenove ESP32-S3-WROOM and Sonatino, because I do not have them.
So please check this code with these boards if this code seems well.