MicroSD fails to initialize

Rydez · 10 · 414

Rydez

  • Full Member
  • ***
    • Posts: 10
    • View Profile
Hello! I'm having some trouble with reading an SD card. I have a TinyZero with a MicroSD TinyShield on top. I got my SD card here: https://tinycircuits.com/products/microsd-card-and-adapter-8gb. I'm following the tutorial here: https://learn.tinycircuits.com/Memory/MicroSD_TinyShield_Tutorial/. I've formatted the SD card using the prescribed SD formatter (FAT32), and I downloaded the zip that contains the CardInfo sketch that uses chipSelect = 10 and uses SerialUSB. Unfortunately, when run the SD card fails to initialize, and it outputs:

Initializing SD card...initialization failed. Things to check:
* is a card inserted?
* is your wiring correct?
* did you change the chipSelect pin to match your shield or module?

I've scoured the internet in an attempt to find a solution, but nothing I've tried has worked.

Any advice would be great!


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 357
    • View Profile
Hiya,

First thing I would check - is the SD Card fully inserted? It hangs out a bit, but it does need pushed in all the way to the connector. The boards should also be flatly connected with the tan 32-pin connector between the TinyZero and SD Shield.

When you connect the SD card and open it on just your computer, I assume that works just fine? Can you drop files onto it? Make sure to safely eject it when you unplug it - some data corruption could cause issues when trying to read the info from the card.

Let me know if that helps!

Cheers,
Réna




Rydez

  • Full Member
  • ***
    • Posts: 10
    • View Profile
Hi Réna,

Here are a couple pictures to show the connections. They seem good to me. It seems that the SD card is in as far as possible. Also, yes, the SD card works on my computer. I can move files onto it.

https://ibb.co/G3DHdTD
https://ibb.co/W0XsQQC


Rydez

  • Full Member
  • ***
    • Posts: 10
    • View Profile
Not sure if this would cause a problem, but I originally formatted the SD using Ubuntu's OS, then later I went to a Windows computer to use the SD formatter from https://www.sdcard.org/downloads/formatter/.


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 357
    • View Profile
Did you test the card before formatting it with Ubuntu? I'm curious if the formatter you used could have mismanaged the protected memory of the SDHC SD Cards we distribute.

The windows formatter you linked from our site has some warnings that formatters from other operating systems could lower performance, but it doesn't mention that the card would be unusable. It still works with dragging and dropping files, so it's possible the Ubuntu formatter could have formatted the protected memory of the SD Card making the card info unreadable. Can you share what tool you used, or are you able to look into how it reformats SDHC cards?

Could you try writing a .txt file to the SD Card to see if that works? You can use this example, you'll just have to change the Serial object to SerialUSB: https://github.com/arduino-libraries/SD/blob/master/examples/DumpFile/DumpFile.ino - This example uses SD.begin(chipSelect) rather than the card.init(SPI_HALF_SPEED, chipSelect) in the example that's not working so it handles initialization a little differently.


Rydez

  • Full Member
  • ***
    • Posts: 10
    • View Profile
If I'm remembering correctly, I did not test the card before formatting it with Ubuntu. The initial formatting was done with the UI shown here: https://itsfoss.com/format-usb-drive-sd-card-ubuntu/.

I attempted to run the sketch you sent, but I'm getting the same output because SD.begin(chipSelect) fails. I also attempted using SD.begin() in the past while trying to figure this out myself.


Rydez

  • Full Member
  • ***
    • Posts: 10
    • View Profile
Thinking about going and getting a fresh SD card to test. Are the SD cards distributed by TinyCircuits special in some way? Or, will any SD card work?


Rydez

  • Full Member
  • ***
    • Posts: 10
    • View Profile
Started doing some deeper debugging within the SD library. I've found that the card fails here: https://github.com/arduino-libraries/SD/blob/a61e84b97b7742024ea2c8545a2b797aa6d551f4/src/utility/Sd2Card.cpp#L305. Timeout is reached while attempting to go into idle state. The timeout is set to 2,000 ms. I tried waiting 100,000 ms, but it didn't work. The status_ variable in Sd2Card is 0x20 before running card.init(), and 0xFF after.
« Last Edit: July 23, 2022, 10:08:14 AM by Rydez »


Rydez

  • Full Member
  • ***
    • Posts: 10
    • View Profile
Just went out and bought a new microSDHC card. I tried it straight out of the package, and that didn't work. Then I formatted it with the sdcard.com formatter, and that didn't work.


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 357
    • View Profile
It sounds like something could be faulty with the hardware if the chip select at pin 10 isn't working. I'll email you about getting a replacement!


 

SMF spam blocked by CleanTalk