DMA Memory vs. Sockets

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
jdts
Posts: 36
Joined: Mon Dec 23, 2019 2:55 pm

DMA Memory vs. Sockets

Post by jdts » Sat Oct 16, 2021 11:19 pm

When something in MP allocates DMA-able memory on ESP32 (e.g. this micropython-hybrid display driver from Russ Hughes), this leads to instability in large socket reads/writes. I noticed this using Robert-hh's uftpd. When using uftpd with a DMA-backed SPI driven display active, it can't perform large transfers reliably. But the display is not the issue. I narrowed it down to the DMA memory allocation the display driver uses.

If any reasonable amount of DMA-able memory is allocated, e.g. 16KB or so:

Code: Select all

import espidf as esp
buf = esp.heap_caps_malloc(2*240*135//4, esp.MALLOC_CAP.DMA)
then repeated calls to socket.write eventually hang, producing ECONNABORTED and ENOTCONN errors. Small transfers still work fine, and allocating a small amount of DMA RAM (perhaps 5-10KB or so) doesn't trigger this.

What could be causing this? Do socket read/writes allocate DMA RAM dynamically?

Post Reply