Skip to content

Extend SD card select timeout #6107

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

Closed
1 task done
NomAnor opened this issue Jan 7, 2022 · 3 comments · Fixed by #6162
Closed
1 task done

Extend SD card select timeout #6107

NomAnor opened this issue Jan 7, 2022 · 3 comments · Fixed by #6162
Assignees
Labels
Status: In Progress ⚠️ Issue is in progress

Comments

@NomAnor
Copy link

NomAnor commented Jan 7, 2022

Board

DOIT ESP32 DEVKIT V1

Device Description

I'm using a common Arduino SD Card PCB that is connected with 14cm wires to the ESP32

Hardware Configuration

I'm using the VSPI Pins 18, 19, 23 and 5

Version

other

IDE Name

Arduino IDE

Operating System

Arch Linux

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

921600

Description

Updating to arduino-esp32 v2.0.2 caused the SD-Card to not work anymore (previously I used 1.0.6). The solutions in the other issues didn't work.

Reverting all changes in the file sd_diskio.cpp gave me the same functionality as in 1.0.6.

Looking at the code I suspected the sdWait timeout in the sdSelectCard function, because in 1.0.6 a timeout was just ignored but this is now fixed. In other places (sdWriteBytes) a timeout of 500ms is used so I changed the value to that and now my card is recognized.

For me just chaning the timeout in v2.0.2 fixed the issue.

Sketch

Example SD_Test sketch

Debug Message

Before changing the timeout:

[   313][W][sd_diskio.cpp:104] sdWait(): Wait Failed
[   313][E][sd_diskio.cpp:126] sdSelectCard(): Select Failed
[   313][W][sd_diskio.cpp:510] ff_sd_initialize(): GO_IDLE_STATE failed
[   318][E][sd_diskio.cpp:795] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[   627][W][sd_diskio.cpp:104] sdWait(): Wait Failed
[   627][E][sd_diskio.cpp:126] sdSelectCard(): Select Failed
Card Mount Failed

After changing the timeout:

[    14][W][sd_diskio.cpp:186] sdCommand(): token error [59] 0x5
SD Card Type: SDSC
SD Card Size: 1947MB

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@NomAnor NomAnor added the Status: Awaiting triage Issue is waiting for triage label Jan 7, 2022
@VojtechBartoska
Copy link
Contributor

Hello, it's a duplicate of #6081 and will be closed by merging #6103

@VojtechBartoska VojtechBartoska added Resolution: Duplicate Issue is a duplicate of another issue and removed Status: Awaiting triage Issue is waiting for triage labels Jan 7, 2022
@P-R-O-C-H-Y
Copy link
Member

@NomAnor Hi, changing timeout to 500ms solves the mounting issue for you? :) Thanks

@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Jan 20, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: In Progress ⚠️ Issue is in progress and removed Resolution: Duplicate Issue is a duplicate of another issue labels Jan 20, 2022
@NomAnor
Copy link
Author

NomAnor commented Jan 20, 2022

Sadly not. At first it worked but after a re-upload I had the same problem again. In the end I reverted all changes to sd_diskio.cpp back to 1.0.6. I still got the "Select failed" message but because the return was missing in

if (!s) {
log_e("Select Failed");
digitalWrite(card->ssPin, HIGH);
return false;
}

that was ignored. The missing return is clearly a bug but ignoring the failure kept the code going and I could read files. My SD-Card was rather old maybe it has to do with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress ⚠️ Issue is in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants