Skip to content

Commit

Permalink
esp32/main: Automatically size SPIRAM heap when allocated using malloc.
Browse files Browse the repository at this point in the history
This change allows the same heap allocation rules to be used when using
malloc regardless if the board has SPRAM or normal RAM.

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 it's 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.
  • Loading branch information
Michael O'Cleirigh authored and dpgeorge committed Feb 2, 2022
1 parent 1f04a9a commit eae2e35
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ports/esp32/main.c
Expand Up @@ -100,7 +100,10 @@ void mp_task(void *pvParameter) {
size_t mp_task_heap_size;
void *mp_task_heap = NULL;

#if CONFIG_ESP32_SPIRAM_SUPPORT
#if CONFIG_SPIRAM_USE_MALLOC
// SPIRAM is issued using MALLOC, fallback to normal allocation rules
mp_task_heap = NULL;
#elif CONFIG_ESP32_SPIRAM_SUPPORT
// Try to use the entire external SPIRAM directly for the heap
mp_task_heap = (void *)SOC_EXTRAM_DATA_LOW;
switch (esp_spiram_get_chip_size()) {
Expand Down

0 comments on commit eae2e35

Please sign in to comment.