Page 1 of 1

ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Posted: Sat Jun 07, 2025 11:54 am
by arturv
Hi

Is there any limitation (chip side) that the SPI Driver using DMA cannot use TX buffers in SPIRAM memory?

From what I understand in the datasheet/reference manual, the GDMA module should be able to access internal RAM and external RAM, the SPI section doesn't seem to mention any limitation on this regard, but the ESP-IDF (v5.4.1) SPI driver implementation limits that the Buffer in case of DMA must be in internal RAM (inside SPI Driver)

Code: Select all

if (send_ptr && bus_attr->dma_enabled) {
        if ((!esp_ptr_dma_capable(send_ptr) || tx_unaligned)) {
And the function "esp_ptr_dma_capable" is only checking that the buffer must be in internal RAM, and if the buffer is in external RAM will attempt to allocate a buffer from internal memory.

Is this limitation from the chip itself, or is it a limitation of ESP-IDF on not supporting this correctly?


Thank You

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Posted: Sun Jun 08, 2025 8:44 am
by Sprite
Good point. Might be something we overlooked because it looked like it did the right job to begin with or maybe it's a conscious choice because PSRAM might 'go away' when flash writes are done. I'll make an internal issue about this.

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Posted: Mon Jun 09, 2025 11:31 am
by arturv
Thanks for the feedback.

If possible after the internal discussion, post some follow-up, or maybe put a note in the SPI driver documentation regarding this.

Thank You

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Posted: Tue Jun 10, 2025 1:58 pm
by MicroController
Although he hardware can do PSRAM<->peripheral DMA, I think I saw stated somewhere that the IDF explicitly does not support this. (Might have been in some comment in IDF code.)

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Posted: Fri Aug 01, 2025 9:17 am
by shb3014
I modify the code to add esp_ptr_dma_ext_capable in the condition so memcpy is skipped with psram tx_buffer. As long as the buffer is uint32_t aligned, i can see image pushed to the screen, but it seems that spi_device_get_trans_result is not properly working and there are glitches on the screen.

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Posted: Sun Aug 02, 2026 10:53 am
by eriksl
Any news here?