6 years, 1 month ago.

SDBlockDevice does not work with mbed 5.10 and FRDM-K64F

SDBlockDevice example application

// https://os.mbed.com/docs/v5.10/apis/sdblockdevice.html
// https://github.com/ARMmbed/sd-driver/
#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 == sd.read(block, 0, 512)) {
            // print the contents of the block
            printf("%s", block);
        }
    }
    // call the SDBlockDevice instance de-initialisation method.
    sd.deinit();

    printf("mbed os %d.%d.%d\r\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
}
// mbed os 5.9.5 Success!
// mbed os 5.10.0 Error: Library name 'sd' not unique (defined in /tmp/...)

2 Answers

6 years, 1 month ago.

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

Accepted Answer

Thanks Jan, your reply was very useful

posted by Nikolai Zimfer 11 Oct 2018

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

posted by Jan Jongboom 05 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

Hi Jan I have the same problem, using mbed LPC1768 in the online IDE. I have no idea what you mean when you say sd-driver. There is no such file. All I have is my main.cpp (with the same code almost as above), and the standard "mbed" folder. Please advise what will fix the problem

posted by Rory Hand 16 Sep 2019
6 years, 1 month 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: https://os.mbed.com/docs/v5.10/reference/configuration-storage.html#configuring-components

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