Skip to content

Instantly share code, notes, and snippets.

@hasumikin
Last active March 27, 2025 23:34
Show Gist options
  • Save hasumikin/f508c092ced0b5d51779d472fbaf81e8 to your computer and use it in GitHub Desktop.
Save hasumikin/f508c092ced0b5d51779d472fbaf81e8 to your computer and use it in GitHub Desktop.
Debug a Pi Pico app with Picoprobe(WSL2)

Connection

Note that RP2 (debug target) should be powered, too.

Run Powershell as an admin

You may need to upgrade usbipd : https://github.com/dorssel/usbipd-win/releases

  • usbipd list to find the Picoprobe's BUSID
    It will look like: 2-2 2e8a:000c CMSIS-DAP v2 Interface, USB シリアル デバイス (COM10) Shared
  • If it is 2-2 2e8a:000c CMSIS-DAP v2 Interface, USB シリアル デバイス (COM10) Not shared, run usbipd bind -b 2-2 to make it shared
  • Then usbipd attach --wsl -b 2-2 usbipd list will changes like: 2-2 2e8a:000c CMSIS-DAP v2 Interface, USB シリアル デバイス (COM10) Attached

On a terminal

  • openocd-rp2040 or openocd-rp2350

On another terminal cding the project directory

build project

-DCMAKE_BUILD_TYPE=Debug has to be defined in build process. Note that Debug is only valid option while debug and DEBUG are not valid.

In R2P2, rake pico_debug is what you need.

  • gdb-pico build/[project].elf
  • In the gdb's REPL
    • load to upload the elf
    • monitor reset init to init
    • c to start (alias for continue)
    • monitor reset halt to reboot

Setup

openocd

sudo apt-get install libusb-1.0-0-dev libtool
git clone https://github.com/raspberrypi/openocd.git --branch sdk-2.0.0 --depth=1 --no-single-branch
cd openocd
./bootstrap
./configure --disable-werror
make
sudo make install
sudo cp contrib/60-openocd.rules /etc/udev/rules.d/

gdb-multiarch

sudo apt install gdb-multiarch

.bash_alias

alias openocd-rp2040="/usr/local/bin/openocd -f interface/cmsis-dap.cfg -c 'adapter speed 5000' -f target/rp2040.cfg -s tcl"
alias openocd-rp2350="/usr/local/bin/openocd -s tcl -f interface/cmsis-dap.cfg -f target/rp2350.cfg -c 'adapter speed 5000'"

function gdb-pico() {
  gdb-multiarch -ex "target remote localhost:3333" $*
}
alias gdb-pico=gdb-pico

PowerShell as an admin

winget install usbipd

For Arm Windows, you can download usb-ipd.exe from https://github.com/dorssel/usbipd-win

@henrygab
Copy link

Thank you for considering my comment.
I think the following line has a typo:

sudo contrib/60-openocd.rules /etc/udev/rules.d/

I believe it should instead be:

sudo cp contrib/60-openocd.rules /etc/udev/rules.d/

@hasumikin
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment