HAL_ChibiOS: adjust dma reserve allocation

use larger target and allow for smaller allocation
This commit is contained in:
Andrew Tridgell 2020-01-17 15:58:07 +11:00
parent 64dc29cf98
commit c5b1c88948
1 changed files with 10 additions and 4 deletions

View File

@ -59,7 +59,7 @@ static memory_heap_t heaps[NUM_MEMORY_REGIONS];
// size of memory reserved for dma-capable alloc // size of memory reserved for dma-capable alloc
#ifndef DMA_RESERVE_SIZE #ifndef DMA_RESERVE_SIZE
#define DMA_RESERVE_SIZE 4096 #define DMA_RESERVE_SIZE 6144
#endif #endif
#if DMA_RESERVE_SIZE != 0 #if DMA_RESERVE_SIZE != 0
@ -81,9 +81,15 @@ void malloc_init(void)
create a DMA reserve heap, to ensure we keep some memory for DMA create a DMA reserve heap, to ensure we keep some memory for DMA
safe memory allocations safe memory allocations
*/ */
void *dma_reserve = malloc_dma(DMA_RESERVE_SIZE); uint32_t reserve_size = DMA_RESERVE_SIZE;
osalDbgAssert(dma_reserve != NULL, "DMA reserve"); while (reserve_size > 0) {
chHeapObjectInit(&dma_reserve_heap, dma_reserve, DMA_RESERVE_SIZE); void *dma_reserve = malloc_dma(reserve_size);
if (dma_reserve != NULL) {
chHeapObjectInit(&dma_reserve_heap, dma_reserve, reserve_size);
break;
}
reserve_size = (reserve_size * 7) / 8;
}
#endif #endif
} }