From c14e9526456622614dd4b79cdbf0a583aabd23e0 Mon Sep 17 00:00:00 2001
From: Philip Attfield <opensource@sequiturlabs.com>
Date: Wed, 14 Sep 2016 07:57:07 +0200
Subject: [PATCH] rpi3: Add debugger config files

.gdbinit stores settings for loading the symbol files at the correct
addresses and pi3.cfg is the JTAG configuration file for OpenOCD.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: David Brown <david.brown@linaro.org>
---
 rpi3/debugger/.gdbinit | 28 ++++++++++++++++++++++++++++
 rpi3/debugger/pi3.cfg  | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 rpi3/debugger/.gdbinit
 create mode 100644 rpi3/debugger/pi3.cfg

diff --git a/rpi3/debugger/.gdbinit b/rpi3/debugger/.gdbinit
new file mode 100644
index 0000000..8cb296f
--- /dev/null
+++ b/rpi3/debugger/.gdbinit
@@ -0,0 +1,28 @@
+target extended-remote localhost:3333
+
+# to debug single core:
+# in u-boot: setenv smp off ; boot
+
+# substitute appropriate value from u-boot startup message (relocation offset)
+add-symbol-file ../../../u-boot/u-boot 0x3af3a000
+add-symbol-file ../../../arm-trusted-firmware/build/rpi3/debug/bl31/bl31.elf 0x08400000
+add-symbol-file ../../../optee_os/out/arm/core/tee.elf 0x08420000
+add-symbol-file ../../../linux/vmlinux 0xffffffc000080800
+
+mon gdb_breakpoint_override hard
+
+flushregs
+
+# bl31_entrypoint
+#b *0x08400000
+
+# TEE entrypoint
+#b *0x08420000
+
+# Linux; primary core entry. 
+# Symbols for initial setup _do not align with vmlinux (elf)_. Debug at instruction
+# level only.
+# Symbols post MMU enable are correct.
+#b *0x080000
+
+mon halt
diff --git a/rpi3/debugger/pi3.cfg b/rpi3/debugger/pi3.cfg
new file mode 100644
index 0000000..4463be8
--- /dev/null
+++ b/rpi3/debugger/pi3.cfg
@@ -0,0 +1,38 @@
+#  RPi3b
+
+tcl_port 5555
+telnet_port 4444
+gdb_port 3333
+
+transport select jtag
+
+adapter_khz 1000
+
+jtag_ntrst_delay 100
+reset_config trst_only separate 
+
+set _CHIPNAME rpi3b
+
+set _TARGETNAME_0 $_CHIPNAME.cpu0
+set _TARGETNAME_1 $_CHIPNAME.cpu1
+set _TARGETNAME_2 $_CHIPNAME.cpu2
+set _TARGETNAME_3 $_CHIPNAME.cpu3
+
+jtag newtap $_CHIPNAME dap -irlen 4 -expected-id 0x4ba00477
+
+target create $_TARGETNAME_0 aarch64 -chain-position $_CHIPNAME.dap -dbgbase 0x80010000 -ctibase 0x80018000
+#target create $_TARGETNAME_1 aarch64 -chain-position $_CHIPNAME.dap -dbgbase 0x80012000 -ctibase 0x80019000
+#target create $_TARGETNAME_2 aarch64 -chain-position $_CHIPNAME.dap -dbgbase 0x80014000 -ctibase 0x8001a000
+#target create $_TARGETNAME_3 aarch64 -chain-position $_CHIPNAME.dap -dbgbase 0x80016000 -ctibase 0x8001b000
+
+#target smp $_CHIPNAME.cpu3 $_CHIPNAME.cpu2 $_CHIPNAME.cpu1 $_CHIPNAME.cpu0
+
+proc rpi3b_gdb_attach {target} {
+  echo "gdb attach halt ..."
+  targets 0
+  halt
+}
+
+$_TARGETNAME_0 configure -event gdb-attach {
+  halt
+}
-- 
GitLab