Debugging in C Code on the RP2040: Using gdb - Setup

Where I show a simple method of using gdb to debug code on the RP2040 (Pi Pico board).

Sources#

Setup .gdbinit#

The Guide recommends at the very least, add “target remote localhost:3333” to your .gdbinit file. To make our edit/compile/link/load round trip easy, I recommend the following for your .gdbinit:

gdb Resources

All of the resources found related to gdb (particularly, related to the RP2040) and how to use it.

GNU gdb documentation#

gdb Tutorials#

Cheat Sheets#

Tools to enhance gdb#

AVR gdb#

AVR gdb Notes#

  1. Check the version number on avr-gdb as of December 2021, it is 11.1. On Ubuntu, the latest version is 8.1 from 2018 which had quite a few bugs. Attempted to build it manually (which failed), so I spun up a Manjaro (Arch Linux) instance to get the latest. Crazy, I know.
  2. Start avarice in a separate window using, then launch gdb in another window:
    avarice -g -w -d -P atmega328p :3333 	# window 1
    avr-gdb -tui							# window 2
  3. If avarice crashes on startup, cycle power on both the debugger (Dragon) and the target (Uno)

Pico (RP2040) gdb#