This is an automated email from Gerrit. "liangzhen <[email protected]>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9754
-- gerrit commit f79008d08be96d673ffd52d6246a022fb1c18cf0 Author: Zane Leung <[email protected]> Date: Wed Jun 24 11:31:56 2026 +0800 tcl/target: Refactor SpacemiT keystone k1 config Refactor spacemit-k1.cfg to support flexible multi-core configurations Change-Id: I65cdcabb66718bf6f13cb8b09d21a741ad0bc3b3 Signed-off-by: Zane Leung <[email protected]> diff --git a/tcl/target/spacemit-k1.cfg b/tcl/target/spacemit-k1.cfg index e57d1adbc8..bd6b2ca804 100644 --- a/tcl/target/spacemit-k1.cfg +++ b/tcl/target/spacemit-k1.cfg @@ -3,13 +3,24 @@ # # SpacemiT Key Stone K1 target # -# https://www.spacemit.com/key-stone-k1 +# https://www.spacemit.com/products/keystone/k1 # transport select jtag - adapter speed 2000 +if { [info exists SPEED] } { + set _SPEED $SPEED +} else { + set _SPEED 8000 +} + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME k1 +} + # Set TARGET to "rcpu" to enable JTAG for RCPU if { [info exists TARGET] } { set _TARGET $TARGET @@ -18,77 +29,88 @@ if { [info exists TARGET] } { } if { $_TARGET == "rcpu" } { - set CPUTAPID 0x10308A6D - set DRVAL 0xe + set _CPUTAPID 0x10308A6D + set _DRVAL 0xe } else { - set CPUTAPID 0x10000E21 - set DRVAL 0xa + set _CPUTAPID 0x10000E21 + set _DRVAL 0xa } -if { [info exists CHIPNAME] } { - set _CHIPNAME $CHIPNAME +if { [info exists CLUSTERS] } { + set _CLUSTERS $CLUSTERS } else { - set _CHIPNAME k1 + set _CLUSTERS {0 1} } -if { [info exists CORES] } { - set _cores $CORES -} else { - set _cores 1 +for {set i 0} {$i < 2} {incr i} { + if { [info exists CLUSTER${i}_COREIDS] } { + set _CLUSTER${i}_COREIDS [set CLUSTER${i}_COREIDS] + } else { + set _CLUSTER${i}_COREIDS {0 1 2 3} + } } if { [info exists SECJTAG] } { - jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $CPUTAPID + set _SECJTAG $SECJTAG +} else { + set _SECJTAG 0 +} + +if { $_SECJTAG == 1 } { + jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $_CPUTAPID } else { jtag newtap pre unknown -irlen 1 -expected-id 0x00000000 -disable jtag configure pre.unknown -event tap-enable "" - jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $CPUTAPID -disable + jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $_CPUTAPID -disable jtag configure $_CHIPNAME.cpu -event tap-enable "" jtag newtap post unknown -irlen 9 -expected-id 0x08501C0D -ignore-version jtag configure post.unknown -event setup { - global _CHIPNAME DRVAL + global _CHIPNAME _DRVAL irscan post.unknown 0x98 - drscan post.unknown 16 $DRVAL + drscan post.unknown 16 $_DRVAL jtag tapenable pre.unknown jtag tapenable $_CHIPNAME.cpu } } -set _TARGETNAME $_CHIPNAME.cpu_$_TARGET - +set _TARGETNAME $_CHIPNAME.$_TARGET if { $_TARGET == "rcpu" } { - target create $_TARGETNAME.0 riscv -chain-position $_CHIPNAME.cpu + target create $_TARGETNAME riscv -chain-position $_CHIPNAME.cpu } else { - set DBGBASE {0x0 0x400} set _smp_command "target smp" - - for { set _core 0 } { $_core < $_cores } { incr _core } { - target create $_TARGETNAME.$_core riscv -chain-position $_CHIPNAME.cpu \ - -coreid [expr {$_core % 4}] -dbgbase [lindex $DBGBASE [expr {$_core / 4}]] - - if { [expr {$_core % 4}] == 0 } { - $_TARGETNAME.$_core configure -rtos hwthread + foreach cluster $_CLUSTERS { + if { $cluster > 2 } { + echo [format "Warning: x60 cluster %u is out of range (0..1), it will be ignored" $cluster] + continue } - set _smp_command "$_smp_command $_TARGETNAME.$_core" + set dbgbase [expr {$cluster * 0x400}] + foreach coreid [set _CLUSTER${cluster}_COREIDS] { + if { $coreid >= 4 } { + echo [format "Warning: x60 cpu index %u is out of range (0..3), it will be ignored" $coreid] + continue + } + set hartid [expr {$cluster * 4 + $coreid}] + target create $_TARGETNAME.$hartid riscv -chain-position $_CHIPNAME.cpu \ + -coreid $coreid -dbgbase $dbgbase -check-dbgbase off + + if { $hartid == 0 } { + $_TARGETNAME.$hartid configure -rtos hwthread + } + + set _smp_command "$_smp_command $_TARGETNAME.$hartid" + } } - eval $_smp_command } -set _SPEED 8000 - -$_TARGETNAME.0 configure -event examine-start { +[target current] configure -event examine-end { adapter speed $_SPEED puts [ adapter speed ] -} - -foreach t [target names] { - # $t riscv set_mem_access sysbus progbuf - $t riscv set_mem_access progbuf + puts [ targets ] } --
