Difference between revisions of "Dev/Debugging"

From PaparazziUAV
Jump to navigation Jump to search
Line 44: Line 44:
* Show (eXamine) the value of the 9 bytes hardware register at address 0x40005800 and show them in hex format:
* Show (eXamine) the value of the 9 bytes hardware register at address 0x40005800 and show them in hex format:
*:<pre>x/9x 0x40005800</pre>
*:<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:Software]] [[Category:Developer_Documentation]]
[[Category:Software]] [[Category:Developer_Documentation]]

Revision as of 04:34, 12 February 2012

Introduction

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

Procedure

  1. Start openocd in a new shell since this process needs to remain running.
    To program the Lisa/L board run the command
    openocd -f interface/lisa-l.cfg -f board/lisa-l.cfg
    or if you are still using the old paparazzi-stm32 package and your path is not set properly
    cd /opt/paparazzi/stm32/share/openocd/scripts/; /opt/paparazzi/stm32/bin/openocd -f interface/lisa-l.cfg -f board/lisa-l.cfg
    To program the Lisa/M board via JTAG change dir to "<paparazzi root>/arm-multilib/share/openocd/scripts", and run the command:
    openocd -f interface/flossjtag.cfg -f board/lisa-l.cfg

NOTICE: For lisa/m boards file lisa-m.cfg should look like:

# the Lost Illusions Serendipitous Autopilot
# http://paparazzi.enac.fr/wiki/Lisa
# Work-area size (RAM size) = 64kB for STM32F103RB device
set WORKAREASIZE 0xFA00
source [find target/stm32f1x.cfg]
  1. 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
    arm-none-eabi-gdb var/<airframe>/ap/ap.elf
    or (if you are using the old paparazzi-stm32 package)
    /opt/paparazzi/stm32/bin/arm-none-eabi-gdb ./var/<airframe>/ap/ap.elf
    Replace <airframe> with the name of the airframe that has been built.
  2. Now connect GDB to the board
    target remote localhost:3333
  3. 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
  4. Stop the currently running code
    monitor reset halt
  5. Reset the code back to the start
    monitor reset init
  6. 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.
    monitor cortex_m3 maskisr on
  7. Now we can run the program which will stop at the break point we set.
    continue

Useful commands

  • 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