ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

arturv
Posts: 2
Joined: Sat Apr 22, 2017 6:23 pm

ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Postby arturv » Sat Jun 07, 2025 11:54 am

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

Sprite
Espressif staff
Espressif staff
Posts: 10650
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Postby Sprite » Sun Jun 08, 2025 8:44 am

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.

arturv
Posts: 2
Joined: Sat Apr 22, 2017 6:23 pm

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Postby arturv » Mon Jun 09, 2025 11:31 am

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

MicroController
Posts: 2705
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Postby MicroController » Tue Jun 10, 2025 1:58 pm

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.)

shb3014
Posts: 1
Joined: Tue Mar 08, 2022 1:34 am

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Postby shb3014 » Fri Aug 01, 2025 9:17 am

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.

eriksl
Posts: 239
Joined: Thu Dec 14, 2023 3:23 pm
Location: Netherlands

Re: ESP32S3: SPIDriver, DMA and Buffer in SPIRAM

Postby eriksl » Sun Aug 02, 2026 10:53 am

Any news here?

Who is online

Users browsing this forum: trendictionbot and 1 guest