-
Notifications
You must be signed in to change notification settings - Fork 26
MbedOS configuration
Is good for...
//TODO
(Note: Legacy Mbed configs have a .json extension. Mbed CE moved to .json5 mainly for comment support)
In top level CMakeLists.txt there has to be the line
target_link_libraries(YourApplication mbed-os)
via this line you can switch between full profile mbed-os to mbed-baremetal profile or add components what are not part of that profile in default.
For example USB is component what is not included in full MbedOS profile so you have to add it like this
target_link_libraries(YourApplication mbed-os mbed-usb)
Another example is block devices. These were split out from the main Mbed library, and have to be linked separately. For example, if you need FlashIAPBlockDevice.h, you have to link mbed-storage-flashiap, like this:
target_link_libraries(YourApplication mbed-os mbed-storage-flashiap)
-
mbed-usbcontains majority of USB functionality (can be also manually enabled in baremetal profile) -
mbed-usb-msdprovides USBMSD.h (USB Mass Storage Device support) -
mbed-usb-cdc-ecmprovides USBCDC_ECM.h (Simulated USB Ethernet adapter support) (RTOS required, not compatible with baremetal)
-
mbed-netsocketwill pull in the default network stack and socket libraries. Refer to this doc page for more information about Mbed's network stack options.
-
mbed-storage(can be also manually enabled in baremetal profile) -
mbed-storage-blockdeviceprovides non-driver-related block device headers -
mbed-storage-dataflashprovides DataFlashBlockDevice.h (Block device for DataFlash interface SPI flashes) -
mbed-storage-flashiapprovides FlashIAPBlockDevice.h (Block device which uses MCU flash as storage) -
mbed-storage-i2ceeprovides I2CEEBlockDevice.h (Block device for I2C EEPROMs) -
mbed-storage-ospifprovides OSPIFBlockDevice.h (Block device for octal SPI SFDP flashes) -
mbed-storage-qspifprovides QSPIFBlockDevice.h (Block device for quad SPI SFDP flashes) -
mbed-storage-spifprovides SPIFBlockDevice.h (Block device for regular SPI SFDP flashes) -
mbed-storage-sdprovides SDBlockDevice.h (Block device for (micro)SD/SDHC cards). Now supports asynchronous (DMA) SPI in Mbed CE! -
mbed-storage-spinandprovides SPINANDBlockDevice.h (block device for QSPI NAND flashes).
*Note: Currently, all of the driver block devices require their matching COMPONENT to be enabled for your target. Out of the box, this will only be true if the chip's dev board actually has that component; e.g. only dev boards with an SD card slot will enable COMPONENT_SD and make the mbed-storage-sd target available.
To change this, you will need to add a line like the following to your target_overrides in mbed_app.json:
"target.components_add" : ["DATAFLASH", "FLASHIAP", "SD"],This will enable the component and activate the matching library.
TODO: file system block devices, KVStore
mbed-mbedtls
//TODO
If you need to make a library within your own code, you can use CMake's add_library() command. This library can then be linked to multiple different applications, and the code inside only gets compiled once.
Example:
add_library(SomeLibrary STATIC LibSource1.cpp LibSource2.cpp)
target_link_libraries(SomeLibrary PUBLIC mbed-core-flags) # This is needed so that the library can access Mbed includes
target_include_directories(SomeLibrary INTERFACE .)
add_executable(MyMbedOSExe)
target_link_libraries(MyMbedOSExe SomeLibrary mbed-os)
mbed_set_post_build(MyMbedOSExe)
# another alternative for bare metal profile
add_executable(MyMbedBaremetalExe)
target_link_libraries(MyMbedBaremetalExee SomeLibrary mbed-baremetal)
mbed_set_post_build(MyMbedBaremetalExe)Note that the library is linked to mbed-core-flags, not mbed-os. This is a limitation of CMake object libraries; only the executable should be linked to mbed-os, NOT the libraries. Note that if the library needs to use RTOS features, it should like to mbed-rtos-flags as well to get access to the RTOS.