Pages: [1] 2   Go Down
Author Topic: >> Resolved << : MEGA with cardinfo.h and "LC studio" SD card reader dont work  (Read 10350 times)
0 Members and 1 Guest are viewing this topic.
Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The same in French at (Le même en Français à) http://arduino.cc/forum/index.php/topic,125710.msg945043.html#msg945043

Hi every body,

When I started to work on this SD card reader, I thought to have 15 minutes to start to learn all the functions of the library (SD in the case).
Perhaps is there something I don't understand but nothing is correctly going on.

I m working on MEGA with an "LC studio" SD card reader.

If you read French, U can see this post (in FRench) : http://arduino.cc/forum/index.php/topic,125710.0.html

I m tring now to expose the problem here.

At every time I open the serial monitor, MEGA send this message :



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


The program in the ATMEGA2560 of the MEGA is the one you can find by : Files/Exemples/SD/cardinfo of the 1.0.1 ARDUINO version. I modified it to fit well to MEGA.

Code:
#include <SD.h>

Sd2Card card;
SdVolume volume;
SdFile root;

const int chipSelect = 53;    

void setup()
{
  Serial.begin(9600);
   while (!Serial) {     ; // wait for serial port to connect. Needed for Leonardo only  }

  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(53, OUTPUT);     // 10 change this to 53 on a mega
  

  if (!card.init(SPI_HALF_SPEED, chipSelect)) {    Serial.println("initialization failed. Things to check:");
...
etc

I tryed with another MEGA card,... with another SD card (64Mo and 32Go Fat formated by Windows  7)
I can see on oscilloscope the MOSI signal from the MEGA to the SD and the answer (I think) from SD to MEGA on MISO (see attached pictures) when CS is at low state. SCK seems to be correct too.

The connection is as follows:
MEGA pin 50 -> miso (Master in) Card Reader "LC studio"
MEGA pin 51 -> mosi (Master Out)
MEGA pin 52 -> sck (Serial Clock)
MEGA pin 53 -> CS (Chip Select)

In Final ... the perennial failure message above recalled.

I did a voltage matching on the outputs of the player to the MEGA (see diagram image)

Seeking an electrical problem on the SD card reader, I found that the ground pin of the regulator AMS1117 was not connected to the ground of the reader, then I fixed the error and voltages are stable and nominal. I found 52Ko and not 0 Ohms between the Voltage controler's ground and the reader's card ground, measured by Fluke 185. This is a problem, sometimes on this type of player because I found a post on this, once I had identified the problem and the components in question, providing the necessary keywords to search on the net... Chinese electronics...   ( http://arduino.cc/forum/index.php?topic=122947.0 )



I'm interested in any new info, result of experience or constructive idea and thank you in advance.

Cordially.


* Scope 00@11-Adapt 5V 3.3V - Liberty.JPG (303.41 KB, 730x4400 - viewed 200 times.)

* Prob Defaut Masse - QL0.JPG (362.54 KB, 730x2713 - viewed 264 times.)

* AdptNiv-V1.2-sign-Red.JPG (117.08 KB, 1498x893 - viewed 313 times.)
« Last Edit: October 13, 2012, 10:53:38 pm by LibertyCareche » Logged

Quidquid agis, prudenter agas, et respice finem !

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great news for me... I did not become sénileet !!

I tryed with an Arduino Uno. The firts tests let me think that I could have to retire early ... but finaly I removed again the 64MB SD card to try an 32GB in FAT32 formatted. Result :

Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card



Besides the first electronic bug, I wonder if :
  1) the MEGA coupled to an SD card can be a problem for SD.h
  2) a 64MB SD card can be a problem for SD.h
  3) a 10 years old Card wich is working fine (I test regularly every hour) can cause problems for SD.h
  4) Contrary to what you may read on the official site, the FAT16 could pose a problem SD.h


_ _ _ _ _ /_ _ _ _ _ /_ _ _ _ _ /_ _ _ _ _ Subsequently , why SD.h can't find the FAT? _ _ _ _ _ /_ _ _ _ _ /_ _ _ _ _ /

« Last Edit: October 07, 2012, 06:01:39 pm by LibertyCareche » Logged

Quidquid agis, prudenter agas, et respice finem !

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 150
Posts: 6139
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My 4GB card works fine in my ethernet shield sd slot on a Mega, and I am using the SD library. So I think it is neither the Mega nor the library.

Are there any files that violate the 8.3 filename format on the sd?
The SD library finds mine ok
Logged

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1658
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is the 64 MB card an MMC card?  Also some old cards don't comply with the SD spec.

SD.h only supports SD cards that comply with the SD standard.  Macs and Windows machines support old cards but SD.h does not since this would increase the size of the library and few people use cards produced before the standard was finalized.

Also the SD standard requires 64MB cards to be formatted FAT12.  SD.h does not support FAT12 file systems.

How did you format the cards?  If you used Mac or PC utilities, the card may be formatted with a GUID partition table instead of MBR. PCs and Macs accept GUID partition tables but SD.h does not.

The SD standard requires a MBR partition table.  The best way to format SD cards is to use SdFormatter https://www.sdcard.org/downloads/formatter_3/.

It would be helpful if you downloaded SdFat http://code.google.com/p/sdfatlib/downloads/list and ran the QuickStart and SdInfo examples and posted any error codes from these programs.  These programs are in the SdFat/examples folder.

You can also force the 64 MB card to be formatted FAT16 by using the SdFormatter example in the SdFat/examples folder.
« Last Edit: October 07, 2012, 04:40:05 pm by fat16lib » Logged

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for answer to me SurferTim,

There is just one file in 8.3 format name.
As I wrote, I change the MEGA to be sure that the problem can't be imputed to it.


                    I think that it will be funny to write an answer 
                    to the scrolling question in your scrolling texte


Thanks too for your answer Fat16Lib,

The 64MB sd card is marked "Multimedia card", so... I think its an MMC...
Thank you for all these tips.

I formatted the cards with SDFormater V3.1.    I'll try SdFat and post the results.

it is certain that writing a library as SD.h is a big job. Successful work indeed! Admittedly, this is a big library for a card Uno but perhaps it could be made more efficient for the more powerful cards, such as MEGA and those that will probably come out in the coming months or years...

Are you the author of this library? I think I read somewhere your username !...

anyway, thank you very much

Logged

Quidquid agis, prudenter agas, et respice finem !

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tryed it, Fat16Lib,

here is the result :

SdFat version: 20120719

type any character to start

card.init failed
SD errorCode: 0X8
SD errorData: 0X1

type any character to start

Logged

Quidquid agis, prudenter agas, et respice finem !

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1658
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The card is not an SD card.  It must be a MMC (MultiMediaCard) since the error code is 0X8.

SD I/O can be a bit faster with a Mega but not much.  AVR SPI is not very efficient.

I have developed a version for Cortex M processors and will release it for the Arduino Due and Teensy 3.0.  It runs much faster than the AVR version.

I will provide an option in the AVR library to speedup the Mega a little.  Very few people use the Mega and most people use Print to write text files which is very slow.  Most people use the Uno and memory is precious with this board.

I have released examples that allow writing binary data much faster.  See AnalogIsrLogger20120810.zip http://code.google.com/p/beta-lib/downloads/list.  This example logs binary data from an analog pin at up to 100 ksps.  It uses a special API to create contiguous files and stream data using multi-block SD write commands.
Logged

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know if its an MMC, Fat16Lib...

see picture...

have a good day


* Scan TLC 503.jpg (63.56 KB, 556x369 - viewed 77 times.)
Logged

Quidquid agis, prudenter agas, et respice finem !

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1658
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This card is a SDHC card so it should work with both SdFat and SD.h libraries.

The card fails on CMD58 which checks whether the card is a standard capacity card or high capacity card and returns the Vdd range supported by the card.

The card returns a status that it is not in a ready state.  This means power on initialization has not completed correctly.

CMD58 is only used in SPI mode.  A different set of commands is used by a PC or Mac in SDIO mode.  This card may work in a PC or Mac but fail in SPI mode.

Does it always return error code 0X8 with error data 0X1?

MMC cards also fail on CMD58 but your card is clearly an SDHC card.  MMC cards often fail with error code 0X8 and error data 0X5.
« Last Edit: October 08, 2012, 08:14:56 am by fat16lib » Logged

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am going to buy another SD card... 2GB. Appoint it (nominate) SDb, want you ?
I formated it as you told me with SDFormatter.

the result with SDInfo is :

Code:

SdFat version: 20120719

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0X57

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0X57

type any character to start

init time: 47 ms

Card type: SD2
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0X4F

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0X57

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0XAB

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0XAB

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0X55

type any character to start

init time: 39 ms

Card type: SD1
readCID failed
SD errorCode: 0XF
SD errorData: 0X0

type any character to start

It's not the same result for each tests.


For the 32GB of yesterday,... Appoint it SDa,... I have some different results too :


Code:
SdFat version: 20120719

type any character to start

card.init failed
SD errorCode: 0X8
SD errorData: 0X1

type any character to start

card.init failed
SD errorCode: 0X8
SD errorData: 0X7F

type any character to start

init time: 47 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

init time: 47 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

init time: 4 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

init time: 75 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

card.init failed
SD errorCode: 0X8
SD errorData: 0X3

type any character to start

init time: 28 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

init time: 30 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

init time: 31 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

init time: 30 ms

Card type: SDHC
readCID failed
SD errorCode: 0X10
SD errorData: 0XFF

type any character to start

card.init failed
SD errorCode: 0X2
SD errorData: 0X55

type any character to start
Logged

Quidquid agis, prudenter agas, et respice finem !

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1658
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A new card seems like a good idea.   

I worry that the problem may be noise on the SPI bus.  There are often SPI problems with modules like the LC Studio.  Most reliable modules have a 5V to 3.3V level shifter based on a buffer chip.   Level shifters based on resistors and diodes work poorly with some cards.

Some cards use edge detectors and the sharp signals of a buffer chip work better.

If you new card does not fix the problem, make sure the SPI wires are as short as possible.
Logged

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's exactly what I was telling myself  smiley
It's only the difference... the voltage adaptation. If you saw the electronic diagram I made based on the LC studio card reader (black components) and my adaptation système, you can see three diodes... I recommend Schottky diodes like BAT85 and now I just have some 1N4148... then the high level is 3.3V but the low one is 0,6V. it is certainly not ideal. I'll work with (on)  that now.

thank you very much for your advice
Have a good evening, although it is perhaps a little early for you at this time...
Best regards
Logged

Quidquid agis, prudenter agas, et respice finem !

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

smiley

With SDb & UNO :


Code:

SdFat version: 20120719

type any character to start

init time: 3 ms

Card type: SD2

Manufacturer ID: 0X6F
OEM ID:
Product: SMI
Version: 1.0
Serial number: 0
Manufacturing date: 7/2012

cardSize: 3887104 (512 byte blocks)
flashEraseSize: 128 blocks
eraseSingleBlock: true

SD Partition Table
part,boot,type,start,length
1,0X0,0X6,131,3886973
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0

Volume is FAT16
blocksPerCluster: 64
clusterCount: 60726
freeClusters: 60725
fatStartBlock: 132
fatCount: 2
blocksPerFat: 238
rootDirStart: 608
dataStartBlock: 640

type any character to start


With SDa & UNO :


Code:

SdFat version: 20120719

type any character to start

init time: 2 ms

Card type: SDHC

Manufacturer ID: 0X1B
OEM ID: SM
Product: 00000
Version: 1.0
Serial number: 2330206577
Manufacturing date: 10/2011

cardSize: 61315072 (512 byte blocks)
flashEraseSize: 128 blocks
eraseSingleBlock: true

SD Partition Table
part,boot,type,start,length
1,0X0,0XC,8192,61295848
2,0X0,0X0,0,0
3,0X0,0X0,0,0
4,0X0,0X0,0,0

Volume is FAT32
blocksPerCluster: 64
clusterCount: 957491
freeClusters: 957490
fatStartBlock: 9614
fatCount: 2
blocksPerFat: 7481
rootDirStart: 2
dataStartBlock: 24576

type any character to start


Tomorrow, I'll try with the MEGA
« Last Edit: October 08, 2012, 04:15:48 pm by LibertyCareche » Logged

Quidquid agis, prudenter agas, et respice finem !

Lormaison
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Omnes vulnerant, ultima necat !
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it bad luck ?

First test:
64 MB SD card, 10 years old.
Arduino MEGA under SD.h & CardInfo.
SD card reader (LC studio) on witch one the ground pin of the tension controler 3.3V AMS1117  was not connected to the card ground.
Result :
Negative.

Second test :
Same cards but bug repaired (see pictures above)
Result :
Negative.

Third test :
Exchange SD card for 32GB
Same cards.
Result :
Negative.

Fourth test :
Same cards but with level adaptation 5V MEGA / 3,3V SD card
(See Levels Adaptation Diagram above)(with 1N4148 instead of BAT83 I advocate).
Result :
Negative.

Fifth test :
Exchange SD card for 64MB 10yo
UNO card...
Resultat :
Negative.

Sixth test :
UNO under SDFatLib & SDInfo.
Result :
Negative.
 
Seventh test :
Exchange SD card for 32GB
Result :
 half positive(reporting error codes by the program).

Eighth test :
Exchange SD card for a new 2GB.
Result :
 half positive(reporting error codes by the program).

Ninth test :
exchange 1N4148 (See Levels Adaptation Diagram above) for some BAT83.
Result :
Positive

Tenth test :
Exchange SD card for 32GB.
Result :
Positive

Eleventh test :
Exchange SD card for 64MB.
Result :
Negative.

Twelfth test :

Uno under SD.h  & CardInfo.
Result :
Positive

Thirteenth test :
MEGA under SD.h  & CardInfo OR under SDFatLib & SDInfo.
Result :
Positive


Conclusions :

  • SD cards that was existing before the SD standard completion are not preferred.
  • The cards are sensitive to the shape of the signals.
  • Some "LC studio" card readers have a mass default.


Thank you very much, Fat16Lib and Jean-François for your help.   smiley

« Last Edit: October 09, 2012, 03:03:32 pm by LibertyCareche » Logged

Quidquid agis, prudenter agas, et respice finem !

Nice, France
Offline Offline
Full Member
***
Karma: 11
Posts: 237
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  • Some "LC studio" card readers have a mass default.

Looking at this image and also at the related thread in the French section of the forum, a better English translation of « Certains lecteurs de carte "LC studio" ont un défaut masse » would be “Some "LC studio" card readers have a ground fault”.
Logged

Pages: [1] 2   Go Up
Jump to: