Content-Length: 224700 | pFad | https://github.com/adafruit/circuitpython/issues/10125

32 Implement DMA-capable Memory Allocation for RP2350 · Issue #10125 · adafruit/circuitpython · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DMA-capable Memory Allocation for RP2350 #10125

Open
eightycc opened this issue Mar 10, 2025 · 2 comments
Open

Implement DMA-capable Memory Allocation for RP2350 #10125

eightycc opened this issue Mar 10, 2025 · 2 comments

Comments

@eightycc
Copy link
Collaborator

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 that tlsf 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 the tlsf heap ages, it becomes unpredictable from which pool allocations will come.

The dma_capable argument of port_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 of port_malloc and allocate all DMA buffers from the main tlsf heap rather than the VM heap.

A workaround may be to allocate all DMA buffers early in the life of the system.

@tannewt
Copy link
Member

tannewt commented Mar 11, 2025

I think we'll need to improve common-hal memory use for this too then. I think we assume that VM allocated memory can be DMA'd.

@jepler
Copy link

jepler commented Mar 11, 2025

I think the low level Espressif APIs mostly bounce everything through SRAM that might be DMA'd, so it hasn't caused problems that e.g., a bytes argument to be sent out SPI is in PSRAM...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/adafruit/circuitpython/issues/10125

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy