mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-14 10:04:35 +02:00
Merge branch 'bugfix/reserve_dma_ram_in_segments' into 'master'
psram: reserve dma pool in the step of heap max block Closes IDF-4936 See merge request espressif/esp-idf!18740
This commit is contained in:
@@ -248,8 +248,12 @@ esp_err_t esp_psram_extram_get_alloced_range(intptr_t *out_vstart, intptr_t *out
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
esp_err_t esp_psram_extram_reserve_dma_pool(size_t size)
|
||||||
esp_err_t esp_psram_extram_reserve_dma_pool(size_t size) {
|
{
|
||||||
|
if (size == 0) {
|
||||||
|
return ESP_OK; //no-op
|
||||||
|
}
|
||||||
|
|
||||||
ESP_EARLY_LOGI(TAG, "Reserving pool of %dK of internal memory for DMA/internal allocations", size / 1024);
|
ESP_EARLY_LOGI(TAG, "Reserving pool of %dK of internal memory for DMA/internal allocations", size / 1024);
|
||||||
/* Pool may be allocated in multiple non-contiguous chunks, depending on available RAM */
|
/* Pool may be allocated in multiple non-contiguous chunks, depending on available RAM */
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
@@ -271,21 +275,6 @@ esp_err_t esp_psram_extram_reserve_dma_pool(size_t size) {
|
|||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
esp_err_t esp_psram_extram_reserve_dma_pool(size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0) {
|
|
||||||
return ESP_OK; //no-op
|
|
||||||
}
|
|
||||||
ESP_EARLY_LOGI(TAG, "Reserving pool of %dK of internal memory for DMA/internal allocations", size/1024);
|
|
||||||
uint8_t *dma_heap = heap_caps_malloc(size, MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
|
||||||
if (!dma_heap) {
|
|
||||||
return ESP_ERR_NO_MEM;
|
|
||||||
}
|
|
||||||
uint32_t caps[] = {MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL, 0, MALLOC_CAP_8BIT | MALLOC_CAP_32BIT};
|
|
||||||
return heap_caps_add_region_with_caps(caps, (intptr_t) dma_heap, (intptr_t) dma_heap + size);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool IRAM_ATTR esp_psram_is_initialized(void)
|
bool IRAM_ATTR esp_psram_is_initialized(void)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user