ARM Mbed: Difference between revisions

No edit summary
Line 15: Line 15:
<br />
<br />
<br />
<br />
To install the tools on Ubuntu Linux type
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
mbed config -G GCC_ARM_PATH <toolchain path>/bin
</pre>
</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].
<br />
<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:
Use the CLI tool '''mbed''' to 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>
where the name of the target device can be determined by connecting the target board with your Ubuntu computer and typing
<pre class="terminal">
<pre class="terminal">
mbed detect
mbed detect
</pre>
</pre>
which prints device information and whether MbedOS is supported:
which prints device information and the version of Mbed OS that can be installed:
<br />
<br />
Also use ''mbed'' to build the project and (optionally) immediately flash to the device:
<pre class="terminal">
mbed toolchain GCC_ARM
mbed compile --clean --flash
</pre>
<br />
The ''compile'' step may require an older version of the GNU Arm Embedded Toolchain. You can download older versions from the same [https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads download page] as the latest version.
<br />
<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 63: 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 />
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 />

Revision as of 2019-07-24T00:04:09

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)


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.