ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Sun May 19, 2024 1:16 am

Hello.

The TRM seems to imply that one can create a buffer in PSRAM memory, and use EDMA to send out via the I2S peripheral (for parallel output LCD mode).

However, any attempts I try produce garbage output when any of the buffer is allocated to the ESP32-S2's PSRAM.

What is this the case? The TRM seems to imply this is possible. However, I have not been able to find any examples.

liaifat85
Posts: 200
Joined: Wed Dec 06, 2023 2:46 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby liaifat85 » Sun May 19, 2024 2:00 pm

You can allocate critical buffers that require high-speed access in internal SRAM instead of PSRAM. You can use PSRAM for less critical data that doesn’t need high-speed access.

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Mon May 20, 2024 10:24 am

I don't want to use the SRAM. I want to use the PSRAM.

The TRM says you can use it for I2S and LCD output, but I there's no guidance anywhere on how to achieve this in code.

ESP_Sprite
Posts: 9307
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby ESP_Sprite » Tue May 21, 2024 1:36 am

It should just work like internal RAM, with the exception that your memory needs to be aligned to the cache line size of the psram cache. Also, you need to make sure data is not stuck in that cache, as the CPU reads/writes from cache while DMA interacts directly with the underlying PSRAM; this means that you'll need to flush the cache for the data memory before starting the DMA transfer. Also note that DMA descriptors can only be in internal RAM.

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Tue May 21, 2024 5:27 am

Thanks ESP_Sprite.

If I used say the esp-camera example (https://github.com/espressif/esp32-camera) and re-write it to be an LCD output instead, do you think that could potentially do the trick? I see a bunch of PSRAM data alignment stuff in this code.

ESP_Sprite
Posts: 9307
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby ESP_Sprite » Tue May 21, 2024 8:54 am

Erm, possibly? It certainly has a lot of the components you'd need.

faptastic
Posts: 15
Joined: Mon Nov 14, 2022 10:38 pm

Re: ESP32-S2 External RAM / PSRAM + I2S LCD + DMA

Postby faptastic » Mon Jun 03, 2024 9:16 pm

I created a working example for 24 bit parallel LCD output on the esp32s2 that uses the internal SRAM for the DMA buffer.

However, if I attempt to use MALLOC_CAP_SPIRAM as the DMA buffer source, it does not matter what settings I try, the device sends garbage out across all the mapped GPIOs that does not resemble the buffer data in any way. No settings seem to change this behaviour.

https://github.com/mrcodetastic/esp32s2 ... /tree/main

@Sprite, any possibility you could eye-ball to see what could be going wrong?

Specifically: https://github.com/mrcodetastic/esp32s2 ... el_dma.cpp

Any help appreciated.

Who is online

Users browsing this forum: No registered users and 151 guests