This tutorial shows how to debug your embedded STM32 firmware using the ST-Link hardware debugger, the texane/st-link tool and Visual Studio with VisualGDB.
Before proceeding with the tutorial please ensure that VisualGDB 4.0 or later is installed.
- Start Visual Studio. Create a new project by selecting File->New->Project:
- Select VisualGDB -> Embedded Project Wizard.
Specify project directory and enter project name.
- Select “Create a new project” on the first page:
- Select the arm-eabi toolchain. If you don’t have it installed, VisualGDB will download and install it automatically. Click “download support for more devices” and select your STM32 device from the list:
- Continue with the default LEDBlink sample:
- If you are running the wizard for the first time, click “install support for additional debug methods”. Otherwise simply select “Texane ST-Link” from the list:
- Press “Finish”. VisualGDB will generate a sample project for the selected STM32 device. Select Build->Build Solution or press Ctrl-Shift-B to build it:
- Connect your ST-Link debugger via USB. Ensure that you have the drivers installed. Put a breakpoint somewhere in the code and press F5 to start debugging:
- Once the breakpoint is hit, press F10 to step over the line. Notice how the LED turns on and off when you step over the lines containing GPIO_WriteBit() calls:
- You can always modify various settings for your project by right-clicking on it in Solution Explorer and selecting VisualGDB Project Properties: