-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Initializing SD card...initialization failed! with GIT but ok with 2.5 #6019
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've just run the ReadFiles.ino example on 2 cards, changing the one line to
On the 128MB Canon SDC-128MH card I get the expected output (Debug enabled):
And the new Samsung EVO Select U1 32GB I get the right output, too:
Assuming it is a card related issue, what can you tell us about the card? Is it a very old MMC one? What size, brand, type, any other info? |
Also, calling @TD-er. I think I remember you going to the GIT head for your ESPEasy. Does it support SD cards, and if so have you or any of your users tried it or had issues like this? Thx! |
My card is Micro SD Kingston 4Gb microSDHC – Classe 4 - I have also tried an ADATA 16GBMicro SD class 10 with same result |
..edit..since I can't spell PIN...and can't spell "since" either, it seems...
The
SD_CS_PIN is used in some SdFat examples, but there is no actual use in the low-level libs, so defining it is a no-op, I think. Can you edit the readfiles.ino example and change the same line I showed |
I am not sure to understand what you mean SD_CS_PIN is used in file
|
Ahha, I think I see the difference: I am using the You are using the ESP8266SdFat example So, there is something in the SdFat examples which is incorrect, but the SD ones are fine. LEt me see. It's probably a simple define/namespace/config issue. |
and about SD library listfiles.ino :
sample is not good anymore ? |
Think we cross-posted. You're not using the SD examples, but the SdFat ones... |
read my first post I tried both |
So, what's going on is the ESP8266SdFat examples have an updated, incompatible with the older SD SD.h where they make an ESP8266-incompatible File (defined in a private header) and do other badness. It's fine for other systems where they're the only filesystem, just not good for us. And not needed since our SD.h is compatible with all our other Filesystems (SPIFFS, LittleFS, etc.). Basically, I think the only answer is to ignore the SdFat examples and use the 8266-compatible SD ones. I can blow the examples away from the repo to avoid this issue. |
For the SD one, did you modify the SD.begin() line or set the |
the sample code from SD : I did not change anything - same code in 2.5 works and same code failed in GIT both are identical sample and identical hardware and identical SD card |
I changed code like you:
and I get
is that normal ? |
That's definitely not normal. Do you maybe have the GIT and the IDE version installed at the same time? Need to uninstall one to use the other successfully. The lack of a |
Ok seems D0 is defined for NodeMCU but not for generic
still I originaly though it was my setup/ hardware - but rollback to 2.5 works and also on ESP32 that is why I raised issue |
As a short reply to me being mentioned. I know there is support in ESPeasy for SD card (must enable and build yourself), but not many use it. |
Thanks, @TD-er . @luc-github it could be a different default speed for the SPI bus which your reader/wiring may not support. Try changing the begin line to set the SPI speed as well:
Obviously using the CS pin you've wired up in place of 16. |
Actually I tried before SPI_QUARTER_SPEED and SPI_HALF_SPEED without success, I tried these values because they worked with 2016 version of SDFat beta and because SPI_HALF_SPEED was default value in 2.5. but SD_SCK_MHZ(1) seems to work (I did not know this way) , new SD need lower SPI SPEED ? |
That's probably a question better left to the SDFAT maintainer, @greiman. I just brought his massively updated and improved (LFNs, etc.) version into the 8266 Arduino repo, but did not actually change any of the guts (other than to place it in a namespace). I think it's more likely the older settings were not doing what they were supposed to and you were really going slower/faster than expected on the board. Or, it could be some change to SPI (which I haven't been following, sorry) that's now interpreting things differently. |
And, FWIW, I'm not seeing any problem w/o the 1MHZ specification (i.e. I just use "SD.begin(XX)", no SPI settings param) when I run the SD examples. So it's very odd, maybe something timing related on the SPI bus changed.... |
Thank you, well looking at speeds in SD 2.5 they are defined here : Arduino/libraries/SD/src/utility/Sd2Card.h Lines 29 to 41 in 951aeff
in new SD :
which give following values:
Using SPI_SIXTEENTH_SPEED in new SD instead of SPI_HALF_SPEED in 2.5 SD make it works on my side I can imagine your setup is using fast hardware, so going faster is not an issue, but on my side it is obviously a problem, and so even the new SD is far better than old one - somewhere compatibility is broken and a note concerning speeds would be welcome IMHO. On my side I was using old SDFat beta 2016 until now, so I can do speed adjustment in same time I will integrate the new SD instead of old SDFat beta, so impact is not high, but for people that do not change anything (like I did using sample code) they may get surprised if same code failed now. Thank you again for your great work - new lib will be far better than old one. |
@luc-github I'm reopening this as it's a simple fix to be backwards compatible. I think @igrr fixed the ancient Arduino libs, manually. The same change looks not so bad in the real sdfat lib... |
Replace the default SPI_FULL/HALF/QUARTER_SPEEDs with ESP8266 appropriate ones taken from the original SD library that @igrr modified. Fixes esp8266#6019
Thanks again for the debug, @luc-github . |
SD support looks broken in GIT version when it was Ok in 2.5
Basic Infos
Platform
Settings in IDE
Problem Description
SD card init failed with git version
using sample : https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/listfiles/listfiles.ino
Initializing SD card...initialization failed!
on same hardware with core 2.5 same code works
Also tried the new library :
https://github.com/earlephilhower/ESP8266SdFat/blob/92ab4b59eb920bf3134347dbe07e7c059eb64d46/examples/ReadWrite/ReadWrite.ino modifing
#define SD_CS_PIN 4
to not change the wiringsame error:
Initializing SD card...initialization failed!
The text was updated successfully, but these errors were encountered: