-
Notifications
You must be signed in to change notification settings - Fork 262
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
esp-wifi: Custom allocation functions only works with global allocator. #3187
Comments
Thanks Currently all allocations made by drivers itself are done in internal memory. We can relax that since the drivers use different functions for internal-only memory and memory which is allowed to live in external RAM. The reason we don't just use the global allocator is that the APIs don't allow us to specify "memory properties". In the future we might change the mechanism to use a non-global Allocator for that (#2192) I see how it would be useful to have |
In my case I wanted to isolate the wifi-stacks memory pool in order to get the system deterministic (my application should have a "static" (guess true static allocation is impossible for idf-based things like the wifi stack) core and dynamic applications, mostly placed on the remaining ram / psram. I actually just used two instances of esp alloc for that. The API didn't look like there was that difference between internal/external (altough I am not sure if this is scoped to the wifi stack or used by any c code calling malloc), so if thats not an easy thing to split this might be solved using a small comment in the documentation. But in the end, I can work around this. Guess the true Rust-based approach would be to make this allocator aware (using the experimental allocator_api). |
I agree - the documentation there is lacking
That would be the goal - but we don't want to force users into nightly so the current situation is a workaround until that is available |
Yeah, that is understandable. Thanks for the quick reply. |
Bug description
While the API (
esp_wifi_free_internal_heap
andesp_wifi_allocate_from_internal_ram
) seem like the allocations are permanent (I assumed this was using some sort of arena internally), esp-wifi still calls alloc::alloc::dealloc on the regions it got from that pool (https://github.com/esp-rs/esp-hal/blob/main/esp-wifi/src/compat/malloc.rs#L36). If this region is not the global allocator, this will ultimately lead to the wifi stack running out of memory.I guess this could be fixed by also adding an
esp_wifi_free_from_internal_ram
function.Environment
Should be a general problem and exists on the current main.
Was tested on an ESP32S3.
The text was updated successfully, but these errors were encountered: