With Windows10 I have formatted an 32 Gb SDcard as FAT32 and checked by asking the properties after the format was complete. It was OK.
After executing example CardInfo with a SDcard module and an Arduino Nano the results in the monitor are as below:
Initializing SD card...Wiring is correct and a card is present.
Card type: SD2
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card
Unfortunately, I can't tell Cardinfo that this SD card is actually formatted as FAT32 :-)
Then I tried the Arduino example File> Examples > SD > ReadWrite with this result:
Initializing SD card...initialization failed!
If I look closer to the way these two examples are initializing the SD card then I see a difference.
The line " if (!card.init(SPI_HALF_SPEED, chipSelect)) {Serial.println("initialization failed. Things to check:"); " etc. in the Cardinfo example works OK,
but the similar initializing line in the Read/Write example " if (!SD.begin(4)) {Serial.println("initialization failed!"); " etc. then the initializing is failed.
(note: the variable "card" in the CardInfo example is declared as "SD2card card;")
I have tried another formatted SDcard. Same result. And I have used both SDcards in another device without any issue.
What could possibly cause this?
Have you perhaps ever encountered this issue as well?
Since it is never completely clear exactly which example you are using, can you just post the code for each example (within code-tags please)
Just in case can you post the wiring that you are using, including a link to the SD-card holder unit and/or a picture of it.
It is just looking for possible options. Anything over 4GB will have to be FAT32 or it won't have sufficient size for the addresses in the FAT.
No to be honest, but i have only used SD-card with ESP boards which are 3.3v devices just like SD-cards are, (and therefore do not require level shifting) and have a significant amount more memory.
The CS does not correspond, and if of course a simple user definable pin, but that is why i ask to just post the exact code that is uploaded instead of referencing something which is included in the IDE libraries.
(there may always be differences between (core) versions as well)
I have tried now SDformatter and SDinfo. I didn't know about the existence of SDfat.
I have installed SDfat version 2.3.0 of Bill Greiman.
Now all formats and tests were succesful! Thank you for this hint.
In some example sketches the CS-pin is going to 4 or to 10. I had to pay attention to that especially.
I had done a full format within Windows10 and used Arduino IDE version 1.8.19. Apparently that was not good enough.
Then also the tests with the Examples-SD-CardInfo and Examples-SD-Read/Write were going smoothly now with correct results!
The SD library is based on a simplified and old version of SdFat - which has been maintained and improved since. So that’s why I’d recommend to stick to SdFat.
What i do in that case is decide on what i want to use, the CS pin is free assignable after all and not connected toe the SPI peripheral after all. And save the sketch with the preferred choice as my example and save it in my sketchbook folder.
On the ATmega328P, if the hardware SS pin (digital 10 on the Uno) is configured as an input and driven low, the SPI peripheral can switch into slave mode. Therefore, when operating as SPI master, that pin must be kept configured as an output to guarantee master mode.