11U24, SDFileSystem not working.

24 Sep 2014

I've trying to get my SD card working with a 11U24 based board.

I have been able to create a directory on the SD card. At least sometimes. This gives a good feeling that the hardware is working.

I'm trying to write a file to the card. The code below never gets past the fopen call. Everything stops.

I've turned on debugging in the SDFileSystem code. I've been able to see the code progress till it gets to the disk_read() function in diskio.cpp.

The card apparently initializes, based on the debug messages.

Anybody using SDFileSystem with this processor?

debug output

Hello World!
open(sdtest.txt) on filesystem [sd], drv [0]
disk_initialize on drv [0]

Init: SDCARD_V2
init card = 2

SDHC Card
hc_c_size: 15199
capacity: 7969177600
sectors: 15564800

disk_read(sector 0, count 1) on drv [0]
disk_read(sector 0)

#include "mbed.h"
#include "mbed_debug.h"
#include "SDFileSystem.h"

/* Serial debug port. */
Serial pc(P1_13, P1_14); // tx, rx

FILE *fp;
SDFileSystem sd(P1_22, P1_21, P1_20, P1_19, "sd"); 
DigitalOut led22(P0_22);
 
int main() {
    pc.printf("Hello World!\r\n");   

    fp = fopen("/sd/sdtest.txt", "w");
    pc.printf("fopen\r\n"); 
    
    if(fp == NULL) {
        pc.printf("Could not open file for write\r\n");
    }
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp); 
 
    pc.printf("Goodbye World!\r\n");

}