Skip to content

Debugging Printer Firmware with MK404

vintagepc edited this page Dec 2, 2021 · 2 revisions

Getting started:

You will need a few things to debug firmware with MK404:

  1. An intermediate ELF binary with debug symbols. You can recover this from the Arduino temp build directory (Firmware.ino.elf) or configure avr-gcc to build one.
  2. avr-gdb
  3. Mad GDB skillz (or read a good tutorial).

The Meat and Potatoes:

  1. Launch MK404 with any options required (SD filenames, -f, etc), AND the --gdb argument. MK404 will pause on startup.
  2. Start avr-gdb in a terminal
  3. Load the debug symbols: (gdb) file Firmware.ino.elf
  4. Set any breakpoints you wish, e.g. b file:line or b <function>
  5. Connect to the target: target extended-remote :1234
  6. GDB will halt execution and you'll see: 0x00000000 in __vectors ()
  7. Resume execution: (gdb) cont
  8. When you hit your breakpoint, go to town - you can examine variables with p, or registers with x (uint8_t*)<addr>.