Passionate about technology, people, new places and especially the possibilities of the future – here you will find the musings and antics of Jason Blackman (blckmn).

Setting up VisualGDB for building Betaflight

VisualGDB is a powerful embedded add on for Visual Studio for developing for micro-controllers such as the ARM based STM32 series from ST Microelectronics. This post shows how to setup your environment for building the popular Cleanflight, Betaflight or Raceflight flight controller firmware for multi-rotors. Once setup building and debugging software for these micro-controllers gains all the powerful features of Visual Studio.

Getting Started:

Please take note of the paths provided for files. These will almost certainly differ for your installation – the paths provided in images etc are only for reference to assist you in finding the paths on your development environment.

Make sure that you can actually make the target using the command line (outside of VisualGDB). A good place to start is the Cleanflight wiki:

You should ensure your build chain, and Cygwin binaries are in the path – you can ignore the path information in the Cleanflight instructions. I use the build chain described in the Cleanflight build wiki, but it is possible the SysGCC build chain will work (though I have not tested it).

Rather than set PATH system wide, just do it in the command you are executing – otherwise Cygwin will take over all sorts of windows functions and utilities:

> set PATH=c:\cygwin\bin;D:\dev\gcc-arm\bin;%PATH%
> make TARGET=BLUEJAYF4

Ensure that the above builds successfully before trying to setup VisualGDB. If you can’t get this to work in a standard command prompt in Windows, try doing it within the Cygwin Terminal window to ensure it is working there.

Creating a project:

On the next screen you will need to locate your third party tool chain – if using the setup from clean flight then you will need to find the bin folder that contains the file: arm-none-eabi-gdb.exe.

Once you have done that you will need to also select the device you will be debugging. For most F4 targets that will be a STM32F405RG.

You can safely ignore any build chain errors when you click next at the point above.

Import preserving the directory structure was my preference.

In the Build / Debug page make sure you select the “I don’t know the main executable yet” option. This will be set by hand later.

You can pretty much skip through the remainder, and configure it from the project settings (Visual GDB project settings – by right clicking on the project in explorer).

Setting up the project settings is described below.

Visual GDB Setup:

If your environment has a “Embedded settings” tab. Make sure you have ticked off all the included device libraries (HAL etc). These are not required, as they are in the various FC firmware repositories. The include paths to these files will be specified shortly.

Build Settings:

The most important part. Make sure you set the binary (ELF file) and build directory.

To set these you select “Customize” (for both build and clean commands).

Build Command:

Clean Command:

You will notice for BOTH of these I am using extra variables in the PATH for the additional environment setting. This is required to ensure the Cygwin make and find are used, along with the build chain.

Debug Settings:

I found I had to set the ST-link configuration (the default file is adequate, just needs to be specified), the target file (default file contents is fine), speed, and a few of the other settings as above.

Intellisense Settings:

Note the included directories (add local). These are the paths specified in the Makefile but because we aren’t parsing the Makefile we need to specify them here.

Also the –D command line parameters for clang are the defines that would have been set in the make file.

Path Mapping:

Make sure it is the c:/dir/file.c setting. No need for anything else to be set.

GDB settings:

Pretty much the default here.

GDB Startup commands:

None required. Leave as the default (empty).

Voila

You should now be able to build your project (ctrl-shift-b), Intellisense should work, and you should be able to set break points.

Hi there just wanted to give you a quick heads up. The text in your content
seem to be running off the screen in Firefox.
I’m not sure if this is a format issue or something to do with web browser compatibility but I
figured I’d post to let you know. The design look
great though! Hope you get the problem fixed soon. Many thanks