ESP32-S3 DMA (EDMA) with PSRAM and LCD
Posted: Sat Oct 30, 2021 5:23 pm
Hello,
I am trying to get DMA working with PSRAM on ESP32-S3. From what I gather, it employs EDMA (as does ESP32-S2), which allows direct data transfer between PSRAM and peripherals, e.g. LCD. However, I've been unable to get it working properly. I used code from LVGL example in esp-idf as a base to make a simple program which just fills part of the screen with a solid color (the display I use has an R61529 controller which is not supported by esp-idf). It works just fine if the buffer I use is allocated in internal RAM (a single solid color as expected), but has weird glitchy effects if using PSRAM (random noise). I am sure some data is still sent in the PSRAM case, as the random noise clearly visible.
I've tried to change the data in the framebuffer after each render by memsetting the buffer in the on_color_trans_done callback. In PSRAM case, this just leads to small streaks of appearing in random places on the display (within the rendered area, which is just part of the whole).
Here is how I allocate the framebuffer:
NB: I would assume I'd need to allocate with MALLOC_CAP_DMA even with internal RAM, but somehow everything works even without that.
I get the same issues irregardless of whether I use aligned alloc or not. I checked code for esp32-camera, as it had some mentions of EDMA, and saw that some sort of alignment was done there. Not sure if I am doing it properly, however.
Any ideas?
I am trying to get DMA working with PSRAM on ESP32-S3. From what I gather, it employs EDMA (as does ESP32-S2), which allows direct data transfer between PSRAM and peripherals, e.g. LCD. However, I've been unable to get it working properly. I used code from LVGL example in esp-idf as a base to make a simple program which just fills part of the screen with a solid color (the display I use has an R61529 controller which is not supported by esp-idf). It works just fine if the buffer I use is allocated in internal RAM (a single solid color as expected), but has weird glitchy effects if using PSRAM (random noise). I am sure some data is still sent in the PSRAM case, as the random noise clearly visible.
I've tried to change the data in the framebuffer after each render by memsetting the buffer in the on_color_trans_done callback. In PSRAM case, this just leads to small streaks of appearing in random places on the display (within the rendered area, which is just part of the whole).
Here is how I allocate the framebuffer:
NB: I would assume I'd need to allocate with MALLOC_CAP_DMA even with internal RAM, but somehow everything works even without that.
Code: Select all
// internal RAM allocation
char *framebuffer = heap_caps_malloc(LCD_H_RES * 40 * 2, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
// PSRAM allocation
char *framebuffer = heap_caps_malloc(LCD_H_RES * 40 * 2, MALLOC_CAP_8BIT|MALLOC_CAP_SPIRAM);
// PSRAM allocation, aligned
char *framebuffer = heap_caps_aligned_alloc(16, LCD_H_RES * 40 * 2, MALLOC_CAP_8BIT|MALLOC_CAP_SPIRAM);
Any ideas?