# J-Link setup
adapter speed 10000 ;# kHz
adapter driver jlink
#######################################################
# config core(s)/hart(s) to connect
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu0 -irlen 5
jtag newtap $_CHIPNAME cpu1 -irlen 5
scan_chain
# -coreid N: hartN, -rtos hwthread: all harts bus only hart0 enabled
# sel_e24: 0 for u7mc, 1 for e2
set sel_e24 1
if { $sel_e24 == 1 } {
set _TARGETNAME_0 $_CHIPNAME.cpu0
# e2
target create $_TARGETNAME_0 riscv -chain-position $_CHIPNAME.cpu0 -rtos hwthread
#$_TARGETNAME_0 configure -work-area-phys 0x2a020000 -work-area-size 10000 -work-area-backup 1
} else {
set _TARGETNAME_0 $_CHIPNAME.cpu0
set _TARGETNAME_1 $_CHIPNAME.cpu1
set _TARGETNAME_2 $_CHIPNAME.cpu2
set _TARGETNAME_3 $_CHIPNAME.cpu3
set _TARGETNAME_4 $_CHIPNAME.cpu4
# u7mc
#target create $_TARGETNAME_0 riscv -chain-position $_CHIPNAME.cpu1 -rtos hwthread
target create $_TARGETNAME_1 riscv -chain-position $_CHIPNAME.cpu1 -coreid 1
#target create $_TARGETNAME_2 riscv -chain-position $_CHIPNAME.cpu1 -coreid 2
#target create $_TARGETNAME_3 riscv -chain-position $_CHIPNAME.cpu1 -coreid 3
#target create $_TARGETNAME_4 riscv -chain-position $_CHIPNAME.cpu1 -coreid 4
#target smp $_TARGETNAME_0 $_TARGETNAME_1 $_TARGETNAME_2 $_TARGETNAME_3 $_TARGETNAME_4
#$_TARGETNAME_0 configure -work-area-phys 0x2a020000 -work-area-size 10000 -work-area-backup 1
}
init
halt
if { $sel_e24 == 0 } {
# e24 is default disabled, shall be enabled from u7mc
#######enable e24
##_ENABLE_CLOCK_CLK_U0_E2_SFT7110_CLK_CORE_
mww phys 0x10230064 0x80000000 ;
##_ENABLE_CLOCK_CLK_U0_E2_SFT7110_CLK_DBG_
mww phys 0x10230068 0x80000000 ;
##_ENABLE_CLOCK_CLK_U0_E2_SFT7110_RTC_CLK_
mww phys 0x10230060 0x80000018 ;
##_CLEAR_RESET_RSTGEN_RST_U0_E2_SFT7110_RST_CORE_
mww phys 0x10230074 0x7fffee ;
}
# zero init L2LIM: secondboot should've done this, if not, read L2LIM will cause exception 1
set zero_L2LIM_len 0
if { $zero_L2LIM_len > 0 } {
# last 128k is reserved for cache way0
set L2LIM_size [expr (2 * 1024 - 128) * 1024]
set L2LIM_start 0x8000000
if { $zero_L2LIM_len > $L2LIM_size } {
set zero_L2LIM_len $L2LIM_size
}
set end_addr [expr $L2LIM_start + $zero_L2LIM_len]
set msg [format "zero L2LIM: start 0x%x, size 0x%x" $L2LIM_start $zero_L2LIM_len]
puts "\n$msg"
set addr $L2LIM_start
while { $addr < $end_addr } {
#set msg [format "wzero %x" $addr]
#puts "$msg"
mww phys $addr 0xdeadcafe
set addr [expr $addr + 4]
}
set msg [format "zero L2LIM: size 0x%x done" $zero_L2LIM_len]
puts "$msg\n"
}
echo "Ready for Remote Connections"
得到结果
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : Hardware thread awareness created
Info : J-Link Pro V4 compiled Sep 22 2029 15:00:37
Info : Hardware version: 11.00
Info : VTarget = 3.393 V
Info : clock speed 10000 kHz
Info : JTAG tap: riscv.cpu0 tap/device found: 0x07110cfd (mfg: 0x67e (Guangdong StarFive Technology Co), part: 0x7110, ver: 0x0)
Info : JTAG tap: riscv.cpu1 tap/device found: 0x07110cfd (mfg: 0x67e (Guangdong StarFive Technology Co), part: 0x7110, ver: 0x0)
Info : datacount=1 progbufsize=2
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40901125
Info : starting gdb server for riscv.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Ready for Remote Connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : Hardware thread awareness created
Info : J-Link Pro V4 compiled Sep 22 2029 15:00:37
Info : Hardware version: 11.00
Info : VTarget = 3.393 V
Info : clock speed 10000 kHz
Info : JTAG tap: riscv.cpu0 tap/device found: 0x07110cfd (mfg: 0x67e (Guangdong StarFive Technology Co), part: 0x7110, ver: 0x0)
Info : JTAG tap: riscv.cpu1 tap/device found: 0x07110cfd (mfg: 0x67e (Guangdong StarFive Technology Co), part: 0x7110, ver: 0x0)
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 5 harts
Info : hart 0: XLEN=64, misa=0x8000000000901107
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 5 harts
Info : hart 1: XLEN=64, misa=0x800000000094112f
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 5 harts
Info : hart 2: XLEN=64, misa=0x800000000094112f
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 5 harts
Info : hart 3: XLEN=64, misa=0x800000000094112f
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 5 harts
Info : hart 4: XLEN=64, misa=0x800000000094112f