MMC card with spi-sd-card.c

Gene Smith gds at chartertn.net
Wed Dec 24 09:03:59 UTC 2008


Sebastian Huber wrote, On 12/23/2008 03:15 AM:
> Sebastian Huber wrote:
>> Gene Smith wrote:
>>> I have been trying to use an MMC with the "spi/sd" drivers in RTEMS. I 
>>> worked until it tries to send two commands in a loop waiting for idle 
>>> conditon in an init routine:
>>>
>>> rv = sd_card_send_command( e, SD_CARD_CMD_APP_CMD, 0);
>>> CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: 
>>> SD_CARD_CMD_APP_CMD");
>>> rv = sd_card_send_command( e, SD_CARD_ACMD_SD_SEND_OP_COND, 0);
>>> CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Send: 
>>> SD_CARD_ACMD_SD_SEND_OP_COND");
>> These commands set the SD Card into SPI mode.
> [...]
> 
> Oh, I guess I misunderstood you.  You want to use a MMC in SPI mode? There are
> several ways to switch from MMC mode to SPI mode.  This one worked for all
> cards I worked with.  We may use the alternatives if one approach fails.
> 

I try to mount using the shell:

mkdir /mnt
mount -t mddos /dev/sd-card-a /mnt
mount: mount failed: Invalid argument

I see no card errors printed with syslog() and see none stepping with 
debugger. Blocks are read with no errors detected.

But error occurs in fat.c when checking the boot record. The bytes per 
sector does not match any in the list and fails here:

381:
     /* Evaluate boot record */
     vol->bps = FAT_GET_BR_BYTES_PER_SECTOR(boot_rec);

     if ( (vol->bps != 512)  &&
          (vol->bps != 1024) &&
          (vol->bps != 2048) &&
          (vol->bps != 4096))
     {
         rtems_disk_release(vol->dd);
         rtems_set_errno_and_return_minus_one( EINVAL );  <---fails here
     }

Also, when I try to format it seems to work:
[/] # msdosfmt -t 16 /dev/sd-card-a
msdos format: /dev/sd-card-a
msdos format successful

But I still can't mount it and when I take the card out and put it on a 
"real" system the files are all still there.

Card was originally fat32 formatted by a camera. Reformated with gparted 
  to fat16 and have same errors.

Haven't tried doing the mount with my own code yet like Bob G did. I 
think shell commands should do the same thing, right?




More information about the users mailing list