Mbed OS 5 bare-metal with SD support and FATFileSystem

Heya,

I’m using the example from Zoltan Hudak: SDCard - Example of using SD card with Mbed OS5. | Mbed
It’s working but the build is really slow (even slower on my desktop when I’m using PlatformIO)

I’m using online mbed IDE with the board DISCO F469 for all these tests, mbed os 5.15.5.

To fix this problem, bare-metal profile with support for SD card + FAT filesystem (or littlefs) should be the solution.

1 - I tried adding the bare-metal to the following in mbed_app.json:

{
    "requires": [ "bare-metal" ],
    "target_overrides": {
        "*": { "target.components_add": [ "SD" ] }
    }
}

but this produce fatal error: ‘FATFileSystem.h’ file not found #include “FATFileSystem.h”

2 - I tried changing #include “FATFileSystem.h” to #include “fat/FATFileSystem.h” with the following mbed_app.json

{
    "requires": [
        "bare-metal"
    ],
    "target_overrides": {
        "*": {
            "target.components_add": [ "SD" ],
            "target.features_add": [ "filesystem", "fat_chan" ]
        }
    }
}

but this produces Error: Use of undeclared identifier ‘MBED_CONF_FAT_CHAN_FF_MAX_SS’ in “extras/mbed-os.lib/features/storage/filesystem/fat/ChaN/ff.h”, Line: 130, Col: 11
target.features_add seems to be not working here.

3 - I tried this mbed_app.json

{
    "requires": [
        "bare-metal",
        "filesystem",
        "fat_chan"
    ],
    "target_overrides": {
        "*": {
            "target.components_add": [
                "sd"
            ]
        }
    }
}

but now i got Error: /src/main.cpp:8:10: fatal error: ‘SDBlockDevice.h’ file not found #include “SDBlockDevice.h”

Thanks for the help!

Ahoj,

just try

{
    "requires": [ "bare-metal", "sd"],
    "target_overrides": {
        "*": { "target.components_add": [ "SD" ] }
    }
}

Edit:
Ah , I forgot the FATFileSystem, the settings from above is only for the SDBlockDevice.

{
    "requires": [ "bare-metal","sd","filesystem","fat_chan"],
    "target_overrides": {
        "*": { "target.components_add": [ "SD" ] }
    }
}

BR, Jan

1 Like

Yay you solved it :smiley:
I just needed to add rtos-api as sd was dependant.

{
    "requires": [ "bare-metal", "rtos-api", "sd","filesystem","fat_chan"],
    "target_overrides": {
        "*": { "target.components_add": [ "SD" ] }
    }
}

Thank you so much JohnnyK !