From 5a304557a78f444da51a207f64bab93f6fcfebdd Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Sun, 28 Feb 2021 13:10:03 +0200 Subject: [PATCH] build(tools): Add RasPi4 target configuration for OpenOCD Update and move rpi3 jtag configs. Add rpi bringup doc - lists romtables for configuring. --- nucleus/Makefile.toml | 2 +- {doc/rpi2rpi_jtag => ocd}/rpi3_target.cfg | 43 ++++++++++------ ocd/rpi4_target.cfg | 62 +++++++++++++++++++++++ 3 files changed, 90 insertions(+), 17 deletions(-) rename {doc/rpi2rpi_jtag => ocd}/rpi3_target.cfg (80%) create mode 100644 ocd/rpi4_target.cfg diff --git a/nucleus/Makefile.toml b/nucleus/Makefile.toml index 9bd55cf..8278677 100644 --- a/nucleus/Makefile.toml +++ b/nucleus/Makefile.toml @@ -87,7 +87,7 @@ env = { "QEMU_RUNNER_OPTS" = "${QEMU_SERIAL_OPTS} ${QEMU_GDB_OPTS}" } [tasks.openocd] dependencies = ["build", "kernel-binary"] script = [ - "${OPENOCD} -f interface/jlink.cfg -f ../doc/rpi2rpi_jtag/rpi3_target.cfg" + "${OPENOCD} -f interface/jlink.cfg -f ../ocd/rpi4_target.cfg" ] [tasks.gdb-config] diff --git a/doc/rpi2rpi_jtag/rpi3_target.cfg b/ocd/rpi3_target.cfg similarity index 80% rename from doc/rpi2rpi_jtag/rpi3_target.cfg rename to ocd/rpi3_target.cfg index eb206e6..aa636c2 100644 --- a/doc/rpi2rpi_jtag/rpi3_target.cfg +++ b/ocd/rpi3_target.cfg @@ -1,32 +1,32 @@ -# Broadcom 2837 on Raspberry Pi 3 as JTAG target +# Broadcom bcm2837 on Raspberry Pi 3 as JTAG target # From https://www.suse.com/c/debugging-raspberry-pi-3-with-jtag/ -telnet_port 4444 -gdb_port 5555 - -transport select jtag - -# we need to enable srst even though we don't connect it -reset_config trst_and_srst - -adapter speed 4000 -jtag_ntrst_delay 500 - if { [info exists CHIPNAME] } { set _CHIPNAME $CHIPNAME } else { - set _CHIPNAME rpi3 + set _CHIPNAME bcm2837 } -# -# Main DAP -# if { [info exists DAP_TAPID] } { set _DAP_TAPID $DAP_TAPID } else { set _DAP_TAPID 0x4ba00477 } +adapter speed 4000 + +transport select jtag +# we need to enable srst even though we don't connect it +reset_config trst_and_srst + +jtag_ntrst_delay 500 + +telnet_port 4444 +gdb_port 5555 + +# +# Main DAP +# jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_DAP_TAPID -enable dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap @@ -35,7 +35,9 @@ set _CTINAME $_CHIPNAME.cti set DBGBASE {0x80010000 0x80012000 0x80014000 0x80016000} set CTIBASE {0x80018000 0x80019000 0x8001a000 0x8001b000} + set _cores 4 +set _smp_command "" for { set _core 0 } { $_core < $_cores } { incr _core } { @@ -46,6 +48,15 @@ for { set _core 0 } { $_core < $_cores } { incr _core } { -dap $_CHIPNAME.dap -coreid $_core \ -dbgbase [lindex $DBGBASE $_core] -cti $_CTINAME.$_core + if {$_core != 0} { + set _smp_command "$_smp_command ${_TARGETNAME}.${_core}" + } else { + set _smp_command "target smp ${_TARGETNAME}.${_core}" + } + $_TARGETNAME.$_core configure -event reset-assert-post "aarch64 dbginit" $_TARGETNAME.$_core configure -event gdb-attach { halt } } + +eval $_smp_command +targets $_TARGETNAME.0 diff --git a/ocd/rpi4_target.cfg b/ocd/rpi4_target.cfg new file mode 100644 index 0000000..27ea7b3 --- /dev/null +++ b/ocd/rpi4_target.cfg @@ -0,0 +1,62 @@ +# Broadcom bcm2711 on Raspberry Pi 4 as JTAG target +# From https://gist.github.com/tnishinaga/46a3380e1f47f5e892bbb74e55b3cf3e +# See also https://xihan94.gitbook.io/raspberry-pi/raspberry-pi-4-bringup + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME bcm2711 +} + +if { [info exists DAP_TAPID] } { + set _DAP_TAPID $DAP_TAPID +} else { + set _DAP_TAPID 0x4ba00477 +} + +adapter speed 4000 + +transport select jtag +# we need to enable srst even though we don't connect it +reset_config trst_and_srst + +jtag_ntrst_delay 500 + +telnet_port 4444 +gdb_port 5555 + +# +# Main DAP +# +jtag newtap $_CHIPNAME tap -irlen 4 -expected-id $_DAP_TAPID +dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap + +set _TARGETNAME $_CHIPNAME.a72 +set _CTINAME $_CHIPNAME.cti + +set DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000} +set CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000} + +set _cores 4 +set _smp_command "" + +for { set _core 0 } { $_core < $_cores } { incr _core } { + cti create $_CTINAME.$_core -dap $_CHIPNAME.dap -ap-num 0 \ + -baseaddr [lindex $CTIBASE $_core] + + target create ${_TARGETNAME}.${_core} aarch64 \ + -dap ${_CHIPNAME}.dap -coreid $_core \ + -dbgbase [lindex $DBGBASE $_core] -cti ${_CTINAME}.${_core} + + if {$_core != 0} { + set _smp_command "$_smp_command ${_TARGETNAME}.${_core}" + } else { + set _smp_command "target smp ${_TARGETNAME}.${_core}" + } + + $_TARGETNAME.$_core configure -event reset-assert-post "aarch64 dbginit" + $_TARGETNAME.$_core configure -event gdb-attach { halt } +} + +eval $_smp_command +targets $_TARGETNAME.0