Using: Windows, Clion, Picoprobe & OpenOCD
- Go through all the steps necessery to build from command line, as described in "Getting started with Raspberry Pi Pico".
- Add MinGW toolchain to CLion:
- Add CMake profiles using the MinGW toolchain, specify the Pico SDK path as an environment variable:
At this stage the project should build.
- Build OpenOCD with picoprobe support as described in "Getting started..."
- Download libusb binary from here
- Take the dll
libusb-1.0.26-binaries\VS2015-x64\dll\libusb-1.0.dll
and put it in the OpenOCD directoryopenocd\tcl\
You should be now able to debug from command line as described in "Getting started..." section 6.3.
There are a couple tricky things here:
- we are using the bundled version of GDB (it's multiarch so it's OK)
- we are connecting to localhost:3333 (make sure that the port is not in use)
- the GDB Server args are:
-f interface/picoprobe.cfg -f target/rp2040.cfg
- the Working directory is set to
tcl
in the OpenOCD directory - this way OpenOCD will find thecfg
files and thelibusb
dll will load. - the reset command is set to
monitor reset halt
- Create a
.gdbinit
in your windows home directoryC:\Users\[your username]
with the contents:
define target remote
target extended-remote $arg0
monitor reset halt
break main
end
This redefines the target remote
GDB command as target extended-remote
and makes GDB to break just before your main().
This is a workaround for: https://youtrack.jetbrains.com/issue/CPP-7322
Now you should be able to start the debugger from CLion and step through the code.
-
(extra) Add rp2040.svd file to CLion debugger tab to get a nice overview off all registers. The file is located in
pico-sdk\src\rp2040\hardware_regs\rp2040.svd
. -
(also extra) Add
set(PICO_DEOPTIMIZED_DEBUG 1)
to yourCMakeLists.txt
before initializing the Pico SDK to stop the compiler from inling method calls (and make it easier to debug).