Visual Studio Code
This document explains how to build and debug Arm Mbed OS applications using Visual Studio Code. Before starting, first configure your local debug toolchain.
Installing Visual Studio Code
You need to install Visual Studio Code with the C/C++ extensions to begin.
Install Visual Studio Code.
Open Visual Studio Code, and click on the Extensions button.
Search for the C/C++ plugin (by Microsoft) and click Install.
Installing the C/C++ plugin in Visual Studio Code
When prompted, restart the IDE.
Exporting a project
To export your project to Visual Studio Code, you can use either the Online Compiler or Arm Mbed CLI.
Right click on your project.
Select Export Program....
Under Export toolchain, select Visual Studio Code (GCC ARM).
Tip: For most targets, you can also export to IAR or ARMCC.
Click Export, and unpack at a convenient location.
Exporting to Visual Studio Code
Arm Mbed CLI
In your project folder, run:
# alternatively, use -i vscode_armc5 for ARMCC, or -i vscode_iar for IAR # replace K64F with your target board $ mbed export -i vscode_gcc_arm -m K64F --profile mbed-os/tools/profiles/debug.json
Configuring the debugger
To configure the debugger for your project:
Open the folder in Visual Studio Code.
If you're using pyOCD as your debug server, verify that
debugServerPathis set to the location of
If you're using OpenOCD as your debug server:
debugServerPathto point to the location of
debugServerArgsto include your OpenOCD arguments. For more info, read our toolchain document.
Configuring the debugger
Note: If you installed the GNU Arm Embedded Toolchain in a nondefault location (for example, through the Arm Mbed CLI installer), you need to update the
MIDebuggerPath to the full path of your copy of
arm-none-eabi-gdb. To find the new path, open a terminal, and run
where arm-none-eabi-gdb (Windows) or
which arm-none-eabi-gdb (macOS and Linux).
Debugging your project
On the Debug tab, click the Play icon.
Starting the debug session
The project builds, and debugging starts when the build succeeds.
To see warnings or errors, select View > Problems.
Click on the Debug Console button to see the debug output (this is not activated automatically).
Running the debugger
Tip: You can use the Debug Console to interact with the device over GDB and use functionality the UI does not expose. For example, to see the registers, type
-exec info registers. To put a watch on a memory location, type
-exec watch *0xdeadbeef.