Compiling the code
-
When Mbed CLI is installed, get the code for the Mbed OS full profile or bare metal profile.
Open a command-line shell.
For the full profile, enter:
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky $ cd mbed-os-example-blinkyFor the bare metal profile, enter:
$ mbed import https://github.com/ARMmbed/mbed-os-example-blinky-baremetal $ cd mbed-os-example-blinky-baremetalThe rest of the workflow is identical for both profiles.
-
Compile and program your board:
Invoke
mbed compile, and specify the name of your build target and your installed toolchain (GCC_ARM,ARM,IAR). For example, for the K64F board and ARM toolchain:$ mbed compile --target K64F --toolchain ARM --flashThe
--flashargument automatically flashes the compiled program onto your board if it is connected to your computer.Tip: You can get the name of the board plugged into your computer by running
mbed detect, and you can get a full list of supported toolchains and targets by running thembed compile --supportedcommand.Note: To build with the Mbed OS bare metal profile, add
"requires": ["bare-metal"]to thembed_app.jsonfile:{ "requires": ["bare-metal"], "target_overrides": { "*": { -
Press the board's reset button. The LED blinks.