You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.1 KiB

  1. # Hardware Debugging In Eclipse
  2. Build a binary with debugging information using command line or via Eclipse make target.
  3. Example Eclipse make target
  4. ![](https://raw.github.com/wiki/hydra/cleanflight/images/eclipse-gdb-debugging/make 1 - OLIMEXINO GDB.PNG)
  5. # GDB and OpenOCD
  6. start openocd
  7. Create a new debug configuration in eclipse :
  8. ![connect to openocd](http://i.imgur.com/somJLnq.png)
  9. ![use workspace default](http://i.imgur.com/LTtioaF.png)
  10. you can control openocd with a telnet connection:
  11. telnet localhost 4444
  12. stop the board, flash the firmware, restart:
  13. reset halt
  14. wait_halt
  15. sleep 100
  16. poll
  17. flash probe 0
  18. flash write_image erase /home/user/git/inav/obj/inav_SPRACINGF3.hex 0x08000000
  19. sleep 200
  20. soft_reset_halt
  21. wait_halt
  22. poll
  23. reset halt
  24. A this point you can launch the debug in Eclispe.
  25. ![](http://i.imgur.com/u7wDgxv.png)
  26. # GDB and J Link
  27. Here are some screenshots showing Hydra's configuration of Eclipse (Kepler)
  28. If you use cygwin to build the binaries then be sure to have configured your common `Source Lookup Path`, `Path Mappings` first, like this:
  29. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 7.PNG)
  30. Create a new `GDB Hardware Debugging` launch configuration from the `Run` menu
  31. It's important to have build the executable compiled with GDB debugging information first.
  32. Select the appropriate .elf file (not hex file).
  33. DISABLE auto-build
  34. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 1.PNG)
  35. Choose the appropriate gdb executable - ideally from the same toolchain that you use to build the executable.
  36. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 2.PNG)
  37. Configure Startup as follows
  38. Initialization commands
  39. ```
  40. target remote localhost:2331
  41. monitor interface SWD
  42. monitor speed 2000
  43. monitor flash device = STM32F103RB
  44. monitor flash download = 1
  45. monitor flash breakpoints = 1
  46. monitor endian little
  47. monitor reset
  48. ```
  49. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 3.PNG)
  50. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 4.PNG)
  51. It may be useful to specify run commands too:
  52. ```
  53. monitor reg r13 = (0x00000000)
  54. monitor reg pc = (0x00000004)
  55. continue
  56. ```
  57. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 13.PNG)
  58. If you use cygwin an additional entry should be shown on the Source tab (not present in this screenshot)
  59. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 5.PNG)
  60. Nothing to change from the defaults on the Common tab
  61. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 6.PNG)
  62. Start up the J-Link server in USB mode
  63. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 9.PNG)
  64. If it connects to your target device it should look like this
  65. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 10.PNG)
  66. From Eclipse launch the application using the Run/Debug Configurations..., Eclipse should upload the compiled file to the target device which looks like this
  67. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 11.PNG)
  68. When it's running the J-Link server should look like this.
  69. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 12.PNG)
  70. Then finally you can use Eclipse debug features to inspect variables, memory, stacktrace, set breakpoints, step over code, etc.
  71. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/debugging.PNG)
  72. If Eclipse can't find your breakpoints and they are ignored then check your path mappings (if using cygwin) or use the other debugging launcher as follows. Note the 'Select other...' at the bottom of the configuration window.
  73. ![](https://raw.github.com/wiki/cleanflight/cleanflight/images/eclipse-gdb-debugging/config 8 - If breakpoints do not work.PNG)