Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TW#15774] SD Card timing out #1093

Closed
pablo-mendoza opened this issue Oct 9, 2017 · 10 comments
Closed

[TW#15774] SD Card timing out #1093

pablo-mendoza opened this issue Oct 9, 2017 · 10 comments

Comments

@pablo-mendoza
Copy link

pablo-mendoza commented Oct 9, 2017

Hey,

I have a project where I'm recording 44.1khz 2 channel 16bit PCM data from i2s into an SD card(about 172KB/s). If I let it record continuously it would eventually fail with an error like this:

sdmmc_host_wait_for_event returned 0x107

0x107 being ESP_ERR_TIMEOUT. I ended up fixing it by changing:

#define SDMMC_MAX_EVT_WAIT_DELAY_MS 1000

to

#define SDMMC_MAX_EVT_WAIT_DELAY_MS 2000

I found that the card latency can be that big, specially if you have an SD card that doesn't have any more free blocks in the card (has been full at some point) and it needs to go and erase one for a write.

I tested this in SPI and 1bit SD mode.

@pablo-mendoza
Copy link
Author

SDMMC_MAX_EVT_WAIT_DELAY_MS has a comment stating this this is a safeguard for the card being removed so might as well make this very large (5s?)

@igrr
Copy link
Member

igrr commented Oct 9, 2017

I think we can make this timeout configurable, would that work for you?

@pablo-mendoza
Copy link
Author

That certainly would.

@FayeY FayeY changed the title SD Card timing out [TW#15774] SD Card timing out Oct 11, 2017
@rma31
Copy link

rma31 commented Oct 12, 2017

I have a similar issue with writing large files, may I ask how large your files are when writing?
Do you use fwrite to write the binary data?

@pablo-mendoza
Copy link
Author

@profatkuas: MY files can get up to about 100Mb. And yes I was using fwrite. You can try to change SDMMC_MAX_EVT_WAIT_DELAY_MS to 2000 in the idf source code and see if it fixes that for you.

@ctag-fh-kiel
Copy link

ctag-fh-kiel commented Oct 12, 2017

Would you mind sharing a code snippet of the SD / SPI config part as well as the part you are writing with fwrite?

In which file does SDMMC_MAX_EVT_WAIT_DELAY_MS need to be adapted?

Thx much...

@pablo-mendoza
Copy link
Author

I'm just using the default setup in the storage example. The change that I did was in idf itself:

\esp-idf\components\driver\sdmmc_transaction.c(41):#define SDMMC_MAX_EVT_WAIT_DELAY_MS 3000

Its not configurable at the moment, but seems like that might change in the future. Also it does probably needs a better default if there are more people running into this.

@ctag-fh-kiel
Copy link

I tried adapting the #define

#1089 seems to be still different, with following results using different SD cards:

Possibly #1089 is due to SD size > 8GB?

@igrr igrr closed this as completed in 3cf23ff Oct 18, 2017
@williamrobotma
Copy link

I'm trying to change this but I can't find the #define, how can I fix this in 3.2?

@igrr
Copy link
Member

igrr commented Jul 18, 2018

Since the commit linked above, timeout can be adjusted via command_timeout_ms (i.e. card->host.command_timeout_ms)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants