1 # SPDX-License-Identifier: GPL-2.0-or-later
7 source [find target/swj-dp.tcl]
9 if { [info exists CHIPNAME] } {
10 set _CHIPNAME $CHIPNAME
15 if { [info exists WORKAREASIZE] } {
16 set _WORKAREASIZE $WORKAREASIZE
18 set _WORKAREASIZE 0x8000
21 if { [info exists CPUTAPID] } {
22 set _CPUTAPID $CPUTAPID
24 set _CPUTAPID 0x2ba01477
27 swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
28 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
30 set _TARGETNAME $_CHIPNAME.cpu
31 target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
33 $_TARGETNAME configure -work-area-phys 0x200000 -work-area-size $_WORKAREASIZE -work-area-backup 0
35 # TODO: configure reset
36 # reset_config srst_only srst_nogate connect_assert_srst
38 $_TARGETNAME configure -event examine-fail rsl10_lock_warning
40 proc rsl10_check_connection {} {
41 set target [target current]
42 set dap [$target cget -dap]
44 set IDR [$dap apreg 0 0xfc]
45 if {$IDR != 0x24770011} {
46 echo "Error: Cannot access RSL10 AP, maybe connection problem!"
52 proc rsl10_lock_warning {} {
53 if {[rsl10_check_connection]} {return}
56 echo "****** WARNING ******"
57 echo "RSL10 device probably has lock engaged."
58 echo "Debug access is denied."
59 echo "Use 'rsl10 unlock key1 key2 key3 key4' to erase and unlock the device."
60 echo "****** ....... ******"
64 flash bank $_CHIPNAME.main rsl10 0x00100000 0x60000 0 0 $_TARGETNAME
65 flash bank $_CHIPNAME.nvr1 rsl10 0x00080000 0x800 0 0 $_TARGETNAME
66 flash bank $_CHIPNAME.nvr2 rsl10 0x00080800 0x800 0 0 $_TARGETNAME
67 flash bank $_CHIPNAME.nvr3 rsl10 0x00081000 0x800 0 0 $_TARGETNAME
69 # TODO: implement flashing for nvr4
70 # flash bank $_CHIPNAME.nvr4 rsl10 0x00081800 0x400 0 0 $_TARGETNAME