Arm Mbed OS support forum

USBMSD SDBlockDevice example over LPC1768

Hi everyone,
I am trying to compile USBMSD SDBlockDevice example and using a custom board for LPC1768. I am using MBED Studio 1.3.1 with mbed-os 6.6.0 in windows 10 with the target set to “mbed LPC1768”, build profile in “Debug” and the code what I am implementing is the next:

/*

  • Copyright © 2006-2020 Arm Limited and affiliates.
  • SPDX-License-Identifier: Apache-2.0
    */
    #include “mbed.h”
    #include “SDBlockDevice.h”
    #include “USBMSD.h”

SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
USBMSD usb(&sd);

int main()
{
while (true) {
usb.process();
}
return 0;
}

When I build the program i get in the output the next error:

Building project USBMSD_SDBlockDevice_Example (LPC1768, ARMC6)
Scan: USBMSD_SDBlockDevice_Example
Compile [100.0%]: main.cpp
[Fatal Error] main.cpp@6,10: ‘SDBlockDevice.h’ file not found
[ERROR] .\main.cpp:6:10: fatal error: ‘SDBlockDevice.h’ file not found
#include “SDBlockDevice.h”
^~~~~~~~~~~~~~~~~
1 error generated.

How i can solve this problem? Also when i change #include “SDBlockDevice.h” by #include “mbed-os\storage\blockdevice\COMPONENT_SD\include\SD\SDBlockDevice.h”

I get the next errors:
Building project USBMSD_SDBlockDevice_Example (LPC1768, ARMC6)
Scan: USBMSD_SDBlockDevice_Example
Compile [100.0%]: main.cpp
[Error] main.cpp@9,18: unknown type name ‘PTE3’
[Error] main.cpp@9,24: unknown type name ‘PTE1’
[Error] main.cpp@9,30: unknown type name ‘PTE2’
[Error] main.cpp@9,36: unknown type name ‘PTE4’
[ERROR] .\main.cpp:9:18: error: unknown type name ‘PTE3’
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
^
.\main.cpp:9:24: error: unknown type name ‘PTE1’
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
^
.\main.cpp:9:30: error: unknown type name ‘PTE2’
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
^
.\main.cpp:9:36: error: unknown type name ‘PTE4’
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
^
4 errors generated.

How i must proceed with these errors?
Many thanks for your help

Best Regards

Hello,

In the SDBlockDevice | Mbed OS 6 Documentation second point is

Add the SD component to mbed_app.json:

“target.components_add” : [“SD”],

So create mbed_app.json in the project folder, if you do not have it, and place this inside.

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

The rest errors are bad pin names probably. The mbed LPC1768 not contain pin names PTE1-4, that seems to be pin names from FRDM-K64F (The USBMSD was made for that board). So you must replace them with correct SPI pins - maybe p5-8.

BR. Jan

1 Like

thanks for your reply @JohnnyK :slightly_smiling_face:, your solution works very well for me. Only a detail, you missed one “}” in the JSON but now i can continue working in my project.

Best Regards