[En-Nut-Discussion] SDCARD Interfacing with SAM7X

Tim DeBaillie debaillie at ciholas.com
Thu Mar 1 18:51:47 CET 2007


On Tue, 20 Feb 2007, ennut at thezachariasgroup.com wrote:

> How big is your SDCARD? I found the largest card the OS will
> accept is 512 Meg.
> My 1 Gig card did not work in the system.

I've tried two 512MB (SanDisk and PNY) and a 256MB (SanDisk).

> All cards I've used work right out of the package.

None have worked for me.

Here is my code:

~~code~~
#include <dev/spimmc_at91.h>
#include <fs/phatfs.h>
#include "headers.h" //includes globals, other includes, etc.

#define MY_FSDEV devPhat0
#define MY_FSDEV_NAME "PHAT0"

#define MY_BLKDEV devAt91SpiMmc0
#define MY_BLKDEV_NAME "MMCO"

FILE * MMC_stream;

int main(void){

   u_long baud = 115200;

    //register the serial console
    NutRegisterDevice(&DEV_UART, 0, 0);
    uart = fopen(DEV_UART_NAME, "r+");
    _ioctl(_fileno(uart), UART_SETSPEED, &baud);

    //register our device for the filesystem
    NutRegisterDevice(&MY_FSDEV, 0, 0);

    //Register SDMMC Card Block Device
    fprintf(uart, "\r\n\nRegistering block device '" MY_BLKDEV_NAME 
"'...");
    if(NutRegisterDevice(&MY_BLKDEV, 0, 0)){
       fprintf(uart, "FAILED\r\n");
       for(;;);
    }
    fprintf(uart, "OK\r\n");

    //Mount the SD Card Partition
    fprintf(uart, "Mounting block device '" MY_BLKDEV_NAME ":1/" 
MY_FSDEV_NAME "'...");
    if(_open(MY_BLKDEV_NAME ":1/" MY_FSDEV_NAME, _O_RDWR | _O_BINARY) == 
-1){
       fprintf(uart, "FAILED\r\n");
       for(;;);
    }
    fprintf(uart,"OK\r\n");

    for(;;){
       NutThreadYield();
    }

}
~~end code~~

It consistently prints the following, no matter which card I use:

Registering block device 'MMCO'...OK
Mounting block device 'MMCO:1/PHAT0'...FAILED


I have tried formatting in XP with FAT and FAT32.  I have also tried 
OnBelay format (which appears to be the same as Windows format).  I don't 
have my vfat utilities installed in linux currently.

Just a reminder, I am trying this on a AT91SAM7X Dev Board, no 
modifications.

Any help is appreciated...

Tim




More information about the En-Nut-Discussion mailing list