I am connecting my SD card the the ESP32 using this guide.
I have discovered that it only mounts certain brands of SD card (using SD(esp32) example). The Aliexpress 32GB OLEO (red and black) work, the OENY (Blue and black) 16 GB do not work, I have about three of each. I bought a “original” SanDisk Ultra Plus 32GB and it does NOT mount, the cheaper OLEO does mount. I am using the default ESP32 package SD and SPI library and a good 5v power source.
Also I found that initialising is more reliable if the power cut of prior to initialising (can not initialise twice).
It is possible that the manufacture of the OENY is bad, but I can read them all on my PC, its the SD card reader module that is fussy. I wonder if there is a specific pattern of type of specification of the card that the SD reader is compatible with. I have tried formatting the other cards with the same FAT32 and 32K allocation size. I have also used the special SD card formatting software suggested on the Random Nerds article. I am going to buy More OLEO cards and a few other brands (32 GB) to keep on checking. Has anyone else found the special fix to make all cards work, it must be a simple setting perhaps somewhere in the format or a tweak of the library. It just not to do with cheap cards because the SanDisk did not work.
When it comes to use SD cards on MCU SD card slots, my five cents:
some SD cards, esp. newer, want to run in lower voltage mode: The SD card driver will query the card and figure out its type, e.g. SDHC vs. SDXC. If your FW cannot adjust the power voltage for SD card - you might be limited to which card is working
I have seen also issues, when my SD Card driver and FatFS cannot see the card: often, this happens on cards with large capacities, e.g. 512 GB or even 1 TB. Try to use a smaller capacity, e.g. 4 or 8 GB. I think, due to 32bit limitation, e.g. in FAT32, an SD card larger as 32 GB will never work. It would need a different file system (NTFS, eFAT) which might not be supported by your driver.
I have seen also issues where one type of card was working but not another one: lowering the SD Card clock helped here to make it working. Check with which speed you run the SD Card peripheral.
the other mentioned topic as "power consumption" can be true: if the power supply for your board is weak and almost all power is needed just to run the MCU - additional current drawn by a "power hungry" SD Card can generate trouble also for the MCU (e.g. power drops, "brown-outs"). Even I have not realized such a dramatic effect - but a powerful power-supply for entire system makes sense
Most of the time is the SD Card device speed, the capacity of the SD card (too large) or even the type (e.g. a newer one just operating with a lower voltage on adapter).
If what works and what doesn't is a function of brand, and if all cards are 32GB or less (SD or SDHC), and if all cards work on your computer, then the most likely answer is that your 3.3V supply to the card module is marginal, with one brand barely working but the other not working. Some brands just require more power than others. You might try to see if your meter picks up any sagging on the 3.3V line when you try to run the sketch, or perhaps any difference in sagging between brands. If you have a scope, that would show it better.
Thank you all, I will try and follow up with your suggestions and see if I get some consistent results. I have also tried other cards and so far what worked in my set was : Ole o 32 GB (AliExpress red and black colour), Netac 16 GB (Jaycar shop), Sandisk Extreeme and Sandisk High Endurance.
I have powered the SD card module with a desktop power bank 3.3v. The cards that were failing were not recognised and the cards that were being recognised continued to be recognised. So its not the power supply that is the problem. I will have to investigate the other solution options.
Some cards want to have a slower clock (for SDIO peripheral). Try to tweak the clock speed. This did a big difference for me on different cards.
You clock speed is potentially too fast for specific SD card brands.
MCU must have stable 3V3 power and stable SDIO signals (free of reflections, e.g. due to wire/trace length, impedance mismatch etc.), as well.
I would argue:
very new SD cards, e.g. UHS, as SDHC, SDXC need to lower the voltage: after you have read the SD Card "properties" (descriptors) - to be correct - you had to adjust the SD Card voltage.
Imagine: they use potentially 1V8 internally, they have their own voltage regulator inside.
But for the transfer of data (sectors to read), they want to run in lower voltage. Otherwise the card gets too hot because the LDO (regulator) has to burn too much voltage.
So, some cards might fail because of the MCU FW does not "follow" the descriptors responded by the SD card, telling your FW to reduce the voltage for fast data transfer possible to do.
My experience is:
using newer SD card types works often just with lower clock speed (it burns less power and allows to use SD Card even with 3V3 volts). Or they are rejected at all (due to a mismatch of expected parameters).
Handling the SD Card voltage is tricky and needs specific HW (to have an adjustable voltage regulator).
Try with reducing the clock speed first.
If it still fails: some (newer) types are not usable - which is independent of the file system format, how they are formatted: the initialization can fail already when the SD Card type cannot be detected properly and MCU is not able to follow the "requested specifications".
I would assume: modern and very fast SD cards, with large memory size are not always usable on 3V3 MCU systems. They just fail during the "negotiation phase".
If you have full control over source code of your SD card driver - debug where it fails. Often during the phase to "realize" the card properly or the card "tells" you to lower the supply voltage on it before you proceed with data transfer but you not do.
I have seen SD cards used in my MCU where the SD Init fails already - before it tries to figure out the file system (due to a unknown descriptor or how to reduce the voltage requested).
And: make sure to use the right file system: eFAT, NTFS, even possible to format on SD Card - might not be supported by your MCU FatFS.
So, it depends also if your MCU FW is able to recognize different card types properly, to "understand" the SD card descriptors (the feature descriptor read back from SD card)...
Potentially, your FW code, LIB for handling SD cards does not understand all the latest new cards or it cannot "follow" what the card 'has requested'.