STM32 debugging with Texane/ST-Link and VisualGDB

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.

  1. Start Visual Studio. Create a new project by selecting File->New->Project: 01-newproj
  2.  Select VisualGDB -> Embedded Project Wizard.
    Specify project directory and enter project name.
  3. Select “Create a new project” on the first page: 03-newprj
  4. 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:04-device
  5. Continue with the default LEDBlink sample:05-ledblink
  6. 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: 06-texane
  7. 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:07-build
  8. 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:08-debug
  9. 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:09-board
  10. You can always modify various settings for your project by right-clicking on it in Solution Explorer and selecting VisualGDB Project Properties:10-settings

If you prefer using OpenOCD to debug your projects, follow this tutorial to learn more.