| 1 | = Raspberry Pi Debugging with OpenOCD = |
| 2 | |
| 3 | [[TOC(Debugging/OpenOCD/Raspberry_Pi , depth=2)]] |
| 4 | |
| 5 | The scripts for OpenOCD debugging can be found in my |
| 6 | [https://github.com/ppisa/rpi-utils/tree/master/jtag-debug rpi-utils] |
| 7 | GitHUB repo for example. They are listed below as well. |
| 8 | |
| 9 | I have issues to load application image over JTAG (some data corruption, |
| 10 | may it be by overload of bus arbitration). But when application is load |
| 11 | over TFTP from U-boot it can be fully debugged. |
| 12 | |
| 13 | The JTAG interface has to be enabled first. For U-boot based |
| 14 | RTEMS image load it can be achieved by U-boot commands |
| 15 | {{{ |
| 16 | mw.l 0x20200000 0x04a020 |
| 17 | mw.l 0x20200008 0x65b6c0 |
| 18 | }}} |
| 19 | |
| 20 | File "rpi-jt_usb5.cfg": |
| 21 | {{{ |
| 22 | #daemon configuration |
| 23 | telnet_port 4444 |
| 24 | gdb_port 3333 |
| 25 | |
| 26 | # tell gdb our flash memory map |
| 27 | # and enable flash programming |
| 28 | #gdb_memory_map enable |
| 29 | #gdb_flash_program enable |
| 30 | |
| 31 | interface ftdi |
| 32 | #ftdi_device_desc "Dual RS232" |
| 33 | ftdi_vid_pid 0x0403 0x6010 |
| 34 | |
| 35 | ftdi_layout_init 0x0cf8 0x0cfb |
| 36 | ftdi_layout_signal nTRST -data 0x0010 -noe 0x0800 |
| 37 | ftdi_layout_signal nSRST -ndata 0x0040 -noe 0x0400 |
| 38 | |
| 39 | ftdi_layout_signal nTRST -data 0x0010 |
| 40 | ftdi_layout_signal nSRST -ndata 0x0040 |
| 41 | ftdi_layout_signal LED -ndata 0x0800 |
| 42 | |
| 43 | transport select jtag |
| 44 | |
| 45 | #ftdi_layout_signal SWD_EN -ndata 0x0400 |
| 46 | #ftdi_layout_signal SWDIO_OE -alias TMS |
| 47 | |
| 48 | adapter_khz 500 |
| 49 | |
| 50 | reset_config none |
| 51 | |
| 52 | #jtag_nsrst_delay 400 |
| 53 | #jtag_ntrst_delay 400 |
| 54 | |
| 55 | if { [info exists CHIPNAME] } { |
| 56 | set _CHIPNAME $CHIPNAME |
| 57 | } else { |
| 58 | set _CHIPNAME raspi |
| 59 | } |
| 60 | |
| 61 | reset_config none |
| 62 | |
| 63 | if { [info exists CPU_TAPID ] } { |
| 64 | set _CPU_TAPID $CPU_TAPID |
| 65 | } else { |
| 66 | set _CPU_TAPID 0x07b7617F |
| 67 | } |
| 68 | jtag newtap $_CHIPNAME arm -irlen 5 -expected-id $_CPU_TAPID |
| 69 | |
| 70 | set _TARGETNAME $_CHIPNAME.arm |
| 71 | target create $_TARGETNAME arm11 -chain-position $_TARGETNAME |
| 72 | |
| 73 | adapter_khz 500 |
| 74 | |
| 75 | init |
| 76 | |
| 77 | #reset halt |
| 78 | |
| 79 | #wait_halt |
| 80 | |
| 81 | # check TDO connection |
| 82 | #echo 24 > /sys/class/gpio/export |
| 83 | #echo out > /sys/class/gpio/gpio24/direction |
| 84 | #echo 1 > /sys/class/gpio/gpio24/value |
| 85 | }}} |
| 86 | |
| 87 | File "gdb-openocd.init": |
| 88 | {{{ |
| 89 | target remote localhost:3333 |
| 90 | #load |
| 91 | }}} |
| 92 | |
| 93 | File "rpi-jt_usb5-ddd" |
| 94 | {{{ |
| 95 | #!/bin/sh |
| 96 | |
| 97 | SCRIP_DIR="$(dirname "$(readlink -f "$0")")" |
| 98 | |
| 99 | nc -w 3 -z localhost 4444 |
| 100 | if [ $? -ne 0 ] |
| 101 | then |
| 102 | echo "Starting OpenOCD" |
| 103 | openocd -f "$SCRIP_DIR/rpi-jt_usb5.cfg" & |
| 104 | OPENOCD_PID=$! |
| 105 | nc -w 10 -z localhost 4444 |
| 106 | if [ $? -ne 0 ] |
| 107 | then |
| 108 | echo "OpenOCD start failed" |
| 109 | fi |
| 110 | fi |
| 111 | |
| 112 | ddd --debugger arm-elf-gdb -x "$SCRIP_DIR/gdb-openocd.init" "$1" |
| 113 | |
| 114 | kill $OPENOCD_PID |
| 115 | }}} |