Intro to Embedded Rust Part 11: Logging with defmt and Step-through Debugging | DigiKey @digikey
Intro to Embedded Rust Part 11: Logging with defmt and Step-through Debugging | DigiKey  @digikey
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
Intro to Embedded Rust Part 11: Logging with defmt and Step-through Debugging | DigiKeyThats the Spirit [Maker Update] | Maker.ioThe House of Cards Challenge - #thebytesizedengineer | DigiKeyAnalog Devices ADXL380 Shipment Quality Logger – Potentially Genius® | DigiKeyTrouble reading an ADC with Home Assistant - #thebytesizedengineer | Short3d Prints for The Best Summer Ever #3dprinting #3dprint #summer #makerupdateYour utility company is broadcasting your data for anyone to see! - #thebytesizedengineer | ShortMake a 3D Printed Projector #3Dprinting #DIY #Project #MakerUpdateInkscape Extensions for Makers #SVG #Lasercutting #Graphics #MakerUpdateQuick Way to Find i2c Address #Hardware #Prototyping #Arduino #MakerUpdateDecoding the I2C Bus - #thebytesizedengineer | DigiKeyApplying solder paste with a vacuum stencil - #ByteSized | DigiKey
DigiKey |

Intro to Embedded Rust Part 11: Logging with defmt and Step-through Debugging | DigiKey

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER