wiki:Debugging/OpenOCD/Raspberry_Pi
Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Version 1 (modified by Pavel Pisa, on 09/17/15 at 17:20:49) (diff)

Raspberry Pi debugging with OpenOCD.

Raspberry Pi Debugging with OpenOCD

The scripts for OpenOCD debugging can be found in my rpi-utils GitHUB repo for example. They are listed below as well.

I have issues to load application image over JTAG (some data corruption, may it be by overload of bus arbitration). But when application is load over TFTP from U-boot it can be fully debugged.

The JTAG interface has to be enabled first. For U-boot based RTEMS image load it can be achieved by U-boot commands

mw.l 0x20200000 0x04a020
mw.l 0x20200008 0x65b6c0

File "rpi-jt_usb5.cfg":

#daemon configuration
telnet_port 4444
gdb_port 3333

# tell gdb our flash memory map
# and enable flash programming
#gdb_memory_map enable
#gdb_flash_program enable

interface ftdi
#ftdi_device_desc "Dual RS232"
ftdi_vid_pid 0x0403 0x6010

ftdi_layout_init 0x0cf8 0x0cfb
ftdi_layout_signal nTRST -data 0x0010 -noe 0x0800
ftdi_layout_signal nSRST -ndata 0x0040 -noe 0x0400

ftdi_layout_signal nTRST -data 0x0010
ftdi_layout_signal nSRST -ndata 0x0040
ftdi_layout_signal LED -ndata 0x0800

transport select jtag

#ftdi_layout_signal SWD_EN -ndata 0x0400
#ftdi_layout_signal SWDIO_OE -alias TMS

adapter_khz 500

reset_config none

#jtag_nsrst_delay 400
#jtag_ntrst_delay 400

if { [info exists CHIPNAME] } {
   set  _CHIPNAME $CHIPNAME
} else {
   set  _CHIPNAME raspi
}

reset_config none

if { [info exists CPU_TAPID ] } {
   set _CPU_TAPID $CPU_TAPID
} else {
   set _CPU_TAPID 0x07b7617F
}
jtag newtap $_CHIPNAME arm -irlen 5 -expected-id $_CPU_TAPID

set _TARGETNAME $_CHIPNAME.arm
target create $_TARGETNAME arm11 -chain-position $_TARGETNAME

adapter_khz 500

init

#reset halt

#wait_halt

# check TDO connection
#echo 24 > /sys/class/gpio/export
#echo out > /sys/class/gpio/gpio24/direction
#echo 1 > /sys/class/gpio/gpio24/value

File "gdb-openocd.init":

target remote localhost:3333
#load

File "rpi-jt_usb5-ddd"

#!/bin/sh

SCRIP_DIR="$(dirname "$(readlink -f "$0")")"

nc -w 3 -z localhost 4444
if [ $? -ne 0 ]
then
  echo "Starting OpenOCD"
  openocd -f "$SCRIP_DIR/rpi-jt_usb5.cfg" &
  OPENOCD_PID=$!
  nc -w 10 -z localhost 4444
  if [ $? -ne 0 ]
  then
    echo "OpenOCD start failed"
  fi
fi

ddd --debugger arm-elf-gdb -x "$SCRIP_DIR/gdb-openocd.init" "$1"

kill $OPENOCD_PID