Blinky on Arm Mbed CLI

This tutorial builds Blinky using the Arm Mbed CLI, which allows you to build Mbed OS applications on your own machine. You will need to install Mbed CLI and a toolchain before you can work with Blinky.

Quick start video

This video shows how to use Mbed CLI to import and build Blinky. Note that it assumes you have already installed Mbed CLI (see next section):

Watch how to create your first application on Arm Mbed CLI

Installing Mbed CLI and a toolchain

Mbed CLI is an offline tool, meaning you'll have to install it before you can work. You will also need to install a toolchain. Please follow the installation instructions on the Mbed CLI setup page, and come back here when you're done.

Setting context

Whenever you work with Mbed CLI, you need to navigate your command-line terminal to the directory in which you want to work. For example, if your program is in a folder called my_program:

cd my_program

You can then start running Mbed CLI commands, and they will run in the correct context.

Getting Blinky

Mbed CLI can import Blinky, along with the Arm Mbed OS codebase. The import process creates a new directory as a subdirectory of your current context (as explained above).

To import Blinky, from the command-line:

Navigate to a directory of your choice. We're navigating to our development directory:

cd dev_directory

Import the example:

mbed import mbed-os-example-blinky
cd mbed-os-example-blinky

Tip:import requires a full URL to Mercurial or GitHub. If you don't enter a full URL, Mbed CLI prefixes your snippet with https://github.com/ARMmbed/. We took advantage of this feature in our example; import mbed-os-example-blinky is interpreted as https://github.com/ARMmbed/mbed-os-example-blinky.

Blinky is now under dev_directory > mbed-os-example-blinky. You can look at main.cpp to familiarize yourself with the code.

Compiling

Invoke mbed compile, specifying:

Your board: -m <board_name>.

Your toolchain: -t <GCC_ARM, ARM, ARMC6 or IAR>.

For example, for the board K64F and the Arm Compiler 5:

mbed compile -m K64F -t ARM

If you don't know the name of your target board, there are several ways to tell.

Invoke mbed detect, and the Mbed CLI tool displays an output similar to below, where 'K64F' is the name of your target platform and COM3 is the name of the serial port that the platform connects to:

[mbed] Detected "K64F" connected to "D:" and using com port "COM3"

Check the board information page on the list of Mbed Enabled boards. The right side of each information page lists the name of the target.

If you only have one Mbed Enabled board connected, Mbed CLI can automatically detect the target by specifing -m detect.

Your PC may take a few minutes to compile your code. At the end you should get the following result:

Important Information for this Arm website

This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.