Arm Mbed OS support forum

SDFileSytem library for Mbed Studio OS 6

When I compile/build a program under OS 6 for a SD card functionality, I get errors.
[Error] DirHandle.h@64,13: unknown type name ‘ssize_t’; did you mean ‘size_t’?
[Error] DirHandle.h@77,23: unknown type name ‘off_t’
[Error] DirHandle.h@83,13: unknown type name ‘off_t’
[Error] DirHandle.h@95,9: unknown type name ‘off_t’
[Error] DirHandle.h@97,34: allocation of incomplete type ‘struct dirent’

The SDFileSystem library I used is downloaded from mbed site. This library when used with OS 2 (now deprecated) compile fine in on-line compiler. Which SDFileSystem library version will work with OS 6 ? Any advise/clue is welcome.

Hello Glennon,

Mbed OS 6 supports the FATFileSystem and the LittleFileSystem rather than the SDFileSystem. To use an SD card as storage device a pointer to an SDBlockDevice object shall be passed in the constructor of the selected file system. You can find an example here.

Best regards, Zoltan

1 Like

Hi Zoltan,

Thanks for the update. I will try it out.

Best Regards
Glennon

Hi Zoltan,

In my program under Mbed OS 6, #include SDBlockDevice.h is not recognized, but #include BlockDevice.h is recognized ok. Think I need to modify a JSON file (mbed_lib.json ?) to activate the SD card feature. Also the ‘usual’ mbed_app.json file is non-existent. Appreciate your advise. Thanks.

Hello Glennon,

The “SD” component (and the associated library) is automatically included only for mbed boards equipped with an SD card slot. For the other targets we have to include it via an mbed_app.json configuration file. If there is no such file in your project yet then create one by yourself (New file …) and add the “SD” component as follows:

{
    "target_overrides": {
        "*": {
            "target.components_add": ["SD"]
        }
    }
}

Best regards, Zoltan

Many thanks Zoltan. The SD component is up & running !

Best Regards, Glennon