Skip to content

Debugging your Model T Using GDB

Nick Hebner edited this page Jan 11, 2015 · 5 revisions

At the top of the directory run make debug_app_mt or make debug_bootloader to build and load a debug binary and connect GDB to the Model-T. You can now debug in the gdb window. Standard out is forwarded to the OpenOCD server that runs in the background during debugging. You can connect to this terminal with make show_console.

Some useful GDB commands:

  • monitor reset halt
    • Resets the device and stops it so you can setup a new session
  • info threads
    • Shows a list of the current ChibiOS threads, their states and current program counters
  • thread <#>
    • Where <#> is the thread id from the 'info threads' list
    • switches to that thread context
  • thread apply <#> bt
    • Shows a backtrace for a given thread
  • Printing dbg_panic_msg should help narrow down which error happened
  • If a hard fault exception is generated, you can inspect the registers that are dumped to stack variables in the handler
  • PC (program counter) and LR (link register) will be of most interest Information on those registers is in the .map file