I have been working with STM32 series ARM microcontrollers on IAR Embedded Workbench for a while. For some reasons, now I need to move my works to Qt-Creator (both on Windows and Linux). In IAR EWARM, things are simpler: I've never had to deal with linker scripts or startup files, just open an IAR EWARM project template from ST's Peripheral Library release and with some simple adjustments, it's ready. Anyway, I tried to create a new project for STM32F4 on Qt but I faced with various problems.

Is there anybody that can explain this process clearly, step-by-step? With the related makefile, linker script, startup and system files if possible.

Note: Actually, I have a bunch of specific questions about the issue, but since I think that an explanation of the whole process may be helpful for me as well as other embedded newbies, I decided to ask the question this way.

  • \$\begingroup\$ What do you call "Qt environment" ? You mean the use of Qt-Creator ? Or you want your program to run in a Qt application ? Or you mean to run a Qt based program on STM32 ? It is not clear to me.. \$\endgroup\$
    – Antoine
    Jan 18, 2016 at 14:59
  • \$\begingroup\$ I want to compile my C code on Qt-Creator and download it to the mCU. I edited the question. \$\endgroup\$
    – ddyn
    Jan 18, 2016 at 15:40
  • 1
    \$\begingroup\$ I don't think it is such a great idea. It will be lot of pain for a tool that doesn't fit really the need. Why don't you go for something like CooCox or GNU ARM Eclipse ? \$\endgroup\$
    – Antoine
    Jan 18, 2016 at 16:04
  • 2
    \$\begingroup\$ Or if you don't like eclipse based IDEs, try CodeBlocks. It has a nice Embedded toolchain support. \$\endgroup\$
    – Antoine
    Jan 18, 2016 at 16:34
  • \$\begingroup\$ @Antoine , Qt is the only option at work for now. But I'll definitely try CodeBlocks at home, thank you. \$\endgroup\$
    – ddyn
    Jan 19, 2016 at 8:07

4 Answers 4


I actually work with this setup, it works wonderful.

First make sure you use a recent Qt Creator version. I downloaded mine from the website. In some Linux repositories it is outdated and does not support the BareMetal plugin, and/or QBS (which is quite useful).


  • Qt Creator (download from QT site)
  • ARM GCC (Ubuntu: apt-get install gcc-arm-none-eabi)
  • GDB source archive (download from archive)
  • OpenOCD (Ubuntu: apt-get install openocd)

Versions used: Qt Creator 3.6.0, ARM GCC 4.8.2-14ubuntu1+6, ARM GDB 7.6/7.10 with python support and OpenOCD 0.7.0.

1) Install Qt Creator. Open Help -> About Plugins. Find category Device Support and check BareMetal.

2) Go to Tools -> Options. There are a few settings we need to create and adjust in order to compile for an ARM Cortex controller.

a) Go to "Bare Metal" (last category) - add a debugger of your choice. I personally use OpenOCD. At this point you can set the connection to gdb and it's port, as well as init commands. The standard commands are set for STM32F4xx chips - but I guess you can modify it to work with any ARM Cortex controller.

b) Go to "Devices". Add a new device, choose Bare Metal and the GDB provider you have just created. There is nothing else to setup here.

c) Go to "Build & Run" - tab Debuggers. This has been the most trickiest thing to do.

You need an arm gdb version with python scripting support. At the time (about 9 months back when I write this post) the binaries in Ubuntu repo does not have this option. You can save a lot of time/hassle by checking if this has changed.

Nevertheless if you do need to compile GDB with python supporet, here is how to do it. Download GDB from the download archives. I still use GDB-7.6 which seems to work fine, but for this tutorial I have recompiled it for GDB-7.10.

Extract the source archive. Open in terminal and run "./configure --with-python --target=arm-elf". This sets up the make environment for ARM targets with python scripting enabled. Then run make. This takes a while, depending on your system speed. Unfortunately you may be a bit on your own once the compilation stops because of dependency issues. Don't be afraid - this happened to me on my first try too and I figured it out with a bunch of google searches! If python fails, make sure to install the python2.x-dev package (check your version no - likely 2.7). Assuming compilation went well, you can find the gdb executable in the main directory.

If you're on Mac, the process will likely be similar. But I am not familiar with OSX. If you're on Windows, sorry you will need to google a bit on how to do this with Mingw or whatever (honestly I don't know). Or maybe find binaries that have this support enabled.

Once you acquired a gdb executable, call it e.g. "ARM GDB" and set the path to it. I personally don't bother to place it in /usr/bin/, but I guess you could.

This window will throw an error if you use a gdb executable that is not compiled with Python Scripting.

d) Tab "Build & Run" - "Compilers"

Create a new "GCC compiler" and call it "ARM GCC". For path use "/usr/bin/arm-none-eabi-gcc". The "ABI" is not really important, I have just set it to arm-unknown-unknown-unknown-32bit.

e) Tab "Build & Run" - "Kits". Add a new kit, I called mine "ARM Bare Metal". Device type: "Bare Metal" Device: point to the Device you have created with it's OpenOCD/St link GDB server Sysroot: leave it empty Compiler: ARM GCC Debugger: ARM GDB Qt Version: None - You obviously cannot run the QT runtime on a Cortex m4! Cmake tool: unused

Make sure there are no warnings in any of the Build & Run tab

3) Make your make/qmake/QBS project. On left side go to tab "projects" and at left-top add the "ARM Bare Metal" kit. This should work without errors. Your project may start out with a desktop kit. Replacing usually does not work. In that case add an ARM kit and then remove the desktop one.

4) Start your OpenOcd server. I use a STM32F4 discovery for development, and also off-board programming to my own STM32 boards. For any STM32F40x/STM32F41x targets run:

openocd -f board/stm32f4discovery.cfg

This starts a gdb server at port 3333 and a telnet server (for OpenOCD commands) at 4444. As a shortcut I create a few .sh files in my home directory for a quick startup of a GDB server.

5) Start the debug session. It should program and run!

You can set breakpoints, step through code, even more PC back, watch call stack, variables (locals / watch), and disassembly. I'm really quited please with this, but obviously it lacks a few things like: 1) "Register view". Yes it has one, but that's just the CPU registers. I want register view of my peripherals as well. 2) Download progress or more detailed info about connection state. You need to refer to openocd for this.

edit: I have put up an example project on this Github repository.. It contains this post with a few dialog screenshots added, as well as a blinky project for the STM32F4 Discovery board using a QBS project in Qt Creator.

  • \$\begingroup\$ What exactly do you gain using Qt Creator as a tool chain? \$\endgroup\$
    – Matt Young
    Jan 19, 2016 at 19:13
  • \$\begingroup\$ I think a large share of personal preference. I can appreciate the versatility of Eclipse, but I absolutely cannot stand how slow Java IDE's are. CodeBlocks was mentioned earlier too, I guess there is not much difference. They are both IDE's for C/C++ with GDB debugging. I like QBS build system, but it's not a must. I happen to already use Qt so it's nice to stay within 1 environment for coding. There are probably much better commercial solutions available, but often not cross platform or out of budget for many hobbyists or small teams. \$\endgroup\$
    – Hans
    Jan 19, 2016 at 22:11
  • \$\begingroup\$ I used Qt and Qt Creator for the one desktop application I've ever written, and never in a million years would have thought people were using it for embedded development. Something new every day... \$\endgroup\$
    – Matt Young
    Jan 19, 2016 at 22:26
  • \$\begingroup\$ There are many ways leading to Rome. Any IDE that talks to GDB will be used at some point for cross-platform or embedded development I suppose. Visual Studio can also talk to OpenOCD via the VisualGDB plug-in, and so it can be (is being) used for ARM development. OTOH one could also write a script that runs a Makefile and calls a JTAG cmd line tool to upload their binary image to their board. You could use Vim and debug via serial/scope. No need for any interface or debugger that supports code stepping. If that is what works for you that's fine too right? :-) \$\endgroup\$
    – Hans
    Jan 19, 2016 at 22:51
  • \$\begingroup\$ Thanks for the heads-up about the bareMetal plugin. I remember hearing it mentioned once and then forgot. \$\endgroup\$ Feb 15, 2019 at 22:34

Download and install GCC-ARM, OpenOCD and ST-Util. STM32CubeF4 is optional but mandatory.

Add a custom compiler and debugger as image bellow on Tools->Options->Build & Run.

enter image description here

Learn how to use OpenOCD, GDB and ST-Flash.

Suggested Sites:

Cover all setup of QtCreator


Simple bare metal project for STM32 (it's mine)



Good starting point for you is wiki.qt.io/Building_Qt_5_from_Git

Also you'll find everything you need in their documentation which is on doc.qt.io.

You'll get the best support on its official forum forum.qt.io/category/4/qt-development.

This is more SO question, and not for SE EE.

  • \$\begingroup\$ Thank you, I will check these out. By the way, I first asked this question on SO and couldn't get an answer for like half an hour, so I decided to ask it here. \$\endgroup\$
    – ddyn
    Jan 18, 2016 at 13:24
  • \$\begingroup\$ Get STM32Cube to generate a project for eclipse tool SW4STM32 .. you get an eclipse project. QT may be able to import this directly, or you could look at the makefile it generates in <yourproject>/Your Proj config>/debug/makefile.. You may have to compile it first to get the makefile generated \$\endgroup\$
    – ChrisR
    Jan 18, 2016 at 14:00

If you want to build Qt targeting STM32, the short answer is : Forget it !

Why ? Qt is meant to run on Windows or Linux as you mention. But is is not possible to run those OS's on a STM32 because it lack a MMU, memory, power, etc..

If you want to port Qt to a new OS or event bare-metal, the road will be very long!

  • \$\begingroup\$ I don't think the original poster wants to port Qt to a microcontroller. Instead, s/he wants to know how how to get a project running using Qt when starting from scratch. The OP is quite clear about using both Windows and Linux. \$\endgroup\$ Jan 18, 2016 at 15:37
  • \$\begingroup\$ The OP does not want Qt on the STM32, they just want to use Qt Creator (the IDE) for STM32 development. \$\endgroup\$
    – Venemo
    May 20, 2017 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.