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 list. Your target name most likely matches the board name.
Set the target for the active program from the Explorer view.
If you have an unsupported board, please see the Custom targets page.
Building a program
To build, debug or run an Mbed program:
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 Explorer view and select Set Active Program.
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 list, select Import custom profiles. A window opens. Select a custom profile from any location on your computer.
To remove a custom profile from the Build profile drop-down list 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.
Select a build option:
Build program: Build the program, without flashing it to the device.
Build: Checks the
BUILDsub-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.
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.
The output of the build is displayed in the Output view. To open the view, go the View menu and select Output.
You can turn the auto scrolling on or off by clicking the Turn Auto Scrolling On or Turn Auto Scrolling Off icons.
A completed build.
To copy the output, do a right-click in the Output view and select Copy or Copy All:
- Copy: Copies the line where your cursor is.
- Copy All: Copies the whole output.
Do a right-click in the Output view and select Find to search the content of the output. When the Output view is in focus, you can also go to the Edit menu and select Find.
Click the Clear Output icon to clear the build output or do a right-click and select Clear Output.