7 years, 5 months ago.

SDFileSystem that works with Nucleo-F746ZG

I hooked up an SDcard breakout board to the Nucleo-F746ZG. I tried the example program https://developer.mbed.org/handbook/SDFileSystem

#include "mbed.h"
#include "SDFileSystem.h"
 
SDFileSystem sd(PA_7, PA_6, PA_5, PD_15, "sd"); // mosi, miso, sclk, cs
 
int main() {
    printf("Hello World!\n");   
 
    mkdir("/sd/mydir", 0777);
    
    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
    if(fp == NULL) {
        error("Could not open file for write\n");
    }
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp); 
 
    printf("Goodbye World!\n");
}

I get: Hello World! Could not open file for write

A few years ago, I remember this program worked. What can be the issue?

Kind regards, Jack.

1 Answer

7 years, 1 month ago.

Did you ever solve this problem? I am trying to do almost the same thing using SDFileSystem on a Nucleo-F767ZI. I've tried several different combinations of SPI pins but I always get the same response that it can't open the file. Looking at the contents of the SD card, it isn't making the directory at all.

I've seen some threads from 2+ years ago suggesting that SDFileSystem doesn't work with Nucleo but I'm hoping this has been resolved somehow.

I have used two different versions of SDFileSystem with Nucle STM32F401RE. Can confirm, at one point in time, it worked with that micro. I note that in 5.3 there are changes to the storage libraries. I just tried a quick project in the online compiler and SDFileSystem compiled but would not function for me. I rolled back the mbed library to Aug 2016 release 125 and then the SD card started working. So maybe try using earlier version of mbed os.

posted by Graham S. 17 Mar 2017