Raspberry Pico Debugging on WSL
Few days ago I set up my embedded toolchain to debug upload code to a Raspberry Pico Microcontroller on my NixOS machine. It's nice to have a dedicated Linux machine but it's a 2014 MacBook Pro, and not I am not very comfortable sitting in my kitchen trying to write embedded code.
So I woke up and started to configure my Windows machine with WSL so that I can debug Raspi Pico on my normal gaming desktop as well. The process was a little bit complicated that I initially thought it would be.
- Initially the picoprobe USB device wasn't getting mounted / attached to the WSL subsystem. That wasn't too complicated to fix. There are official documentation from Microsoft on how to set up
usbipd
to attach USB ports to WSL system. - I had some trouble building Rust binaries for the
thumb
target that I was using from rp-hal, but that was rather easily fixed. - But then it became clear that the Ubuntu distribution I was running, 22.04 didn't get a package update to include the latest version of OpenOCD (0.12.0).
- I tried to build OpenOCD from source, but that wasn't very straightforward with the CMSIS-DAP features.
- So I ended up installed Debian on my WSL, installed and the dev tools, including OpenOCD, and made it to work e.g. building Rust code, flashing & debugging with GDB.
- Even though I managed to get all the tooling around Raspi Pico working, my normal Rust + neovim development wasn't really working out. The LSP with neovim kept crashing and I couldn't figure out why. I tried to debug for a bit, but my neovim plugin + lua knowledge was so low, at some point I gave up.
- At this point, I at least had a working toolchain on my Windows machine, just that my development environment wasn't properly set up, and wasn't Ubuntu but Debian.
- Then I found out that OpenOCD's latest version is available with the 24.04 version of Ubuntu. So I ended up installing the latest version of Ubuntu. Then I went ahead and set up all the dev tools I needed for Rust embedded on Raspi Pico.
- Fired up OpenOCD + GDB, worked quite well; except some
keep_alive()
warnings. - Then I finished setting up the rest of my development environment, along with neovim and Rust plugins, tmux, ZSH, neovim etc.
Now I have two capable machines, able to write code and flash and debug Raspi Picos.
All in all, Sunday well spent.
13-05-2024