9 months, 1 week ago.

SDBlockDevice does not work with mbed 5.10 and FRDM-K64F

SDBlockDevice example application

#include "mbed.h"
#include "SDBlockDevice.h"

SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);   // FRDM-K64F, micro SD card

uint8_t block[512] = "Hello World!\n";

int main()
    // call the SDBlockDevice instance initialisation method.
    if ( 0 != sd.init()) {
        printf("Init failed \n");
        return -1;
    printf("sd size: %llu\n",         sd.size());
    printf("sd read size: %llu\n",    sd.get_read_size());
    printf("sd program size: %llu\n", sd.get_program_size());
    printf("sd erase size: %llu\n",   sd.get_erase_size());

    // set the frequency
    if ( 0 != sd.frequency(5000000)) {
        printf("Error setting frequency \n");
    if ( 0 != sd.erase(0, sd.get_erase_size())) {
        printf("Error Erasing block \n");
    // Write some the data block to the device
    if ( 0 == sd.program(block, 0, 512)) {
        // read the data block from the device
        if ( 0 ==, 0, 512)) {
            // print the contents of the block
            printf("%s", block);
    // call the SDBlockDevice instance de-initialisation method.

// mbed os 5.9.5 Success!
// mbed os 5.10.0 Error: Library name 'sd' not unique (defined in /tmp/...)
Comment on this question

2 Answers

9 months, 1 week ago.

Since Mbed OS 5.10 the SD driver is part of the OS, so delete 'sd-driver' from your project.

Thanks Jan, your reply was very useful

posted by Nikolai Zimfer 11 Oct 2018

Jan, then how should we use the sd function in the main app?

posted by Banchao Shu 04 Jan 2019

Same as before, you just don't need to manually include the sd-driver library anymore.

posted by Jan Jongboom 05 Jan 2019

The error shows: there is no such file or Directory, #include SDBlockDevice.h after deleting the sd-driver. Working on Mbed 5.11.

posted by Banchao Shu 07 Jan 2019

Interesting, it seems to have moved into a separate component. Add a section to your mbed_app.json like in this example to include the component.

posted by Jan Jongboom 08 Jan 2019
9 months, 1 week ago.

Hi Nikolai,

You will need to add the SD driver present within Mbed OS as a component to the K64F, instructions for using the new configuration can be found here:

Please let me know if you have any questions!

- Jenny, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

Thanks Jenny, I use the online compiler and the K64F platform. In this case, the compiler should automatically select the configuration parameters for the K64F and integrate them into a binary file.

posted by Nikolai Zimfer 11 Oct 2018