Mistake on this page? Email us

Building and running a program

Mbed OS supports over 150 boards and modules containing Arm microcontrollers. Mbed OS provides an abstraction layer, so that you can use the same code on multiple boards and modules, provided the hardware includes the functionality called by the program. This means you can use the same program for a range of Mbed-compatible platforms.

With Mbed Studio, you build your program for a selected platform. If your platform is connected to your computer over USB, you can also run the program on the platform and debug it.

To build 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. The currently selected platform for the active program is displayed at the top of the files pane. To change the target platform, click the current platform and select a new one from the list, or connect the platform to your computer by USB and switch to the connected platform when prompted.

    Note: You can add a target to the drop-down list by updating the target in the targets.json file, as described in Adding and configuring targets. The targets.json file is located in the mbed-os/targets folder of your program.

    The platform for the active program is displayed in the files pane.

  3. By default, the Debug build profile is applied. To use the Develop or Release, select a profile 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 and enables you to select a custom profile from any location on your computer. The custom profile can be applied to the active program.

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

    For more information about Mbed OS build profiles, see Build profiles. See also Configuring Mbed OS build tools and profiles.

  4. Click the relevant option: Build program, Run program or Debug program. The output is displayed in the Output tab.

    • The built binary is added to the BUILD sub-directory inside the program directory.
    • If you choose Build program, Mbed Studio only builds your program. You can use the Clean build option in the drop-down to clean the previous build and rebuild your program faster.
    • If you choose Run program, Mbed Studio builds and runs your program.

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

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.