Difference between revisions of "DevGuide/GDB OpenOCD Debug"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
== JTAG | == JTAG adapters == | ||
Recently some new [[JTAG]] adapters that use the FTDI2232 USB-parallel converter were introduced through OpenOCD (you can try your Wiggler with that, too). USB JTAG adapters include Floss-JTAG, Olimex or Amontec and also fine with Windows (Yagarto). | |||
Also see [[DevGuide/OpenOCD]] for installation instructions. | |||
== | == Debugging with GDB over JTAG == | ||
=== Procedure === | |||
# Start openocd in a new shell since this process needs to remain running. | |||
#: To connect to the Lisa/L board run the command | |||
#:<pre>openocd -f interface/lisa-l.cfg -f board/lisa-l.cfg</pre> | |||
#: To connect to the Lisa/M board via FLOSS-JTAG run the command: | |||
#:<pre>openocd -f interface/flossjtag.cfg -f board/lisa-l.cfg</pre> | |||
# Start GDB with an argument of the elf file created and uploaded to the board. | |||
#: If you programmed with the ap target then the command would be along the lines of | |||
#:<pre>/opt/paparazzi/arm-multilib/bin/arm-none-eabi-gdb var/<airframe>/ap/ap.elf</pre> | |||
#: Replace <airframe> with the name of the airframe that has been built. | |||
# Now connect GDB to the board | |||
#:<pre>target remote localhost:3333</pre> | |||
# Now we need to set some break points in the code. | |||
#: In this example the ap target was part of the rotorcraft and main.c contains the main program. Open rotorcraft sw/airborne/firmwares/rotorcraft/main.c and find a line at which you'd like to set a break point. | |||
#: <pre>break main.c:113</pre> | |||
# Stop the currently running code | |||
#: <pre>monitor reset halt</pre> | |||
# Reset the code back to the start | |||
#: <pre>monitor reset init</pre> | |||
# Now we can run the program which will stop at the break point we set. | |||
#:<pre>continue</pre> | |||
=== Useful commands === | |||
* We probably want to ignore the interrupt calls for the moment so we can step through the code as it's being called. Note that we don't always want to do this. (STM32 command only) | |||
*:<pre>monitor cortex_m3 maskisr on</pre> | |||
* A stack trace can be printed with the command | |||
*:<pre>bt</pre> | |||
* show the variable of a variable | |||
*:<pre>print i2c1.status</pre> | |||
* Show (eXamine) the value of the 9 bytes hardware register at address 0x40005800 and show them in hex format: | |||
*:<pre>x/9x 0x40005800</pre> | |||
* In some cases you may not be able to access some memory areas in the mcu, in that case you should try: | |||
*:<pre>set mem inaccessible-by-default off</pre> | |||
[[Category:Hardware]] [[Category:Software]] [[Category:Developer_Documentation]] | [[Category:Hardware]] [[Category:Software]] [[Category:Developer_Documentation]] |
Revision as of 06:32, 12 February 2012
JTAG adapters
Recently some new JTAG adapters that use the FTDI2232 USB-parallel converter were introduced through OpenOCD (you can try your Wiggler with that, too). USB JTAG adapters include Floss-JTAG, Olimex or Amontec and also fine with Windows (Yagarto).
Also see DevGuide/OpenOCD for installation instructions.
Debugging with GDB over JTAG
Procedure
- Start openocd in a new shell since this process needs to remain running.
- To connect to the Lisa/L board run the command
openocd -f interface/lisa-l.cfg -f board/lisa-l.cfg
- To connect to the Lisa/M board via FLOSS-JTAG run the command:
openocd -f interface/flossjtag.cfg -f board/lisa-l.cfg
- Start GDB with an argument of the elf file created and uploaded to the board.
- If you programmed with the ap target then the command would be along the lines of
/opt/paparazzi/arm-multilib/bin/arm-none-eabi-gdb var/<airframe>/ap/ap.elf
- Replace <airframe> with the name of the airframe that has been built.
- Now connect GDB to the board
target remote localhost:3333
- Now we need to set some break points in the code.
- In this example the ap target was part of the rotorcraft and main.c contains the main program. Open rotorcraft sw/airborne/firmwares/rotorcraft/main.c and find a line at which you'd like to set a break point.
break main.c:113
- Stop the currently running code
monitor reset halt
- Reset the code back to the start
monitor reset init
- Now we can run the program which will stop at the break point we set.
continue
Useful commands
- We probably want to ignore the interrupt calls for the moment so we can step through the code as it's being called. Note that we don't always want to do this. (STM32 command only)
monitor cortex_m3 maskisr on
- A stack trace can be printed with the command
bt
- show the variable of a variable
print i2c1.status
- Show (eXamine) the value of the 9 bytes hardware register at address 0x40005800 and show them in hex format:
x/9x 0x40005800
- In some cases you may not be able to access some memory areas in the mcu, in that case you should try:
set mem inaccessible-by-default off