Micro SD - vol.init failed, Cardsize = 0.0

Hi,
I'm trying to get the SdFat library work with a micro SD card (4GB) together with a Micro SD card purchased on eBay of the following type: http://item.taobao.com/item.htm?spm=a1z10.1.w4004-8438023200.10.iGcptA&id=19306030373

The shield uses 74VHC125MCT level shifter.

When I run the sketch SdInfo I get the following output:

type any character to start
init time: 3 ms
Card type: SDHC
Manufacturer ID: 0X1
OEM ID:
*Product: *
Version: 0.0
Serial number: 0X9808C018
Manufacturing date: 0/2008
cardSize: 0.00 MB (MB = 1,000,000 bytes)
flashEraseSize: 64 blocks
eraseSingleBlock: false
SD Partition Table
part,boot,type,start,length
1,0X0,0X1,0,1048576
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0
vol.init failed

I've used SdFat library with other shields using normal (not micro) SD cards without problems before.

Any suggestions to why it fails? I know it's quite old (says manufactured 2008). Is it because of lack of support for erasing single blocks?

Edit: I've formatted the card with SD Formatter utility, and it works fine under windows/linux.

Best Regards
Comiter

There is a lot wrong with the info read from the SD.

The card size is zero, The partition type is 0X1 which is FAT12 and impossible for a 4 GB card.

What size does Windows and Linux report for the card?

What is the SD card brand?

I have used your ebay SD module with microSD cards and it worked fine.

The brand of the SD card is Samsung.
Windows reports the card as 3 930 456 064 bytes (3,66GB).
Also under properties in Windows it say that the file system is FAT32.
I have created and read data files (text files) from the card in Windows.

I've tried to format it with both SD formatter and Mini Tool Partition Master, same result.
The Mini Tool reports (after formatting):

Partition Type ID: oxb
File system: FAT32
First Physical Sector: 63
Last Physical Sector: 7698431
Total Physical Sector: 3.67GB

SD Info after this formatting reports

cardSize: 0.00 MB (MB = 1,000,000 bytes)
flashEraseSize: 64 blocks
eraseSingleBlock: false

SD Partition Table
part,boot,type,start,length
1,0X0,0X1,15,1053632
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0

I'll try to get hold of a new card tomorrow and see if that does the trick.

I've finally got a new SD card yesterday, and I gave the sdfat library a second try with this card. It is a Samsung 8GB micro SD card. It still gives me the same error as the previous one (still reporting as 12-bit FAT as partition type). However, the first time I ran it, it reported "readCSD Failed", while the tries afterward says vol.init failed.

SdFat version: 20140806
type any character to start
init time: 4 ms
Card type: SDHC
Manufacturer ID: 0X1
OEM ID:
Version: 0.0
Serial number: 0X80000099
Manufacturing date: 0/2015
readCSD failed
SD errorCode: 0XF
SD errorData: 0X0
type any character to start
init time: 4 ms
Card type: SDHC
Manufacturer ID: 0X1
OEM ID:
Product:
Version: 0.0
Serial number: 0X88000099
Manufacturing date: 0/2014
cardSize: 0.00 MB (MB = 1,000,000 bytes)
flashEraseSize: 64 blocks
eraseSingleBlock: false
SD Partition Table
part,boot,type,start,length
1,0X0,0X1,0,14780416
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0
vol.init failed

I also upgraded to Arduino 1.0.6, just to give it a try.
Windows reports the card as Okay (FAT 32 and just above 7,5GB)

I've also tried to upgrade to the BETA version of sdfat, which gives me the following output:

SdFat version: 20141025
type any character to start
init time: 3 ms
Card type: SDHC
Manufacturer ID: 0X1
OEM ID:
Product:
Version: 0.0
Serial number: 0X80000099
Manufacturing date: 0/2014
readCSD failed
SD errorCode: 0XF
SD errorData: 0X0
type any character to start
init time: 4 ms
Card type: SDHC
Manufacturer ID: 0X1
OEM ID:
Product:
Version: 0.0
Serial number: 0X88000099
Manufacturing date: 0/2014
cardSize: 0.00 MB (MB = 1,000,000 bytes)
flashEraseSize: 64 blocks
eraseSingleBlock: false
OCR: 0XC0FF8000
SD Partition Table
part,boot,type,start,length
1,0X0,0X1,0,14780416
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0
vol.init failed
type any character to start

I'm stumbeling in the dark, and do not have any clue what's might be wrong.

The code runs on a MEGA2560. Could this error be caused by a HW issue (bad cabling, defective SD card reader)? If so, I might try to replace the reader circuit. It is a bit of a hazzle, but I'll do it if the issue can be HW. I have not done it yet, as the code reads the serial number, gets to initialize the card and so on, indicating correct wiring and HW (in my humble mind).

Best Regards
Comiter

The code runs on a MEGA2560.

Do you mean it is connected to a Mega? Or it runs on a Mega but not an Uno?
How do you have it connected to the Mega? Describe pin-to-pin connections, including power and ground.

Hi SurferTim,

It is connected to a Mega (sorry for the bad wording).

I have a 5v power supply connected to both Mega (omitting the Mega regulator) and SD shield (I'm using the word shield about the seperate SD card reader in this case). This 5v supply is wired in a "Star" configuration, where both PCBs is connected to the GND and +5v terminal of the 5v regulator.

The 5v regulator are capable of delivering 5v/3A

For the datalines, these are:

MOSI - ICSP Plug, Pin 4
MISO - ICSP Plug, Pin 1
SCK - ICSP Plug, Pin 3
CS - Pin 7

Best Regards
Comiter

Your problem looks like marginal SPI signals. Enabling software CRC is a good way to check SPI data transmission. CRC is done in software and has high overhead so it is not the default.

Edit the SdFatConfig.h file in the SdFat folder and set USE_SD_CRC nonzero.

/**
 * To enable SD card CRC checking set USE_SD_CRC nonzero.
 *
 * Set USE_SD_CRC to 1 to use a smaller slower CRC-CCITT function.
 *
 * Set USE_SD_CRC to 2 to used a larger faster table driven CRC-CCITT function.
 */
#define USE_SD_CRC 0

If there is an SPI transmission problem you will get solid failures for invalid data transfers.

Post the error output from the SdInfo program.

Hi fat16lib,

I modified the config to:

/**
 * To enable SD card CRC checking set USE_SD_CRC nonzero.
 *
 * Set USE_SD_CRC to 1 to use a smaller slower CRC-CCITT function.
 *
 * Set USE_SD_CRC to 2 to used a larger faster table driven CRC-CCITT function.
 */
#define USE_SD_CRC 2

Without CRC, the current SD card say (16GB Kingston, class 4):

SdFat version: 20141025

type any character to start

init time: 3 ms

Card type: SDHC

Manufacturer ID: 0X0
OEM ID:
Product:
Version: 0.0
Serial number: 0X108000
Manufacturing date: 0/2014

cardSize: 0.00 MB (MB = 1,000,000 bytes)
flashEraseSize: 64 blocks
eraseSingleBlock: false
OCR: 0XE0FFC000

SD Partition Table
part,boot,type,start,length
1,0X0,0X0,0,12632064
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0

vol.init failed

With CRC enablet it reports:

SdFat version: 20141025

type any character to start
cardSize failed
SD errorCode: 0X1B
SD errorData: 0X0

type any character to start

The errorCode 0X1B means there was a CRC error in the 16-byte block of CSD data sent by the card containing the card size.

/** invalid read CRC */
uint8_t const SD_CARD_ERROR_READ_CRC = 0X1B;

I double checked that CRC is working correctly in SdFat.

You have a serious SPI signal problem. I didn’t expect a CRC error in the transfer of the 16-byte CSD register. I expected a problem with 512 byte data blocks.

The read CSD command is the first transfer done by cardInfo.

You could try slowing the SPI rate drastically to see how bad it is. Try changing init() in cardInfo like this to use 500 kHz SPI:

  if (!card.init(SPI_SIXTEENTH_SPEED, SdChipSelect)) {
    sdErrorMsg("\ncard.init failed");
    return;
  }

Hi fat16lib,
thanks for the reply. I tried with different speed (I had previously only tried down to SPI_QUARTER_SPEED without luck). With SPI_SIXTEENTH_SPEED and SPI_EIGHTH_SPEED it works, but any higher speeds fails.
I'll give it a go and replace the SD card module and see what happens.

Thank you very much for your support!

Best Regards
Comiter