-
Notifications
You must be signed in to change notification settings - Fork 7.6k
SD card status check bug #6081
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
Comments
I can confirm there is an issue with SD and core 2.02: SD works very slow in 2.02 |
@AppsByDavideV: It is OK to just remove these lines: f32c0da |
Yes, it works fine now with core 2.02, thanks |
Likewise, if the lines in f32c0da are removed, SD works in V2.0.2, tested with PlatformIO, thanks to @FrankBoesing |
Hello @FrankBoesing, we will take a look on this issue. Thanks for reporting. |
Related to #6078. These 2 issues can be validate and tested together, @P-R-O-C-H-Y. |
Hello, the same here : SD read and write very slow since 2.0.2. Speed was around 400-500 ko/s before, now 4 ko/s after 2.0.2 upgrade. Thanks |
getting random During a screen capture test, 6 files out of 256 failed to write to SD with an average size of 40kb, this is after applying @FrankBoesing's fix. |
Hello, can you try editing sd_diskio.cpp as PR #6103 and test it? |
@P-R-O-C-H-Y confirmed unbroken SD after applying this PR [edit] as pointed out by @Vigeant unbroken state isn't persistent, goes back to broken after a power cycle :-( |
Hello,
Yes it is OK after romvind lines in d_diskio.cpp
Thanks
…----- Mail original -----
De: "P-R-O-C-H-Y" ***@***.***>
À: "espressif/arduino-esp32" ***@***.***>
Cc: "edouardreg" ***@***.***>, "Comment" ***@***.***>
Envoyé: Lundi 10 Janvier 2022 11:20:14
Objet: Re: [espressif/arduino-esp32] SD card status check bug (Issue #6081)
Hello, can you try editing sd_diskio.cpp as PR #6103 and test it?
It should fix the bug.
Thanks
—
Reply to this email directly, view it on GitHub , or unsubscribe .
Triage notifications on the go with GitHub Mobile for iOS or Android .
You are receiving this because you commented. Message ID: <espressif/arduino-esp32/issues/6081/1008725333 @ github . com>
|
Well, after upgrading to 2.02 and applying the fix from PR #6103 as suggested by @P-R-O-C-H-Y my sketch worked for a while and I could read the card again. However, when I resumed work today, it would fail again in the sd_diskio.cpp in the sdWait()<-sdSelectCard() trace. I tried reloading and resetting many times and it would always fail to mount. I reverted my esp32 library back to 1.06 as I had to do before to fix my sd card mounting issues and my card mounted fine. Once the card mounted, I could re-update to 2.02 and apply the PR #6103 fix and my card would keep working. Not sure what happens in the card but it seems like something happens to the card that makes the sdWait() fail in 2.02 that is simply ignored or fixed in 1.06. When running a diff between the 1.06 and 2.02 sd_diskio.cpp you see that the sdSelectCard() is slightly different. In 1.06 it logs that sdWait() failed and keeps going and it still mounts successfully (and fixes the card somehow). In 2.02, if this sdWait fails, it deasserts the ss and errors out stopping the initialization of the card. All that to say that there seem to be more to it than just the PR #6103. There seem to be a fail condition that 1.06 handles better than 2.02 during initialization. Any help from a dev here would be appreciated. |
Status check bug fix is merged now so this issue gets automatically closed. Working on reported issues with mounting sd cards :) |
@Vigeant @tobozo Can you try removing(commenting) these 2 lines from
These 2 lines are not in 1.0.6. |
@P-R-O-C-H-Y this seems to solve the SD mounting issue on ESP32-Wroom and ESP32-S2 and the fix persists across power cycles \o/ |
Thanks @tobozo for testing. Will look why it was added and if its necessary to have these lines. |
Hi @P-R-O-C-H-Y , This is what I am running with since my post and haven't had problems mounting. This seems to be the issue. |
@tobozo @Vigeant When you commented out these 2 lines, the
|
I have this SD SPI module image |
ok I am using https://www.sparkfun.com/products/13743 |
Do you have 5V power to the microSD board? Seems that 10k pull-up resistor does not help.. |
@P-R-O-C-H-Y removing the timeout in sdWait created an endless loop, it waits forever. Tried SD.end / SD.begin in a loop with various delays with no effect. It feels like something (SPI driver?) is setting up the pins in a way that persists across reboots. I'm out of ideas. |
Yeah it seems the problem is with SPI driver, but more weird is that I can't reproduce any issue on official ESPs Devkits boards (tried on ESP32 and ESP32S2). |
Even CS pin should have a 10K pull-up tied to 3.3V |
One more thing to try @tobozo, @Vigeant.
|
@P-R-O-C-H-Y maybe enable USBCDC at boot and don't use the hardware serial? [edit] my board settings However I got some freezes when using |
@P-R-O-C-H-Y commenting out does not help it just fails on the next transaction. |
Yes failed for me too. |
tried a few speeds from 16, 27, 40MHz, even 400KHz, using FSPI, HSPI, constructor, pointer, all fail with sdWait, all succeed when I comment out the So if the problem on ESP32-S2 is SPI related, it's probably wrapped between some |
Thanks for testing that out. Another test for you :) Can you do this change in
|
this fails too, I'm already hammering the SD card in a 10x loop so there was 100 failed attempts instead of 10 :-) Returning true on the first error only confirms the sdWait only fails once: bool sdSelectCard(uint8_t pdrv)
{
ardu_sdcard_t * card = s_cards[pdrv];
digitalWrite(card->ssPin, LOW);
bool s = sdWait(pdrv, 300);
static int failures = 0;
if (!s) {
if( failures++ == 0 ) {
log_w("SD Card initial selection failed, mocking success");
return true;
}
log_e("Select Failed");
digitalWrite(card->ssPin, HIGH);
return false;
}
return true;
} |
OK so the SDwaits fails only once, when the Go idle state is called. Did I get that right? |
it only prints resp=0x00 on failure, which is to be expected (sdWait returns |
I confirm sdWait() only fails once. I put in @tobozo's snipet in mine:
|
Hi @tobozo, @Vigeant For me, it works same as before :D so if you can't test the changes, I will be thankful :) |
@P-R-O-C-H-Y this implementation works for me but ignores the sdWait every time although we know it's only blocking on first access. Ignoring this error every time could make the underlying problem more difficult to solve. One of the effects of this is that if a write timeout occurs after mounting the drive, it'll be silently ignored and eventually result in a corrupted file without even producing a warning. |
I have this same issue after upgrading to the latest esp32 ardunio core 2.0.3 and using the latest @tobozo m5stack-sd-menu code. I am running visual studio with vmicro on a m5stack gray module with no PSRAM. I have a thread going with @tobozo on this issue, see tobozo/M5Stack-SD-Updater#171 . I applied #6103 and commented out the two lines as suggested above by @P-R-O-C-H-Y but no luck. What I did find though which may help folks find the issue and be able to repro is that I have 3 SPI devices attached in my design. 1 is the M5stack display, 1 is the M5Stack TFcard and the other is a LORA communication module. All are on the same bus with different CS pins. If I remove the m5stack module from the lora board everything works perfectly. If I reattach it I get the errors below. after loading @tobozo M5Stack-sd-menu code from my main app. So I though I'd try stopping all 3 SPI busses before the software reset. This made no difference which surprised me. I'm not a SPI expert, but it would seem to be an SPI issue and some control Pin not being reset to the correct state. With this info, does this trigger any thoughts from folks on these errors? rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) [Hobo style] Clock set to an obsolete source (this sketch build): June 05 2022 00:27:10 (Sunday) |
Looks like my issue was due to the LGFX graphics library doing auto detect of boards on the SPI bus and some of the boards they were looking for used the same CS pins as my SPI device that started giving issues. Details on this thread for those interested.... tobozo/M5Stack-SD-Updater#171 |
Board
WT32-SC01
Device Description
ESP-Wrover-Kit
Hardware Configuration
SD Slot
Version
latest master
IDE Name
Platformio
Operating System
Windows 10
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
115200
Description
Enabled log shows many many SD- CRC Failures, reading is not possible wit 2.0.2
After revert the mentioned change, SD starts working again.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: