Mbed (official website) is a collection of APIs which simplify software development for microcontrollers with ARM Cortex kernel. Mbed is maintained by ARM, in cooperation with their partners.
Mbed OS is a real-time operating system that comes with the Mbed APIs.
The web IDE is the most convenient of getting started with the Mbed API and Mbed OS. You can generate a blank Mbed project or a project based on one of the many example projects. You can build the project on the Web IDE and download the resulting binary. You can also download the complete source package as an archive file (ZIP file) with project file stubs for the popular embedded software development environments.
Command Line Tools
Mbed CLI is a collection of command line tools for generating Mbed project stubs in the same way that the Web IDE does. With the command line tools you can create a script that fetches the Mbed OS part and places it in a shared location, then create project stubs with the sources relevant to a specific application.
To use the Mbed CLI tools on Ubuntu, install via pip:
sudo apt install git mercurial sudo pip3 install mbed-cli
You can now use the mbed tool work with Mbed OS sources and projects that use it. First of all, you can query the Mbed devices (boards or modules) that are connected to your computer:
which prints device information and the version of Mbed OS that can be installed:
[mbed] Detected NUCLEO_F411RE, port /dev/ttyACM1, mounted /media/kai/NODE_F411RE, interface version 0221: [mbed] Supported toolchains for NUCLEO_F411RE | Target | mbed OS 2 | mbed OS 5 | ARM | uARM | GCC_ARM | IAR | ARMC5 | |---------------|-----------|-----------|-----------|-----------|-----------|-----------|-------| | NUCLEO_F411RE | Supported | Supported | Supported | Supported | Supported | Supported | - | Supported targets: 1 Supported toolchains: 4 [mbed] Detected NUCLEO_F303K8, port /dev/ttyACM0, mounted /media/kai/NODE_F303K8, interface version 0221: [mbed] Supported toolchains for NUCLEO_F303K8 | Target | mbed OS 2 | mbed OS 5 | ARM | uARM | GCC_ARM | IAR | ARMC5 | |--------|-----------|-----------|-----|------|---------|-----|-------| Supported targets: 0
Note that even Mbed OS 2 is not supported on the STM32F303 Nucleo board because of the Python 3 environment instead of Python 2.
Use mbed to download Mbed OS sources and generate project skeleton files:
mbed import mbed-os-latest # fetches the latest Mbed OS from GitHub mbed config -G MBED_OS_DIR ./mbed-os-latest # makes projects use the downloaded Mbed OS source mbed new --scm git mbed-test # generates new project files with a Git repository cd mbed-test # next commands require that the current working directory is the project root mbed target NUCLEO_F303K8 # sets the target device (the Nucleo-32 board STM32F303K8T6)
The mbed tool uses the configuration information found in the files mbed_lib.json and mbed_app.json to generate the C header file mbed_config.h that contains preprocessor macros which enable the desired Mbed OS features.
Also use mbed to build the project and (optionally) immediately flash to the device:
mbed toolchain GCC_ARM mbed config -G GCC_ARM_PATH <toolchain path>/bin mbed compile --clean --flash
where <toolchain path> is the installation path of the GNU Arm Embedded Toolchain for Cortex M architecture. The compile step may require an older version of the GNU Arm Embedded Toolchain. You can find older versions on the same download page.