Difference between revisions of "Dev/Debugging"

From PaparazziUAV
Jump to navigation Jump to search
(delete this page)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Introduction =
== GDB via JTAG ==
GDB can be used for debugging the code on the boards.
GDB and JTAG can be used for debugging the code directly on the boards. Here are a couple of words on [[JTAG]] itself and the [[DevGuide/JTAG-Debug|debugging process]].


JTAG interface was designed for on chip debug. That means, it can debug chips that has no bootloader at all.
== Test programs ==
The board provided by JobyRobotics is based on FTDI chip that allows two simultaneous USB connections. For us it means that FLOSS JTAG allows JTAG and UART/COM connections.
:-)


Let's take a look at upper side of the board. It contains JTAG connector (which is connected on photo) and two sets of RX/TX LEDs for JTAG and UART/COM interface separately.


[[Image:Jtag-up.jpg]]
[[Category:Software]] [[Category:Developer_Documentation]] [[Category:DeleteMe]]
 
On the other side of the board there is 4 pin UART/COM connector, which contains: Ground (black), TX (yellow), RX (orange) and +5V (red)
 
[[Image:Jtag-down.jpg]]
 
Usage of board is pretty simple: JTAG can be used to upload firmware into the board and/or repair board with broken bootloader, and UART/COM interfaced can be used to make "COM port style" connection to the board. COM connection can be used for example for telemetry debug.
 
= Procedure =
# Start openocd in a new shell since this process needs to remain running.
#: To program the Lisa/L board run the command
#:<pre>openocd -f interface/lisa-l.cfg -f board/lisa-l.cfg</pre>
#:or if you are still using the old paparazzi-stm32 package and your path is not set properly
#:<pre>cd /opt/paparazzi/stm32/share/openocd/scripts/; /opt/paparazzi/stm32/bin/openocd -f interface/lisa-l.cfg -f board/lisa-l.cfg</pre>
#: To program the Lisa/M board via JTAG change dir to "<paparazzi root>/arm-multilib/share/openocd/scripts", and 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>arm-none-eabi-gdb var/<airframe>/ap/ap.elf</pre>
#:or (if you are using the old paparazzi-stm32 package)
#:<pre>/opt/paparazzi/stm32/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>
# 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.
#:<pre>monitor cortex_m3 maskisr on</pre>
# Now we can run the program which will stop at the break point we set.
#:<pre>continue</pre>
 
== Useful commands ==
* 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>
 
[[Category:Software]] [[Category:Developer_Documentation]]

Latest revision as of 09:34, 21 April 2014

GDB via JTAG

GDB and JTAG can be used for debugging the code directly on the boards. Here are a couple of words on JTAG itself and the debugging process.

Test programs

:-)