Setting up Qt Creator for Pi Pico RP2040 development
on
Qt Creator is tricky to set up for RP2040/Pi Pico development, but fairly quick once you know the steps. I was unable to make Pico projects run correctly under VS Code using Raspberry's suggested editor extension.
Note: These are personal notes from setting up Qt Creator for Raspberry Pi Pico 1 development on a new machine, organized into an article after the fact. They are specific to my machine (Arch Linux, fish shell) and may have missing or outdated steps, which may not fully succeed on a new machine or user account.
IDE setup
If you're using Arch Linux, you can install dependencies as follows:
# paru -S pico-sdk # github raspberrypi/pico-setup only works on apt-based systems
cd (path to pico-sdk (either ~, a code folder, or a files folder))
git clone https://github.com/raspberrypi/pico-sdk.git
set -Ux PICO_SDK_PATH $PWD/pico-sdk
sudo pacman -S --needed arm-none-eabi-gcc arm-none-eabi-newlib arm-none-eabi-gdb
I cloned https://github.com/raspberrypi/pico-sdk, but you could alternatively paru -S pico-sdk. The official PDFs suggest raspberrypi/pico-setup, but I found the script only works on apt-based systems.
While attempting to attach Qt Creator's gdb backend to the Pico, I ran into repeated debugger lockups. It turns out the latest release of OpenOCD is too old to work properly with multicore Pi Pico programs, and switching to paru -S openocd-raspberrypi-git magically fixed all debugging issues. I later tried installing openocd-git which worked fine as well.
- If you are using a Pi Pico 2 or RP2350 board, you will need to use
openocd-gitor the raspberrypi fork as well. I do not have a Pico 2 to test if mainline works or not. - I've struggled to build OpenOCD on Arch Linux, because the build scripts depend on cloning https://gitlab.zapb.de/libjaylink/libjaylink.git which is frequently down. The
openocd-gitAUR page actually has a comment from 2025-01 stating, "Since commit bootstrap: Do not set up Git submodules by default anything related to submodules can (and should) be removed from PKGBUILD resulting in a much simplified (and faster) build". This would remove the dependency on cloning the slow Git host, but sadly the AUR package has not incorporated this change in nearly 2 years.
Once you've installed dependencies, it's time to set up Qt Creator.
- If you want flashing and debugging support, you'll have to enable the Bare Metal plugin in Help > About Plugins, then restart the IDE.
- Next you'll have to enable the Pico compilers. Open menu Edit > Preferences, and click on sidebar Kits. At the right click the Add button, and name the new kit Pico.
- Set the C/C++ compilers to
/usr/bin/arm-none-eabi-gcc. (If Qt Creator didn't auto-detect the compiler, you'll have to add it in the Compilers tab.) - Make sure the "Qt version" is set to None, and click Apply.
- Set the C/C++ compilers to
- To add flashing and debugging support, go to sidebar Devices, and click tab Bare Metal. At the bottom click the Add button and select OpenOCD. Rename the new item to "OpenOCD Pico".
- For the "Peripheral description file", browse for
...pico-sdk/src/rp2040/hardware_regs/RP2040.svdunder the Git repo you cloned earlier. - For the "Configuration file", browse for
...pico-sdk/lib/tinyusb/hw/bsp/rp2040/rp2040-openocd.cfg. - Under "Init commands", I added
set remotetimeout 3000before the firstmonitor reset halt. This may make gdb wait longer for an unresponsive Pico, but I'm not sure if the debugger ever locks up if you're usingopenocd-git.
- For the "Peripheral description file", browse for
- Now click the Devices tab, click the Add button (not its dropdown arrow), and in the dialog select Bare Metal Device. Name your new device "Pico" and select the "OpenOCD Pico" debug service provider (DSP).
- If you want to attach the debugger to an already-running microcontroller (before or after triggering a bug), you can create a separate bare metal configuration and device that attaches to a running device without flashing or resetting it.
- In sidebar Devices, click tab Bare Metal, rename the "OpenOCD Pico" configuration to "OpenOCD Pico (flash firmware)", and at the bottom click Clone. Rename the clone to "OpenOCD Pico (no reset)", and remove all
monitor reset haltandloadcommands. - Click tab "Devices", and rename your existing device "Pico (flash firmware)". Add another device, selecting Bare Metal Device, and name it "Pico (no reset)" while selecting the "OpenOCD Pico (no reset)" debug service provider.
- In sidebar Devices, click tab Bare Metal, rename the "OpenOCD Pico" configuration to "OpenOCD Pico (flash firmware)", and at the bottom click Clone. Rename the clone to "OpenOCD Pico (no reset)", and remove all
Sidenote: Why does Qt Creator configure the Desktop device in the Devices tab, while Bare Metal devices have no options besides picking a named bare metal configuration, which gets created in the Bare Metal tab? The two tabs are needlessly different too; the Devices tab has a device dropdown, Add button at the right, and a full-screen configuration, while the Bare Metal tab has a left-side visible list of configurations, Add and Clone button at the bottom, and configuration at the right. I wonder if this is due to bare metal support living in a plugin rather than core, which can't add new configuration screens to the Devices tab.
Project setup
At this point, you can build .uf2 files in Qt Creator and drag them to your Pi Pico in BOOTSEL mode as usual.
If you want to attach a debugger, you'll need a second Pi Pico flashed with the Raspberry debugprobe (formerly picoprobe) firmware. Attach the debugprobe's GPIO pins to the first Pico's SWD pads, and plug the debugprobe to your PC over a USB cable. Now Qt Creator's Run and Debug buttons will flash and debug your first Pico over SWD, as if you were launching programs on your PC.
Tip: Every time you open a new Pico CMake project, you'll end up with two run configurations. There's no point in running bs2_default (a boot stage rather than the complete project), so in the sidebar click Projects, open the "Run Settings" tab, and remove bs2_default. You'll have to repeat this for each project you open.
Fixing broken projects
A Pico project needs a pico_sdk_import.cmake file copied from <PICO_SDK_PATH>/external/pico_sdk_import.cmake. If the file is missing, CMake configuration may find the compiler but not the RP2040 toolchain config, use the wrong compile/link flags, and throw an error undefined reference to `_exit'.
To resolve this error, first copy pico_sdk_import.cmake into your project root, then delete your CMake folder and reconfigure from scratch to fix compilation flags. (CMake is infamous for having a non-memoryless configuration system, which fails to invalidate cache and update configuration when you change build parameters or update your toolchain.)