Breakpoints in firmware, in a browser tab
Category: Engineering
To debug firmware you usually need the board, a probe, the right GDB, and a config file that worked last month. We wanted the part that matters without the rest: click a line, run, and the device stops there. Now it works in the playground. The simulated board pauses on your line, the LCD freezes mid-frame, and the variables show what the code sees.
What it looks like
The example is a small game on a Nokia 5110 LCD, with an HC-SR04 distance sensor as the controller. Move the distance slider and the paddle follows. Click the gutter next to the game loop and a red dot appears. The next time the loop runs, the board stops on that line.
Everything is in the code view, the way it is in VS Code:
- Click the gutter to set a breakpoint. The current line is highlighted.
- Use Continue, Step Over, Step Into and Step Out from the toolbar, or F5, F10, F11 and Shift+F11 while the code view has focus.
- Read the Variables, Watch and Call Stack panels next to the code, with Registers, Memory and Peripherals below them. Values also show inline, at the end of the line.
Step Over from line 508 goes to 509, then 511, then back to the top of the loop at 491. Press Continue and the board stops on 508 again, one frame later. Remove the breakpoint and the game runs again.
Try it
Open the Nokia 5110 example in the playground. The code view opens on src/main.rs. Click the gutter left of line 508 and the board stops there. You do not need an account.
What it does not do
- It debugs the simulated board, not a physical one. For real hardware, use your probe.
- Some locals really are optimized out at a given line, such as
filtat 508. The debugger says so instead of guessing. - Source debugging works on the ARM Cortex-M boards and on the ESP32, ESP32-S3 and ESP32-C3. The firmware needs DWARF debug info.