Implement DMA-capable Memory Allocation for RP2350 #10125
Labels
Milestone
Content-Length: 224700 | pFad | https://github.com/adafruit/circuitpython/issues/10125
32Fetched URL: https://github.com/adafruit/circuitpython/issues/10125
Alternative Proxies:
For RP2350 boards with PSRAM, buffers for use with DMA may be unpredictably allocated in PSRAM. When DMA attempts to access a buffer in PSRAM, a bus fault occurs. This will manifest as a
CircuitPython core code crash
.In the present implementation, SRAM and PSRAM are added to the main
tlsf
heap as separate pools.tlsf
does not differentiate between these pools. It happens thattlsf
will allocate memory from the SRAM pool first because it was added first. Once SRAM is filled, allocations will come from the PSRAM pool. As thetlsf
heap ages, it becomes unpredictable from which pool allocations will come.The
dma_capable
argument ofport_malloc()
is ignored by its RP2 port specialization. Likewise,tlsf
does not provide a means of specifying which pool, SRAM or PSRAM, to use for an allocation.Similarly, it is not predictable whether a VM heap space allocation is in SRAM or PSRAM. There is no means of requesting a VM heap space allocation in SRAM.
An example solution is to implement the
dma_capable
argument ofport_malloc
and allocate all DMA buffers from the maintlsf
heap rather than the VM heap.A workaround may be to allocate all DMA buffers early in the life of the system.
The text was updated successfully, but these errors were encountered: