Page 1 of 1

Lolin D32 Pro. Is it right that I can't use the SDCard and Display in esp-idf?

Posted: Fri Sep 07, 2018 2:40 pm
by ruffle
Sigh. It was all going so well :-(

I'm using a Lolin D32 Pro with its inbuilt SDCard and native TFT display connector and esp-idf v3.2-dev-209-gbe81d2c1... well trying to :(

Lolin/Wemos have designed the board with the SD Card and TFT sharing the same SPI bus with a different CS line (4 & 14 respectively) for each. I wonder if this was a huge mistake.

I spent ages getting the display to work with esp-idf, was delighted when I did... and then hit the buffers when I discovered that it breaks writing to the SDCard that was previously working.

Code: Select all

3 16831970 CAN receive 291 (0x123) Length: 8 Data: 1122334455667783
E (22898) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x107
E (22899) diskio_sdmmc: sdmmc_write_blocks failed (263)
4 21843290 CAN receive 291 (0x123) Length: 8 Data: 1122334455667783
E (27911) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x107
E (27919) diskio_sdmmc: sdmmc_write_blocks failed (263)
5 26867201 CAN receive 291 (0x123) Length: 8 Data: 1122334455667783
E (27933) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x107
The trigger for these dma related errors really does seem to be the use of another device on the SPI bus. If I comment out all of the display code it doesn't come up with these write errors.

After some Googling I found a comment in the docs (https://dl.espressif.com/doc/esp-idf/la ... sdmmc.html):
Currently SD SPI driver assumes that it can use the SPI controller exclusively, so applications which need to share SPI bus between SD cards and other peripherals need to make sure that SD card and other devices are not used at the same time from different tasks.
Oh dear..... this seems to imply that the features of the Lolin D32 Pro board are not useable with esp-idf without some magic (or an update of esp-idf to some as-yet-unwritten version).

Can anyone suggest how one could construct some suitable magic? Would putting a semaphore around my

Code: Select all

fprintf(log_fp,"......
fflush(log_fp);
fsync(fileno(log_fp));
code and wrapping my display update routines in the same semaphore be the right thing?

Any other ideas?

Does the Arduino IDE ESP32 stuff also suffer from the same problem? I'm loath to jump there from esp-idf but if that means my Lolin hardware will work I guess I'll have to consider it.

TIA

Re: Lolin D32 Pro. Is it right that I can't use the SDCard and Display in esp-idf?

Posted: Mon Sep 10, 2018 12:33 pm
by ruffle
To answer my own question (for the benefit of others who might trip across this).

Using a semaphore around the SDCard/Display write code seems to work.

Re: Lolin D32 Pro. Is it right that I can't use the SDCard and Display in esp-idf?

Posted: Thu May 09, 2019 3:31 pm
by billball@capital.edu
Could you post a more complete code example of how you resolved this issue? It would be much appreciated.