SDBlockDevice.h: No such file or directory

Hello everyone, I am using Mbed NXP LPC1768 device and my ide is Visual Studio Code with platformio extension. I want to write data to sd card which is imported on LPC1768. I have tried with with SPI pins and SDBlockDevice library. But when i builded the code then a error occurs. My mbed version is

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: NXP LPC (9.2.0) > NXP mbed LPC1768
HARDWARE: LPC1768 96MHz, 64KB RAM, 512KB Flash
DEBUG: Current (cmsis-dap) On-board (cmsis-dap) External (blackmagic, jlink)
PACKAGES:

  • framework-mbed @ 6.60900.220911 (6.9.0)
  • toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
    Collecting mbed sources…
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Compiling .pio\build\lpc1768\src\main.o
    src\main.cpp:2:10: fatal error: SDBlockDevice.h: No such file or directory

  • Looking for SDBlockDevice.h dependency? Check our library registry!
  • CLI > platformio lib search “header:SDBlockDevice.h”
  • Web > PlatformIO Registry

2 | #include "SDBlockDevice.h"
  |          ^~~~~~~~~~~~~~~~~

compilation terminated.
*** [.pio\build\lpc1768\src\main.o] Error 1

image


It is an example code. Details are not important.

Thank you!

Hello Metehan,

Only the mbed boards equipped with onboard SD card slot use the SD card driver library automatically. For the others you have to instruct mbed to do so in an mbed_app.json file placed in the root directory of your project.

For example,

mbed_app.json:

{
    "target_overrides": {
        "LPC1768": {
            "target.components_add": ["SD"],
            "sd.SPI_MOSI": "p5",
            "sd.SPI_MISO": "p6",
            "sd.SPI_CLK": "p7",
            "sd.SPI_CS": "p8",
            "sd.INIT_FREQUENCY": 160000
        }
    }
}

Thank you sir. But I have a lot of questions too.
1- I guess that project which Platform.io extension create have not mbed_app.json file.

after that I created new project with “mbed new” command on terminal and I copy and pasted missing files like that.

I don’t know is it a good way but I have not find a another way.

2- Which library I should use after I edited the mbed_app.json file ?

Thank you!

I don’t think you have to copy and paste any missing files to a new project. All you need is to create a new “mbed_app.json” file in the root directory of your project using your favorite text editor and copy and paste the content I provided above into it.

1 Like