src/flash/nor: flash driver for RSL10
[fw/openocd] / tcl / target / rsl10.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 #
4 # RSL10: ARM Cortex-M3
5 #
6
7 source [find target/swj-dp.tcl]
8
9 if { [info exists CHIPNAME] } {
10         set _CHIPNAME $CHIPNAME
11 } else {
12         set _CHIPNAME rsl10
13 }
14
15 if { [info exists WORKAREASIZE] } {
16    set _WORKAREASIZE $WORKAREASIZE
17 } else {
18    set _WORKAREASIZE 0x8000
19 }
20
21 if { [info exists CPUTAPID] } {
22         set _CPUTAPID $CPUTAPID
23 } else {
24         set _CPUTAPID 0x2ba01477
25 }
26
27 swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
28 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
29
30 set _TARGETNAME $_CHIPNAME.cpu
31 target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
32
33 $_TARGETNAME configure -work-area-phys 0x200000 -work-area-size $_WORKAREASIZE -work-area-backup 0
34
35 # TODO: configure reset
36 # reset_config srst_only srst_nogate connect_assert_srst
37
38 $_TARGETNAME configure -event examine-fail rsl10_lock_warning
39
40 proc rsl10_check_connection {} {
41     set target [target current]
42     set dap [$target cget -dap]
43
44         set IDR [$dap apreg 0 0xfc]
45         if {$IDR != 0x24770011} {
46                 echo "Error: Cannot access RSL10 AP, maybe connection problem!"
47                 return 1
48         }
49     return 0
50 }
51
52 proc rsl10_lock_warning {} {
53     if {[rsl10_check_connection]} {return}
54
55     poll off
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 "****** ....... ******"
61     echo ""
62 }
63
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
68
69 # TODO: implement flashing for nvr4
70 # flash bank $_CHIPNAME.nvr4 rsl10 0x00081800 0x400 0 0 $_TARGETNAME