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/+/9753

-- gerrit

commit 5639ae73fe8ae1757d50be9d52bd5031d625cb77
Author: Zane Leung <[email protected]>
Date:   Wed Jun 24 11:10:20 2026 +0800

    tcl/target: Add SpacemiT keystone k1 config
    
    Add basic connection details with keystone k1
    
    Change-Id: I0f7b743ae9da99deca72e8a09f7eb69c02bafc60
    Signed-off-by: Zane Leung <[email protected]>

diff --git a/tcl/target/spacemit-k3.cfg b/tcl/target/spacemit-k3.cfg
new file mode 100755
index 0000000000..53d1f66e06
--- /dev/null
+++ b/tcl/target/spacemit-k3.cfg
@@ -0,0 +1,135 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+#
+# SpacemiT Key Stone K3 target
+#
+# https://www.spacemit.com/products/keystone/k3
+#
+
+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 k3
+}
+
+# Set TARGET to "rcpu" to enable JTAG for RCPU
+if { [info exists TARGET] } {
+    set _TARGET $TARGET
+} else {
+    set _TARGET acpu
+}
+
+if { $_TARGET == "rcpu" } {
+    set _CPUTAPID 0x10308A6D
+    set _DRVAL 0xe
+} else {
+    set _CPUTAPID 0x10000E21
+    set _DRVAL 0xa
+}
+
+if { [info exists CLUSTERS] } {
+    set _CLUSTERS $CLUSTERS
+} else {
+    set _CLUSTERS {0 1 2 3}
+}
+
+for {set i 0} {$i < 4} {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] } {
+    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 configure $_CHIPNAME.cpu -event tap-enable ""
+
+    jtag newtap post unknown -irlen 9 -expected-id 0x08502C0D -ignore-version
+
+    jtag configure post.unknown -event setup {
+        global _CHIPNAME _DRVAL
+
+        irscan post.unknown 0x98
+        drscan post.unknown 16 $_DRVAL
+
+        jtag tapenable pre.unknown
+        jtag tapenable $_CHIPNAME.cpu
+    }
+}
+
+set _smp_command "target smp"
+
+if { $_TARGET == "rcpu" } {
+    set _TARGETNAME $_CHIPNAME.$_TARGET
+    foreach coreid $_CLUSTER0_COREIDS {
+        if { $coreid >= 2 } {
+            echo [format "Warning: rcpu index %u is out of range (0..1), it 
will be ignored" $coreid]
+            continue
+        }
+        target create $_TARGETNAME.$coreid riscv -chain-position 
$_CHIPNAME.cpu \
+            -coreid $coreid
+
+        if { $coreid == 0 } {
+            $_TARGETNAME.$coreid configure -rtos hwthread
+        }
+
+        set _smp_command "$_smp_command $_TARGETNAME.$coreid"
+    }
+} else {
+    foreach cluster $_CLUSTERS {
+        if { $cluster < 2 } {
+            set _TARGETNAME $_CHIPNAME.x100
+        } elseif { $cluster < 4 } {
+            set _TARGETNAME $_CHIPNAME.a100
+        } else {
+            echo [format "Warning: acpu cluster %u is out of range (0..3), it 
will be ignored" $cluster]
+            continue
+        }
+
+        set dbgbase [expr {$cluster * 0x400}]
+        foreach coreid [set _CLUSTER${cluster}_COREIDS] {
+            if { $coreid >= 4 } {
+                echo [format "Warning: acpu 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
+
+            if { $hartid == 0 } {
+                $_TARGETNAME.$hartid configure -rtos hwthread
+            }
+
+            set _smp_command "$_smp_command $_TARGETNAME.$hartid"
+        }
+    }
+}
+
+eval $_smp_command
+
+[target current] configure -event examine-end {
+    adapter speed $_SPEED
+    puts [ adapter speed ]
+    puts [ targets ]
+}

-- 

Reply via email to