Uploaded April 2026 | Updated November 2026, 11 hours ago
In this tutorial, we cover efficient logging using the defmt framework and step-through debugging for the Raspberry Pi Pico 2. As embedded projects grow beyond simple LED blinking, you need more sophisticated tools to diagnose bugs and understand program behavior. We introduce two essential debugging approaches: the defmt logging framework for efficient, low-overhead debug output, and interactive step-through debugging with GDB for inspecting program state in real-time.
Note that for this guide, you will need a Raspberry Pi Debug Probe, defmt and step-through debugging require additional hardware connected to the debug port on the target Pico 2.
The written guide for this episode can be found here: digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-11-defmt-and-step-through-debugging
The GitHub repository containing the Docker image and example code for this series can be found here: github.com/ShawnHymel/introduction-to-embedded-rust
Unlike traditional string formatting that stores format strings in flash memory, defmt keeps format strings on your development computer and only sends small integer indices plus variable data over RTT (Real-Time Transfer). This approach dramatically reduces flash usage and runtime overhead, making it ideal for production debugging where you need fast logging without affecting timing-sensitive code. We demonstrate configuring defmt with different log levels (trace, debug, info, warn, error), using defmt-rtt as the RTT transport layer, and integrating panic-probe for better panic messages.
We explore how to add the required linker flags in .cargo/config.toml, set the DEFMT_LOG environment variable to control verbosity, and use probe-rs run to flash your program and display real-time log output through the Debug Probe's SWD connection.
We then look at interactive step-through debugging using GDB (GNU Debugger) with the probe-rs GDB server. ARM Cortex-M microcontrollers like the RP2350 require external debug hardware, as they cannot perform step-through debugging on their own and need a debug probe connected via SWD to enable breakpoints, variable inspection, and single-stepping.
We cover the complete setup: installing probe-rs tools with cargo install, configuring WinUSB drivers on Windows, connecting the Debug Probe to the Pico 2's SWD header (SWCLK, GND, SWDIO), and starting a GDB server with probe-rs gdb. The tutorial demonstrates using gdb-multiarch to connect to the remote target, set breakpoints with break main, step through code with step and next commands, inspect variables with print, and examine the call stack. These are essential skills for diagnosing complex bugs that can't be solved with logging alone.
Related Link:
digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-11-defmt-and-step-through-debugging
Links:
Getting Started with STM32 and Nucleo: youtube.com/watch?v=hyZS2p1tW-g&list=PLEBQazB0HUyRYuzfi4clXsKUSgorErmBv
Introduction to Real-Time Operating Systems (RTOS): youtube.com/watch?v=F321087yYy4&list=PLEBQazB0HUyQ4hAPU1cJED6t3DU0h34bz
Raspberry Pi Pico 2: digikey.com/en/products/detail/raspberry-pi/SC1631/24627142
Learn more:
Maker.io - digikey.com/en/maker
DigiKey’s Blog – TheCircuit digikey.com/en/blog
Connect with DigiKey on Facebook facebook.com/digikey.electronics
And follow us on X: https://x.com/digikey
Product:
digikey.com/en/products/detail/raspberry-pi/SC1631/24627142
digikey.com/en/products/detail/raspberry-pi/SC1632/26241102
digikey.com/en/products/detail/raspberry-pi/SC1633/25862735
digikey.com/en/products/detail/raspberry-pi/SC1634/26241087
digikey.com/en/products/detail/sparkfun-electronics/13314/6797646
digikey.com/en/products/detail/lite-on-inc/LTL-4224/217584
digikey.com/en/products/detail/stackpole-electronics-inc/CF14JT220R/1830334
digikey.com/en/products/detail/te-connectivity-alcoswitch-switches/1825910-6/1632536
digikey.com/en/products/detail/dfrobot/FIT0096/7597069
digikey.com/en/products/detail/adafruit-industries-llc/1957/6827090
digikey.com/en/products/detail/cvilux-usa/DH-20M50055/13175849
Chapters:
0:00 Intro
0:51 Hardware Setup
1:45 Configure Debugging and defmt Dependencies
5:33 Modifying Blinky with defmt Messages for Logging
7:07 Build, Flash, and Run over Debug Probe
14:39 Step-through Debugging with GDB CLI
18:03 Step-through Debugging with GDB and VS Code GUI (Buggy)
24:38 Conclusion
In this tutorial, we cover efficient logging using the defmt framework and step-through debugging for the Raspberry Pi Pico 2. As embedded projects grow beyond simple LED blinking, you need more sophisticated tools to diagnose bugs and understand program behavior. We introduce two essential debugging approaches: the defmt logging framework for efficient, low-overhead debug output, and interactive step-through debugging with GDB for inspecting program state in real-time.
Note that for this guide, you will need a Raspberry Pi Debug Probe, defmt and step-through debugging require additional hardware connected to the debug port on the target Pico 2.
The written guide for this episode can be found here: digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-11-defmt-and-step-through-debugging
The GitHub repository containing the Docker image and example code for this series can be found here: github.com/ShawnHymel/introduction-to-embedded-rust
Unlike traditional string formatting that stores format strings in flash memory, defmt keeps format strings on your development computer and only sends small integer indices plus variable data over RTT (Real-Time Transfer). This approach dramatically reduces flash usage and runtime overhead, making it ideal for production debugging where you need fast logging without affecting timing-sensitive code. We demonstrate configuring defmt with different log levels (trace, debug, info, warn, error), using defmt-rtt as the RTT transport layer, and integrating panic-probe for better panic messages.
We explore how to add the required linker flags in .cargo/config.toml, set the DEFMT_LOG environment variable to control verbosity, and use probe-rs run to flash your program and display real-time log output through the Debug Probe's SWD connection.
We then look at interactive step-through debugging using GDB (GNU Debugger) with the probe-rs GDB server. ARM Cortex-M microcontrollers like the RP2350 require external debug hardware, as they cannot perform step-through debugging on their own and need a debug probe connected via SWD to enable breakpoints, variable inspection, and single-stepping.
We cover the complete setup: installing probe-rs tools with cargo install, configuring WinUSB drivers on Windows, connecting the Debug Probe to the Pico 2's SWD header (SWCLK, GND, SWDIO), and starting a GDB server with probe-rs gdb. The tutorial demonstrates using gdb-multiarch to connect to the remote target, set breakpoints with break main, step through code with step and next commands, inspect variables with print, and examine the call stack. These are essential skills for diagnosing complex bugs that can't be solved with logging alone.
Related Link:
digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-11-defmt-and-step-through-debugging
Links:
Getting Started with STM32 and Nucleo: youtube.com/watch?v=hyZS2p1tW-g&list=PLEBQazB0HUyRYuzfi4clXsKUSgorErmBv
Introduction to Real-Time Operating Systems (RTOS): youtube.com/watch?v=F321087yYy4&list=PLEBQazB0HUyQ4hAPU1cJED6t3DU0h34bz
Raspberry Pi Pico 2: digikey.com/en/products/detail/raspberry-pi/SC1631/24627142
Learn more:
Maker.io - digikey.com/en/maker
DigiKey’s Blog – TheCircuit digikey.com/en/blog
Connect with DigiKey on Facebook facebook.com/digikey.electronics
And follow us on X: https://x.com/digikey
Product:
digikey.com/en/products/detail/raspberry-pi/SC1631/24627142
digikey.com/en/products/detail/raspberry-pi/SC1632/26241102
digikey.com/en/products/detail/raspberry-pi/SC1633/25862735
digikey.com/en/products/detail/raspberry-pi/SC1634/26241087
digikey.com/en/products/detail/sparkfun-electronics/13314/6797646
digikey.com/en/products/detail/lite-on-inc/LTL-4224/217584
digikey.com/en/products/detail/stackpole-electronics-inc/CF14JT220R/1830334
digikey.com/en/products/detail/te-connectivity-alcoswitch-switches/1825910-6/1632536
digikey.com/en/products/detail/dfrobot/FIT0096/7597069
digikey.com/en/products/detail/adafruit-industries-llc/1957/6827090
digikey.com/en/products/detail/cvilux-usa/DH-20M50055/13175849
Chapters:
0:00 Intro
0:51 Hardware Setup
1:45 Configure Debugging and defmt Dependencies
5:33 Modifying Blinky with defmt Messages for Logging
7:07 Build, Flash, and Run over Debug Probe
14:39 Step-through Debugging with GDB CLI
18:03 Step-through Debugging with GDB and VS Code GUI (Buggy)
24:38 Conclusion
![Thats the Spirit [Maker Update] | Maker.io
This week on Maker Update: Japanese demon juggling, more AI for Raspberry Pi, reality-blocking glasses, lighting up the RF spectrum, and 1-dimensional Space Invaders.
+Show Notes [Maker Update Ep.468]+
=Project of the Week=
Synthetic Spirits: Bakezōri & Kameosa by Neil Mendoza 0:29
https://www.neilmendoza.com/portfolio/synthetic-spirits-bakezori/
https://www.neilmendoza.com/portfolio/synthetic-spirits-kameosa/
Creative Applications writeup:
https://www.creativeapplications.net/member/synthetic-spirits-kinetic-sculptures-reveal-a-hidden-world/
=News=
Raspberry Pi AI HAT+ 2 2:19
https://www.raspberrypi.com/products/ai-hat-plus-2/
Buy Raspberry Pi AI HAT+ 2 from DigiKey:
https://www.digikey.com/en/products/detail/raspberry-pi/SC2166/28723081
AI this, AI that, Heres Raspberry Pis new AI HAT by Jeff Geerling
https://www.youtube.com/watch?v=jRQaur0LdLE
=More Projects=
These Glasses Hide Your Messy Room by Marina Fujiwara (MUDA-ZUKURI) 3:25
https://www.youtube.com/watch?v=Rw-a-CTtieQ
I Built a Light That Can See Radio Waves by Rootkid 4:12
https://rootkid.me/works/spectrum-slit
1D RGB Invaders - ESP32 Arcade Game by Achim Weis 4:41
https://makerworld.com/en/models/2254346-1d-rgb-invader-retro-game#profileId-2455425
=Tips & Tools=
USB Gadget Mode in Raspberry Pi OS: SSH Over USB 5:20
https://www.raspberrypi.com/news/usb-gadget-mode-in-raspberry-pi-os-ssh-over-usb/
Fixing Breadboards for Wide Microcontrollers – Pico & ESP32 Edition by lhm0 6:10
https://www.instructables.com/Fixing-Breadboards-for-Wide-Microcontrollers-Pico-/
=DigiKey Spotlight=
Adding LIDAR to a Robot - The Byte Sized Engineer 6:54
https://www.youtube.com/watch?v=P8ekEIbVmQw
#makerupdate
Maker Update is a weekly video series covering news, projects, tips, and events that interest the maker and DIY community.
Find more online:
Blog: http://makerprojectlab.com
Instagram: https://www.instagram.com/makerprojectlab/ Thats the Spirit [Maker Update] | Maker.io](https://i.ytimg.com/vi/UhQIiRWBDGQ/mqdefault.jpg)









