ARM Mbed: Difference between revisions
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
<br /> | <br /> | ||
==== Command Line Tools ==== | ==== Command Line Tools ==== | ||
[https://os.mbed.com/docs/mbed-os/v5.13/tools/developing-mbed-cli.html 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 | [https://os.mbed.com/docs/mbed-os/v5.13/tools/developing-mbed-cli.html 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. | ||
<br /> | <br /> | ||
<br /> | <br /> | ||
To | To use the Mbed CLI tools on Ubuntu, install via ''pip'': | ||
<pre class="terminal"> | <pre class="terminal"> | ||
sudo apt install git mercurial | sudo apt install git mercurial | ||
sudo pip3 install mbed-cli | sudo pip3 install mbed-cli | ||
</pre> | </pre> | ||
<br /> | <br /> | ||
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: | |||
<pre class="terminal"> | <pre class="terminal"> | ||
mbed detect | mbed detect | ||
</pre> | </pre> | ||
which prints device information and the version of Mbed OS that can be installed: | |||
which prints device information and | |||
<pre class="terminal"> | <pre class="terminal"> | ||
[mbed] Detected NUCLEO_F411RE, port /dev/ttyACM1, mounted /media/kai/NODE_F411RE, interface version 0221: | [mbed] Detected NUCLEO_F411RE, port /dev/ttyACM1, mounted /media/kai/NODE_F411RE, interface version 0221: | ||
Line 52: | Line 42: | ||
</pre> | </pre> | ||
Note that even Mbed OS 2 is not supported on the STM32F303 Nucleo board because of the Python 3 environment instead of Python 2. | Note that even Mbed OS 2 is not supported on the STM32F303 Nucleo board because of the Python 3 environment instead of Python 2. | ||
<br /> | |||
<br /> | |||
Use ''mbed'' to download Mbed OS sources and generate project skeleton files: | |||
<pre class="terminal"> | |||
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) | |||
</pre> | |||
<br /> | |||
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. | |||
<br /> | |||
<br /> | |||
Also use ''mbed'' to build the project and (optionally) immediately flash to the device: | |||
<pre class="terminal"> | |||
mbed toolchain GCC_ARM | |||
mbed config -G GCC_ARM_PATH <toolchain path>/bin | |||
mbed compile --clean --flash | |||
</pre> | |||
where ''<toolchain path>'' is the installation path of the [https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm 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. | |||
<br /> | |||
<br /> | <br /> |
Latest revision as of 2019-08-06T16:58:26
Introduction
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
Mbed OS is a real-time operating system that comes with the Mbed APIs.
Web IDE
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:
mbed detect
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.