esp32/main: Support SPRAM allocated using malloc #8219
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Integrating with the esp32-camera for example requires that ESP32 SPRAM be allocatable using the esp-idf
capabilities aware allocation functions. In the case of esp32-camera its for the framebuffer.
Detect when CONFIG_SPIRAM_USE_MALLOC is in use and use the standard automatic configuration of leaving 1/2
of the SPRAM available to other FreeRTOS tasks.
My original thought was to allow the board config to control how much the micropython heap was reduced but I've read some of the other related issues and pull requests and it seems that an algorithm/heuristic is the preferred approach.
Here I just add a new no-op block that will in the case the esp32 is configured to allocate psram using malloc to skip past the normal MMAP allocation strategy and use the non-psram allocation strategy.
I've used this patch locally to build a firmware for esp32-cam-mb and m5-timer-camera:
https://github.com/mocleiri/tensorflow-micropython-examples/tree/feature/59-integrate-esp32-camera-acquisition
mocleiri/tensorflow-micropython-examples#59
--
This patch adds this case into the logic added here: 23b1a4e for non spram heap sizing.
Related:
#7214 (except that our case is when the other idf modules in use need to use the idf capabilities allocation functions where malloc can allocate them parts of psram)