Brief Summary
This article introduces debugging support for ARM GCC cross compilation in Visual Studio 2017, starting with version 15.6 Preview 2. It details how to configure debugging symbols, set up the launch configuration in Visual Studio, and use OpenOCD with an ST Nucleo-F411RE board as an example. The guide covers editing makefiles, creating and modifying the launch.vs.json file, and launching the debugging session.
- Adding debugging symbols to GCC projects.
- Configuring Visual Studio for debugging embedded ARM applications.
- Using OpenOCD for hardware debugging.
Adding Debugging Symbols
To enable debugging, it's crucial to ensure that your output includes debugging symbols. For GCC projects exported from the ARM online compiler, this involves editing the makefile. Under the tools and flags section, add the -g
flag to both the GCC and G++ commands. This ensures that the compiled binary contains the necessary information for debugging.
Configuring Launch Settings in Visual Studio
After building your binary and flashing the device, right-click on the binary output and select "Debug and Launch Settings." In the dialog, choose "C/C++ Debug microcontroller," which generates a launch.vs.json
file. This file contains various options relevant for embedded debugging, which need to be configured based on your specific board, hardware debugger, and associated software providing a gdbserver interface.
Modifying the launch.vs.json File
The launch.vs.json
file requires several modifications to align with your debugging environment. First, update the "program" field to point to your .elf file. Next, specify the full path to arm-none-eabi-gdb.exe
in the "miDebuggerPath" field. In the "setupCommands" section, adjust the symbol load command to reference your .elf file. Additional commands, such as "monitor reset halt" and "monitor reset init," can be added to properly initialize the board for debugging. Ensure the "miDebuggerServerAddress" matches the location provided by your hardware debugger, with "localhost:3333" being the default for OpenOCD.
Configuring Hardware Debugger Interface
If you prefer Visual Studio to launch the software interfacing with your hardware debugger, specify the path to the debugger executable in "debugServerPath" and its arguments in "debugServerArgs." For OpenOCD, this involves providing the path to openocd.exe
and the appropriate configuration file. Verify the configuration by manually running the command to ensure the correct config file is used and that the server startup validation text is accurate.
Starting the Debugging Session
With the launch.vs.json
file configured, press F5 to initiate the debugging session. Visual Studio will then start debugging your embedded ARM application on your device.
Next Steps and Feedback
To get started, download the Visual Studio 2017 Preview, install the Linux C++ Workload, and select the option for Embedded and IoT Development. Microsoft is actively working on enhancing support for embedded scenarios and encourages users to provide feedback via the GitHub issue list or directly via email at [email protected].