SDSPI hangs occasionallly

tsc1987
Posts: 6
Joined: Thu Mar 28, 2019 8:25 pm

SDSPI hangs occasionallly

Postby tsc1987 » Fri Apr 05, 2019 9:14 pm

I am using the ESP32 to read/write data from/to an SD card in the SPI mode. Occasionally, the file write operation freezes leading to the task getting stuck at that stage. Log file gathered in verbose mode is shown below:
Screen Shot 2019-04-05 at 4.11.20 PM.png
Screen Shot 2019-04-05 at 4.11.20 PM.png (147.96 KiB) Viewed 5212 times
As shown above, the last write operation never completes and the task is waiting for the function to return. Any suggestions on the cause of this and how to resolve this or to enable a timeout to the file write operation?

Note: The SPI lines are being used exclusively for the SD card. There is no other device on the SPI line

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: SDSPI hangs occasionallly

Postby ESP_igrr » Sat Apr 06, 2019 4:49 am

Hi tsc1987, which IDF version are you using (git describe --tags)? Recently an issue has been reported with IDF 3.1 where SPI transaction might not complete in some situation. Given that SDSPI relies on the SPI driver, it might be related to what you are seeing.
We can supply you with a patch to the SPI driver which adds some debug output, it may help figure out the issue.

tsc1987
Posts: 6
Joined: Thu Mar 28, 2019 8:25 pm

Re: SDSPI hangs occasionallly

Postby tsc1987 » Sat Apr 06, 2019 7:30 am

I am using esp-idf v3.1.3

ESP_michael
Posts: 37
Joined: Mon Aug 28, 2017 10:25 am

Re: SDSPI hangs occasionallly

Postby ESP_michael » Mon Apr 08, 2019 4:19 am

Hi tsc1987,

Here is a debugging patch to show:

1. the process of the trans into and out of sending queue, into and out of the returning queue (to avoid he accidently receive the trans elsewhere).
2. when the interrupt triggers, when the interrupt is enabled/disabled, and trans_done is cleared
3. key value of registers before the transaction is sent

It helps a lot for us to debug your case. Can you run your code with this patch on v3.1.3 and give us the full log/or the latest several pages of log before the hanging happened?
Attachments
0001-debug-commit.rar
(1.77 KiB) Downloaded 454 times

Who is online

Users browsing this forum: ok-home, wangzihao963 and 74 guests