Skip to content

Debugging your Model T Using GDB

brianstarnes edited this page Apr 26, 2014 · 5 revisions

At the top of the directory run the following in a terminal:

  • openocd -f interface/olimex-arm-usb-tiny-h.cfg -f target/stm32f2x.cfg -f stm32f2x-setup.cfg -c init -c "reset init" -c halt -c "stm32f2x.cpu configure -rtos auto”

In a separate terminal run:

  • arm-none-eabi-gdb.exe build/app_mt/app_mt.elf --eval-command "target remote:3333" --eval-command "monitor poll" --eval-command "monitor reset halt"

You can now debug in the gdb window. Some useful 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