Display and SD card have trouble sharing the SPI bus on ESP32

Description

I took the samples from here and here. Both Display and SD Card share the same SPI 2 bus. They share the same MISO, MOSI, and CLK pins, but they have their own CS pin. I start the display first (which will also initiate the SPI bus) and then start the SD card. The SD card can start successfully and log information. If I change the screen once, the SD card operation will remain normal, however, if I change the screen twice between each logging interval, the SD card task will fail to open the directory and write to the file. The same behavior happens if I use a lv task to update widgets on the screen.

I (22602) raydebug: logging memory Thu Jan 1 00:00:22 1970

E (23605) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x107
E (23605) diskio_sdmmc: sdmmc_read_blocks failed (263)
I (28643) raydebug: logging memory Thu Jan 1 00:00:28 1970

E (29644) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x107
E (29644) diskio_sdmmc: sdmmc_read_blocks failed (263)
E (29646) SD_Card: Failed to open file for writing

What MCU/Processor/Board and compiler are you using?

ESP32 Wroom 32U

What LVGL version are you using?

V7.11

What do you want to achieve?

Allow both SD card and display to operate on the same SPI bus without any interference from each other.

What have you tried so far?

Gave both display and sd card the same SPI config. Both are in full duplex mode. Added a semaphore to make sure the logging task doesn’t run at the same time as lv_task_handler.

Hi!

I have a similar problem. I have a 480x272 pixel screen paired with an ESP32S3. When I configure the SD card before setting up the screen, I can read the settings file from it. After that, I configure the screen. Then, when I try to transfer a file over WiFi, the file arrives, but the SD card can’t write it, and I can’t even read anything from the card. I’ve set flags to prevent updating the lvgl timers and exited the my_disp_flush function using this flag, but nothing has helped.

Have you found a solution to your problem?