Debugging STM32 from QtCreator

4 Jul

In a previous post it was already shown how to setup Eclipse for debugging STM32 applications. However, since I’m a big fan of QtCreator IDE, I figured out how to set it up in this as well. This does not mean you can use Qt code for developing your application! We’re only using the IDE.


You’ll need the following software:

  • QtCreator
  • OpenOCD
  • arm-none-eabi-gcc toolchain
  • Python2.7 for i386

I am running this on Linux Mint 17.1, but it should be similar for other Linux distributions or versions.


Download it from and install.


Find the download link for OpenOCD on their website. Install in any location you like. I installed it to /opt/openocd. Excellent installation instructions can be found here:


Download GNU tools for ARM embedded from launchpad. I installed it to:


It is not necessary to add it to any paths or whatsoever. We will tell QtCreator where to look for it.


The debugger needs a 32-bit version of python libraries. If you’re running on a 64-bit machine, this requires some extra steps. First, add i386 architecture to the package manager and run an update:

sudo dpkg --add-architecture i386
sudo apt-get update

Then, install the i386 version of python libraries by typing:

sudo apt-get install libpython2.7:i386

 QtCreator Configuration

First thing to do in QtCreator is to go to Help->About Plugins. Under device support, enable the BareMetal plugin by Tim Sander. Restarting QtCreator is required.

Next, go to Tools->Options->Build & Run. We are going to setup a new Kit, but first the compiler and debugger. Go to the Compilers tab and add a GCC compiler. Select the arm-none-eabi-gcc compiler from the directory in which you have it installed.Screenshot from 2015-07-04 21:10:21

Next, we’re going to add the debugger. Be sure to select arm-none-eabi-gdb-py. QtCreator is only compatible with the python version of gdb.

Screenshot from 2015-07-04 21:10:41

In the BareMetal menu, add OpenOCD with default settings.

Screenshot from 2015-07-04 21:17:28

Then, go to the Devices menu and add a new Bare Metal device.

Screenshot from 2015-07-04 21:11:53

Screenshot from 2015-07-04 21:12:11

Now, we have everything setup to make a new kit. Go back to the Build & Run menu and select the Kits tab. Add a new kit and select the following settings. The first time I tried this, I encountered a bug with the compiler selection which was grayed out, so I could not select the GCC ARM compiler. The workaround for this is to add a random other compiler so that you have at least two to choose from.

Screenshot from 2015-07-04 21:21:52

Debugging a CX-10 project

To demonstrate the debugger, I downloaded an existing cx-10 custom firmware project (which does not support the XN297 radio chip I’m working on).

git clone

In QtCreator, create a New Project. Select Import Project -> Import Existing Project.  Specify the directory you cloned it to and you should be good to go.

Now, in order to build this project and run it with the debugger, we’ll need to configure build and run settings for the project. Go to Projects Mode (Ctrl+5). If the newly created kit is not your default kit, you need to change the kit first. Then, set the build directory to the project path if it isn’t already, and add the debug argument for make. DEBUG=GDB is specific for the makefile of this project. If you’re doing this for another project, make sure to compile the sources with debug flags -ggdb.

Screenshot from 2015-07-04 21:36:56

Under Run Settings, add a new run configuration. Select via GDB server or hardware debugger. I don’t know why, but you need to enter the full path to the generated elf file.

Screenshot from 2015-07-04 21:40:56

Now we’re almost there. The final thing before we can start debugging is to start OpenOCD.

cd /opt/openocd/0.9.0-201505190955/bin
./openocd -f interface/stlink-v2.cfg -f target/stm32f0x.cfg

These flags are specific for the STM32F0x, which is present on the CX-10. Now that OpenOCD is running, start a debug session in QtCreator by pressing the Debug button or F5. You can add breakpoints and do awesome stuff!

Screenshot from 2015-07-04 21:46:50

6 thoughts on “Debugging STM32 from QtCreator

  1. Thanks for the writeup it is very helpful.

    I use CMake to create my project but could not get it to work in Creator, it kept complaining about my toolchain file. Maybe with this information I’ll be able to get it working.

  2. Pingback: Debugging an ARM (STM32) Microcontroller using Qt Creator – Stars Blog

  3. Hi,
    Thanks for the write-up, i’m searching information to setup Qt Creator as IDE to use the CMSIS libraries on a STM micro and this help me a lot.
    By any chance do you know if Qt Creator still needs the arm-none-eabi-gdb-py binary instead of the arm-none-eabi-gdb?
    I’m using the PPA version of the arm crosscompiler toolchain and it lacks of arm-none-eabi-gdb-py binary.

    Any info would be very helpful.

    • I actually don’t know since I’ve not used the debugger recently. The easiest way to find out is to try it ;-). There has been quite some developments in QtCreator so it might just work.

  4. Hi Bart,
    Thank you SO much for this write-up. I struggled with it for a bit before I figured out the exact problem, there’s an additional step that others might find useful.

    Adding the debugger produces “Unrecognized” in the Type field on the “Debuggers” tab.

    It was because the particular toolchain I installed was built for 32 bit linux, and thus “arm-none-eabi-gdb-python” was not finding because it was only looking in /lib/x86_64-linux-gnu and not /lib/i386-linux-gnu

    sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

    Hopefully this will be useful to others. Perhaps adding it to your instructions would be in order.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.