|
1 | 1 | --- |
2 | | -title: Debugging |
| 2 | +title: Debugging FPGAs with OpenOCD and GDB |
3 | 3 | layout: home |
4 | 4 | --- |
5 | 5 |
|
6 | | -## Debugging OpenRISC |
| 6 | +### Prerequisites |
7 | 7 |
|
8 | | -The OpenRISC cpu, simulator and toolchain provide a full debugging |
9 | | -environment with gdb and OpenOCD. At a low level this is provided with |
10 | | -[adv_debug_sys](https://github.com/olofk/adv_debug_sys) which provides |
11 | | -jtag interface for OpenOCD to talk to. Much can be done directly in OpenOCD. But |
12 | | -for a full debug environments we recommend GDB. GDB communicates with OpenOCD as |
13 | | -a remote target and provides a familiar debugging environment for programmers. |
| 8 | +#### Software |
| 9 | + |
| 10 | +* `or1k-elf` toolchain with gdb [Releases](https://github.com/stffrdhrn/or1k-toolchain-build/releases) |
| 11 | +* OpenOCD |
| 12 | +* A running OpenRISC SoC using `adv_debug_sys` |
| 13 | + |
| 14 | +## Debugging OpenRISC on FPGAs |
| 15 | + |
| 16 | +The OpenRISC cpu and toolchain provide a full debugging environment when running |
| 17 | +on FPGAs using gdb and OpenOCD. At a low level this is provided with |
| 18 | +[adv_debug_sys](https://github.com/olofk/adv_debug_sys) which provides jtag |
| 19 | +interface for OpenOCD to talk to. Much can be done directly in OpenOCD. But for |
| 20 | +a full debug environments we recommend GDB. GDB communicates with OpenOCD as a |
| 21 | +remote target and provides a familiar debugging environment for programmers. |
14 | 22 |
|
15 | 23 | ### OpenOCD Basics |
16 | 24 |
|
| 25 | +OpenOCD is a brirdge for accessing hardware connected to a workstation via JTAG. |
17 | 26 | OpenOCD requires a configuration file to start up. The configuration files |
18 | 27 | specify the chips details (jtag tap) and the details of the interface we are |
19 | 28 | using. |
@@ -75,7 +84,7 @@ reg npc 0x100 |
75 | 84 | # Resume execution after a halt |
76 | 85 | resume |
77 | 86 |
|
78 | | -# For loading a linux image you can do it all at one time. |
| 87 | +# For loading a linux image you can do it all at one time. |
79 | 88 | # Notice here we also reset r3 which linux uses as a bootargs |
80 | 89 | # vector. |
81 | 90 | halt; load_image vmlinux; reg r3 0; reg npc 0x100; resume |
@@ -114,7 +123,12 @@ exit |
114 | 123 |
|
115 | 124 | ### GDB Basics |
116 | 125 |
|
117 | | -When we run GDB we do remote debugging |
| 126 | +[GDB](https://sourceware.org/gdb/) is a very popular debugger that allows |
| 127 | +inspecting programs running on a cpu (target). |
| 128 | + |
| 129 | +When we debug OpenRISC cpus running on FPGAs GDB connects to the remote OpenRISC |
| 130 | +target via the debug tcp port provided by OpenOCD. Once OpenOCD is running we |
| 131 | +can start GDB as follows: |
118 | 132 |
|
119 | 133 | ``` |
120 | 134 | # Starting up gdb (with a remote target) |
@@ -264,6 +278,6 @@ These commands and further reading should get you started. |
264 | 278 |
|
265 | 279 | ### Further Reading |
266 | 280 |
|
267 | | -* http://openocd.org/doc/html/ - OpenOCD User Guide |
268 | | -* http://www.fpga4fun.com/JTAG2.html - How JTAG works |
269 | | -* https://sourceware.org/gdb/onlinedocs/gdb/ - Debugging with GDB |
| 281 | +* [OpenOCD Docs](http://openocd.org/doc/html/) - OpenOCD User Guide |
| 282 | +* [JTAG](http://www.fpga4fun.com/JTAG2.html) - How JTAG works |
| 283 | +* [GDD Docs](https://sourceware.org/gdb/onlinedocs/gdb/) - Debugging with GDB |
0 commit comments