Mistake on this page? Email us

Building and running a program

Selecting a build target

Mbed OS is designed to work on multiple development boards, but each individual build of Mbed OS must match the exact board the binary will be flashed to. This match is known as the target or build target.

To select a target, you can:

  • Connect your board to your computer. Mbed Studio detects the board and suggests a matching target.
  • Use the Target drop-down. Your target name most likely matches the board name.

Set the target for the active program from the files pane.

If you have an unsupported board, please see the Custom targets page.

Building a program

To build, debug or run an Mbed program:

  1. Ensure the program you want to build or run is set to active.

    To make the program active, right-click the program name in the files pane and select Set Active Program.

  2. By default, Mbed Studio uses the Debug build profile.

    • To use the Develop or Release profiles, select them from the Build profile drop-down list or right-click the program and select Set Build Profile.

    • To select a custom profile, from the Build profile drop-down, select Import custom profile. The Custom profile selection window opens. Select a custom profile from any location on your computer.

    To remove a custom profile from the Build profile drop-down for the active program, you must delete or rename the custom profile file.

    For more information about Mbed OS build profiles, see Build profiles on the Mbed OS documentation site. Note, in particular, the effect build profiles have on the device entering sleep.

  3. Select a build option:

    • Build program: Build the program, without flashing it to the device.

      • Build: Checks the BUILD sub-directory (where the previous build is stored) and optimises build time by using as much as it can from the last build. For example, if two consecutive builds are for the same target and using the same build profile, the build will rebuild only the files that actively changed between the two builds, or from the point at which you stopped the previous build attempt.

      • Clean build: Ignore all previous builds. A clean build is slower than reusing a previous build, but guarantees your build will have no old artefacts.

    • Debug program: Build the program and flash it to the device, then start a debug session.

    For more information about debug, see Debugging with Mbed Studio.

    • Run program: Build the program and flash it to the device, without starting a debug session.

    A completed build

Note: Mbed Studio uses pyOCD to communicate with the connected platform. If you attempt to run a program on a platform with a DAPLink version that is not supported by pyOCD, it will fail with exit code 1. We are still adding support for pyOCD and more platforms will be available over time.

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.