1# Copyright 2018 NXP
2# SPDX-License-Identifier: BSD-3-Clause
3
4set _WORKAREASIZE 0x2000
5
6adapter speed 1000
7
8interface jlink
9transport select jtag
10
11set _WORKAREASIZE 0x1000
12
13set _CHIPNAME rv32m1
14
15reset_config srst_only
16
17# OpenCores Mohor JTAG TAP ID
18set _CPUTAPID  0x249511C3
19
20jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
21
22set _TARGETNAME $_CHIPNAME.cpu
23target create $_TARGETNAME rv32m1 -endian little -chain-position $_TARGETNAME
24
25# Select the TAP core we are using
26tap_select mohor
27
28# Select the debug unit core we are using. This debug unit as an option.
29
30set ADBG_USE_HISPEED		1
31
32# If ADBG_USE_HISPEED is set (options bit 1), status bits will be skipped
33# on burst reads and writes to improve download speeds.
34# This option must match the RTL configured option.
35
36du_select adv [expr $ADBG_USE_HISPEED]
37
38# Select core 0
39core_select 0
40
41$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
42$_TARGETNAME configure -event gdb-detach {
43    resume
44}
45set _FLASHNAME $_CHIPNAME.flash
46flash bank $_CHIPNAME.flash0 rv32m1 0 0 0 0 $_TARGETNAME # For core 0
47flash bank $_CHIPNAME.flash1 rv32m1 0x01000000 0 0 0 $_TARGETNAME # For core 1
48
49proc ri5cy_boot { } {
50
51    # Erase all blok unsecure
52    mwb 0x40023000 0x70
53    mww 0x40023004 0x49000000
54    mwb 0x40023000 0x80
55
56    sleep 1000
57
58    mwb 0x40023000 0x70
59    mww 0x40023008 0xFFFF03FF
60    mww 0x40023004 0x43840000
61    mwb 0x40023000 0x80
62
63    sleep 2
64}
65
66proc cm4_boot { } {
67
68    # Erase all blok unsecure
69    mwb 0x40023000 0x70
70    mww 0x40023004 0x49000000
71    mwb 0x40023000 0x80
72
73    sleep 1000
74
75    mwb 0x40023000 0x70
76    mww 0x40023008 0xFFFFFFFF
77    mww 0x40023004 0x43840000
78    mwb 0x40023000 0x80
79
80    sleep 2
81}
82
83proc zero_boot { } {
84
85    # Erase all blok unsecure
86    mwb 0x40023000 0x70
87    mww 0x40023004 0x49000000
88    mwb 0x40023000 0x80
89
90    sleep 1000
91
92    mwb 0x40023000 0x70
93    mww 0x40023008 0xFFFF03BF
94    mww 0x40023004 0x43840000
95    mwb 0x40023000 0x80
96
97    sleep 2
98}
99
100proc cm0_boot { } {
101
102    # Erase all blok unsecure
103    mwb 0x40023000 0x70
104    mww 0x40023004 0x49000000
105    mwb 0x40023000 0x80
106
107    sleep 1000
108
109    mwb 0x40023000 0x70
110    mww 0x40023008 0xFFFFFFBF
111    mww 0x40023004 0x43840000
112    mwb 0x40023000 0x80
113
114    sleep 2
115}
116
117# All cores are available, CM4 & RI5CY boot first
118proc core0_boot { } {
119
120    # Erase all blok unsecure
121    mwb 0x40023000 0x70
122    mww 0x40023004 0x49000000
123    mwb 0x40023000 0x80
124
125    sleep 1000
126
127    mwb 0x40023000 0x70
128    mww 0x40023008 0xFFFFA3FF
129    mww 0x40023004 0x43840000
130    mwb 0x40023000 0x80
131
132    sleep 2
133}
134
135# All cores are available, CM0 & ZERO_RISCY boot first
136proc core1_boot { } {
137
138    # Erase all blok unsecure
139    mwb 0x40023000 0x70
140    mww 0x40023004 0x49000000
141    mwb 0x40023000 0x80
142
143    sleep 1000
144
145    mwb 0x40023000 0x70
146    mww 0x40023008 0xFFFFA3BF
147    mww 0x40023004 0x43840000
148    mwb 0x40023000 0x80
149
150    sleep 2
151}
152