Categories
Miscellanea

Merry Christmas

Seasons Greetings! This particular LED tree runs a Yarg software image to display random sparkly lights!

Categories
Computing

Day 7-and the bug was…

For Day 1, go here. The series is tagged advent-2025.

As I noted earlier, I discovered a bug in the interrupt handling for Yarg when I opened and started to use box 3. This was a bit dispiriting, because I thought I had tested interrupts (and had tests for them).

Getting into the bug, it seemed familiar – much like a regression I’ve had before (when I had fewer tests) where a repeating interrupt differed from a one-off.

That didn’t seem to be the problem though, and in fact two similar interrupts behaved differently.

Looking further, the problem became clear. When I was preparing an interrupt for a repeat, I was only accounting for simple call frames. My advent code used more local variables, and revealed the bug.

I’ll make a new release with this fix in it, and then it will be time for box 4!

Categories
Computing

Day 6: Debugging Yarg

For Day 1, go here. The series is tagged advent-2025.

As I discovered previously, there seems to be a bug somewhere in the Yarg interrupt handling. While the box contents are basically the same as my ‘hello_button’ example, the circuit from yesterday only handles one interrupt before halting for some reason.

Debugging C on the Pico (which is how Yarg is implemented on the device) can be achieved with the Raspberry Pi Debug Probe (around £12). This connects to the Pico being debugged, and allows GDB (via open OCD) to step through code, set breakpoints and so on. I use it within VSCode, which gives me some convenient views of the RP2040 registers and integration with the rest of the Yarg project.

Advent Box 3 (on the left), and a Debug Probe (on the right in the small plastic enclosure).

The Debug Probe is effectively a specialised Pico, with the same RP2040 microcontroller, and dedicated connectors – USB to the host, and two serial ports to connect to the device being debugged.

One serial port is a standard UART connection needing TX, RX and Ground pins. Using this in preference to the Pico’s support for UART over USB eliminates the start-up time for the USB connection. The USB connection can be negotiated with the debug probe, and the UART connection to the device can connect on demand, practically instantly.

The other serial port is the ARM SWD port (Data, Clock, Ground), which is exposed via Open-OCD to the host to provide conventional debug services.

The Debug Probe comes with some useful connectors, and we’ll use two to connect to the Pico H the Advent Calendar came with:

Debug Probe connected to Pico UART0 and SWD

Notice how the Pico USB no longer needs to be connected, although you do need to supply power to the Pico somehow. I often connect the USB, and then choose in software which serial connection to debug with, and which to use for flashing.

With this setup I can use the VSCode debugger interface to start Yarg and step through code.

For the future, the same debug probe firmware can be run on a standard Pico, converting it into a dedicated debugger. I imagine I will use this when I want to build up a dedicated hardware test harness. I hope to tackle that sometime in the new year!