tcl/target/ti_k3: Introduce RTOS array variable to set various CPU RTOSes
[openocd.git] / tcl / target / ti_k3.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # Copyright (C) 2019-2021 Texas Instruments Incorporated - http://www.ti.com/
3 #
4 # Texas Instruments K3 devices:
5 # * AM654x: https://www.ti.com/lit/pdf/spruid7
6 # Has 4 ARMV8 Cores and 2 R5 Cores and an M3
7 # * J721E: https://www.ti.com/lit/pdf/spruil1
8 # Has 2 ARMV8 Cores and 6 R5 Cores and an M3
9 # * J7200: https://www.ti.com/lit/pdf/spruiu1
10 # Has 2 ARMV8 Cores and 4 R5 Cores and an M3
11 # * J721S2: https://www.ti.com/lit/pdf/spruj28
12 # Has 2 ARMV8 Cores and 6 R5 Cores and an M4F
13 # * J784S4/AM69: http://www.ti.com/lit/zip/spruj52
14 # Has 8 ARMV8 Cores and 8 R5 Cores
15 # * AM642: https://www.ti.com/lit/pdf/spruim2
16 # Has 2 ARMV8 Cores and 4 R5 Cores, M4F and an M3
17 # * AM625: https://www.ti.com/lit/pdf/spruiv7a
18 # Has 4 ARMV8 Cores and 1 R5 Core and an M4F
19 # * AM62a7: https://www.ti.com/lit/pdf/spruj16a
20 # Has 4 ARMV8 Cores and 2 R5 Cores
21 # * AM62P: https://www.ti.com/lit/pdf/spruj83
22 # Has 4 ARMV8 Cores and 2 R5 Cores
23 #
24
25 source [find target/swj-dp.tcl]
26
27 if { [info exists SOC] } {
28 set _soc $SOC
29 } else {
30 set _soc am654
31 }
32
33 # set V8_SMP_DEBUG to non 0 value in board if you'd like to use SMP debug
34 if { [info exists V8_SMP_DEBUG] } {
35 set _v8_smp_debug $V8_SMP_DEBUG
36 } else {
37 set _v8_smp_debug 0
38 }
39
40 # Common Definitions
41
42 # System Controller is the very first processor - all current SoCs have it.
43 set CM3_CTIBASE {0x3C016000}
44
45 # sysctrl power-ap unlock offsets
46 set _sysctrl_ap_unlock_offsets {0xf0 0x44}
47
48 # All the ARMV8s are the next processors.
49 # CL0,CORE0 CL0,CORE1 CL1,CORE0 CL1,CORE1
50 set ARMV8_DBGBASE {0x90410000 0x90510000 0x90810000 0x90910000}
51 set ARMV8_CTIBASE {0x90420000 0x90520000 0x90820000 0x90920000}
52
53 # And we add up the R5s
54 # (0)MCU 0 (1)MCU 1 (2)MAIN_0_0 (3)MAIN_0_1 (4)MAIN_1_0 (5)MAIN_1_1
55 set R5_DBGBASE {0x9d010000 0x9d012000 0x9d410000 0x9d412000 0x9d510000 0x9d512000}
56 set R5_CTIBASE {0x9d018000 0x9d019000 0x9d418000 0x9d419000 0x9d518000 0x9d519000}
57 set R5_NAMES {mcu_r5.0 mcu_r5.1 main0_r5.0 main0_r5.1 main1_r5.0 main1_r5.1}
58
59 # Finally an General Purpose(GP) MCU
60 set CM4_CTIBASE {0x20001000}
61
62 # General Purpose MCU (M4) may be present on some very few SoCs
63 set _gp_mcu_cores 0
64 # General Purpose MCU power-ap unlock offsets
65 set _gp_mcu_ap_unlock_offsets {0xf0 0x60}
66
67 # Set configuration overrides for each SOC
68 switch $_soc {
69 am654 {
70 set _K3_DAP_TAPID 0x0bb5a02f
71
72 # AM654 has 2 clusters of 2 A53 cores each.
73 set _armv8_cpu_name a53
74 set _armv8_cores 4
75
76 # AM654 has 1 cluster of 2 R5s cores.
77 set _r5_cores 2
78 set R5_NAMES {mcu_r5.0 mcu_r5.1}
79
80 # Sysctrl power-ap unlock offsets
81 set _sysctrl_ap_unlock_offsets {0xf0 0x50}
82 }
83 am642 {
84 set _K3_DAP_TAPID 0x0bb3802f
85
86 # AM642 has 1 clusters of 2 A53 cores each.
87 set _armv8_cpu_name a53
88 set _armv8_cores 2
89 set ARMV8_DBGBASE {0x90010000 0x90110000}
90 set ARMV8_CTIBASE {0x90020000 0x90120000}
91
92 # AM642 has 2 cluster of 2 R5s cores.
93 set _r5_cores 4
94 set R5_NAMES {main0_r5.0 main0_r5.1 main1_r5.0 main1_r5.1}
95 set R5_DBGBASE {0x9d410000 0x9d412000 0x9d510000 0x9d512000}
96 set R5_CTIBASE {0x9d418000 0x9d419000 0x9d518000 0x9d519000}
97
98 # M4 processor
99 set _gp_mcu_cores 1
100 }
101 am625 {
102 set _K3_DAP_TAPID 0x0bb7e02f
103
104 # AM625 has 1 clusters of 4 A53 cores.
105 set _armv8_cpu_name a53
106 set _armv8_cores 4
107 set ARMV8_DBGBASE {0x90010000 0x90110000 0x90210000 0x90310000}
108 set ARMV8_CTIBASE {0x90020000 0x90120000 0x90220000 0x90320000}
109
110 # AM625 has 1 cluster of 1 R5s core.
111 set _r5_cores 1
112 set R5_NAMES {main0_r5.0}
113 set R5_DBGBASE {0x9d410000}
114 set R5_CTIBASE {0x9d418000}
115
116 # sysctrl CTI base
117 set CM3_CTIBASE {0x20001000}
118 # Sysctrl power-ap unlock offsets
119 set _sysctrl_ap_unlock_offsets {0xf0 0x78}
120
121 # M4 processor
122 set _gp_mcu_cores 1
123 set _gp_mcu_ap_unlock_offsets {0xf0 0x7c}
124
125 # Setup DMEM access descriptions
126 # DAPBUS (Debugger) description
127 set _dmem_base_address 0x740002000
128 set _dmem_ap_address_offset 0x100
129 set _dmem_max_aps 10
130 # Emulated AP description
131 set _dmem_emu_base_address 0x760000000
132 set _dmem_emu_base_address_map_to 0x1d500000
133 set _dmem_emu_ap_list 1
134 }
135 am62p -
136 am62a7 {
137 set _K3_DAP_TAPID 0x0bb8d02f
138
139 # AM62a7/AM62P has 1 cluster of 4 A53 cores.
140 set _armv8_cpu_name a53
141 set _armv8_cores 4
142 set ARMV8_DBGBASE {0x90010000 0x90110000 0x90210000 0x90310000}
143 set ARMV8_CTIBASE {0x90020000 0x90120000 0x90220000 0x90320000}
144
145 # AM62a7/AM62P has 2 cluster of 1 R5 core.
146 set _r5_cores 2
147 set R5_NAMES {main0_r5.0 mcu0_r5.0}
148 set R5_DBGBASE {0x9d410000 0x9d810000}
149 set R5_CTIBASE {0x9d418000 0x9d818000}
150
151 # sysctrl CTI base
152 set CM3_CTIBASE {0x20001000}
153 # Sysctrl power-ap unlock offsets
154 set _sysctrl_ap_unlock_offsets {0xf0 0x78}
155
156 # Overrides for am62p
157 if { "$_soc" == "am62p" } {
158 set _K3_DAP_TAPID 0x0bb9d02f
159 set R5_NAMES {wkup0_r5.0 mcu0_r5.0}
160 }
161 }
162 j721e {
163 set _K3_DAP_TAPID 0x0bb6402f
164 # J721E has 1 cluster of 2 A72 cores.
165 set _armv8_cpu_name a72
166 set _armv8_cores 2
167
168 # J721E has 3 clusters of 2 R5 cores each.
169 set _r5_cores 6
170
171 # Setup DMEM access descriptions
172 # DAPBUS (Debugger) description
173 set _dmem_base_address 0x4c40002000
174 set _dmem_ap_address_offset 0x100
175 set _dmem_max_aps 8
176 # Emulated AP description
177 set _dmem_emu_base_address 0x4c60000000
178 set _dmem_emu_base_address_map_to 0x1d600000
179 set _dmem_emu_ap_list 1
180 }
181 j7200 {
182 set _K3_DAP_TAPID 0x0bb6d02f
183
184 # J7200 has 1 cluster of 2 A72 cores.
185 set _armv8_cpu_name a72
186 set _armv8_cores 2
187
188 # J7200 has 2 clusters of 2 R5 cores each.
189 set _r5_cores 4
190 set R5_DBGBASE {0x9d010000 0x9d012000 0x9d110000 0x9d112000}
191 set R5_CTIBASE {0x9d018000 0x9d019000 0x9d118000 0x9d119000}
192
193 # M3 CTI base
194 set CM3_CTIBASE {0x20001000}
195 }
196 j721s2 {
197 set _K3_DAP_TAPID 0x0bb7502f
198
199 # J721s2 has 1 cluster of 2 A72 cores.
200 set _armv8_cpu_name a72
201 set _armv8_cores 2
202
203 # J721s2 has 3 clusters of 2 R5 cores each.
204 set _r5_cores 6
205
206 # sysctrl CTI base
207 set CM3_CTIBASE {0x20001000}
208 # Sysctrl power-ap unlock offsets
209 set _sysctrl_ap_unlock_offsets {0xf0 0x78}
210
211 # M4 processor
212 set _gp_mcu_cores 1
213 set _gp_mcu_ap_unlock_offsets {0xf0 0x7c}
214 }
215 j784s4 {
216 set _K3_DAP_TAPID 0x0bb8002f
217
218 # j784s4 has 2 cluster of 4 A72 cores each.
219 set _armv8_cpu_name a72
220 set _armv8_cores 8
221 set ARMV8_DBGBASE {0x90410000 0x90510000 0x90610000 0x90710000
222 0x90810000 0x90910000 0x90a10000 0x90b10000}
223 set ARMV8_CTIBASE {0x90420000 0x90520000 0x90620000 0x90720000
224 0x90820000 0x90920000 0x90a20000 0x90b20000}
225
226 # J721s2 has 4 clusters of 2 R5 cores each.
227 set _r5_cores 8
228 set R5_DBGBASE {0x9d010000 0x9d012000
229 0x9d410000 0x9d412000
230 0x9d510000 0x9d512000
231 0x9d610000 0x9d612000}
232 set R5_CTIBASE {0x9d018000 0x9d019000
233 0x9d418000 0x9d419000
234 0x9d518000 0x9d519000
235 0x9d618000 0x9d619000}
236 set R5_NAMES {mcu_r5.0 mcu_r5.1
237 main0_r5.0 main0_r5.1
238 main1_r5.0 main1_r5.1
239 main2_r5.0 main2_r5.1}
240
241 # sysctrl CTI base
242 set CM3_CTIBASE {0x20001000}
243 # Sysctrl power-ap unlock offsets
244 set _sysctrl_ap_unlock_offsets {0xf0 0x78}
245 }
246 default {
247 echo "'$_soc' is invalid!"
248 }
249 }
250
251 proc _get_rtos_type_for_cpu { target_name } {
252 if { [info exists ::RTOS($target_name)] } {
253 return $::RTOS($target_name)
254 }
255 return none
256 }
257
258 set _CHIPNAME $_soc
259
260 swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_K3_DAP_TAPID -ignore-version
261
262 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
263
264 set _TARGETNAME $_CHIPNAME.cpu
265
266 set _CTINAME $_CHIPNAME.cti
267
268 # sysctrl is always present
269 cti create $_CTINAME.sysctrl -dap $_CHIPNAME.dap -ap-num 7 -baseaddr [lindex $CM3_CTIBASE 0]
270
271 target create $_TARGETNAME.sysctrl cortex_m -dap $_CHIPNAME.dap -ap-num 7 -defer-examine \
272 -rtos [_get_rtos_type_for_cpu $_TARGETNAME.sysctrl]
273
274 $_TARGETNAME.sysctrl configure -event reset-assert { }
275
276 proc sysctrl_up {} {
277 # To access sysctrl, we need to enable the JTAG access for the same.
278 # Ensure Power-AP unlocked
279 $::_CHIPNAME.dap apreg 3 [lindex $::_sysctrl_ap_unlock_offsets 0] 0x00190000
280 $::_CHIPNAME.dap apreg 3 [lindex $::_sysctrl_ap_unlock_offsets 1] 0x00102098
281
282 $::_TARGETNAME.sysctrl arp_examine
283 }
284
285 $_TARGETNAME.sysctrl configure -event gdb-attach {
286 sysctrl_up
287 # gdb-attach default rule
288 halt 1000
289 }
290
291 proc _cpu_no_smp_up {} {
292 set _current_target [target current]
293 set _current_type [$_current_target cget -type]
294
295 $_current_target arp_examine
296 $_current_target $_current_type dbginit
297 }
298
299 proc _armv8_smp_up {} {
300 for { set _core 0 } { $_core < $::_armv8_cores } { incr _core } {
301 $::_TARGETNAME.$::_armv8_cpu_name.$_core arp_examine
302 $::_TARGETNAME.$::_armv8_cpu_name.$_core aarch64 dbginit
303 $::_TARGETNAME.$::_armv8_cpu_name.$_core aarch64 smp on
304 }
305 # Set Default target as core 0
306 targets $::_TARGETNAME.$::_armv8_cpu_name.0
307 }
308
309 set _v8_smp_targets ""
310
311 for { set _core 0 } { $_core < $_armv8_cores } { incr _core } {
312
313 cti create $_CTINAME.$_armv8_cpu_name.$_core -dap $_CHIPNAME.dap -ap-num 1 \
314 -baseaddr [lindex $ARMV8_CTIBASE $_core]
315
316 target create $_TARGETNAME.$_armv8_cpu_name.$_core aarch64 -dap $_CHIPNAME.dap -coreid $_core \
317 -dbgbase [lindex $ARMV8_DBGBASE $_core] -cti $_CTINAME.$_armv8_cpu_name.$_core -defer-examine \
318 -rtos [_get_rtos_type_for_cpu $_TARGETNAME.$_armv8_cpu_name.$_core]
319
320 set _v8_smp_targets "$_v8_smp_targets $_TARGETNAME.$_armv8_cpu_name.$_core"
321
322 if { $_v8_smp_debug == 0 } {
323 $_TARGETNAME.$_armv8_cpu_name.$_core configure -event gdb-attach {
324 _cpu_no_smp_up
325 # gdb-attach default rule
326 halt 1000
327 }
328 } else {
329 $_TARGETNAME.$_armv8_cpu_name.$_core configure -event gdb-attach {
330 _armv8_smp_up
331 # gdb-attach default rule
332 halt 1000
333 }
334 }
335 }
336
337 # Setup ARMV8 proc commands based on CPU to prevent people confusing SoCs
338 set _armv8_up_cmd "$_armv8_cpu_name"_up
339 # Available if V8_SMP_DEBUG is set to non-zero value
340 set _armv8_smp_cmd "$_armv8_cpu_name"_smp
341
342 if { $_v8_smp_debug == 0 } {
343 proc $_armv8_up_cmd { args } {
344 foreach _core $args {
345 targets $_core
346 _cpu_no_smp_up
347 }
348 }
349 } else {
350 proc $_armv8_smp_cmd { args } {
351 _armv8_smp_up
352 }
353 # Declare SMP
354 target smp {*}$_v8_smp_targets
355 }
356
357 for { set _core 0 } { $_core < $_r5_cores } { incr _core } {
358 set _r5_name [lindex $R5_NAMES $_core]
359 cti create $_CTINAME.$_r5_name -dap $_CHIPNAME.dap -ap-num 1 \
360 -baseaddr [lindex $R5_CTIBASE $_core]
361
362 # inactive core examination will fail - wait till startup of additional core
363 target create $_TARGETNAME.$_r5_name cortex_r4 -dap $_CHIPNAME.dap \
364 -dbgbase [lindex $R5_DBGBASE $_core] -ap-num 1 -defer-examine \
365 -rtos [_get_rtos_type_for_cpu $_TARGETNAME.$_r5_name]
366
367 $_TARGETNAME.$_r5_name configure -event gdb-attach {
368 _cpu_no_smp_up
369 # gdb-attach default rule
370 halt 1000
371 }
372 }
373
374 proc r5_up { args } {
375 foreach _core $args {
376 targets $_core
377 _cpu_no_smp_up
378 }
379 }
380
381 if { $_gp_mcu_cores != 0 } {
382 cti create $_CTINAME.gp_mcu -dap $_CHIPNAME.dap -ap-num 8 -baseaddr [lindex $CM4_CTIBASE 0]
383 target create $_TARGETNAME.gp_mcu cortex_m -dap $_CHIPNAME.dap -ap-num 8 -defer-examine \
384 -rtos [_get_rtos_type_for_cpu $_TARGETNAME.gp_mcu]
385 $_TARGETNAME.gp_mcu configure -event reset-assert { }
386
387 proc gp_mcu_up {} {
388 # To access GP MCU, we need to enable the JTAG access for the same.
389 # Ensure Power-AP unlocked
390 $::_CHIPNAME.dap apreg 3 [lindex $::_gp_mcu_ap_unlock_offsets 0] 0x00190000
391 $::_CHIPNAME.dap apreg 3 [lindex $::_gp_mcu_ap_unlock_offsets 1] 0x00102098
392
393 $::_TARGETNAME.gp_mcu arp_examine
394 }
395
396 $_TARGETNAME.gp_mcu configure -event gdb-attach {
397 gp_mcu_up
398 # gdb-attach default rule
399 halt 1000
400 }
401 }
402
403 # In case of DMEM access, configure the dmem adapter with offsets from above.
404 if { 0 == [string compare [adapter name] dmem ] } {
405 if { [info exists _dmem_base_address] } {
406 # DAPBUS (Debugger) description
407 dmem base_address $_dmem_base_address
408 dmem ap_address_offset $_dmem_ap_address_offset
409 dmem max_aps $_dmem_max_aps
410
411 # The following are the details of APs to be emulated for direct address access.
412 # Debug Config (Debugger) description
413 dmem emu_base_address_range $_dmem_emu_base_address $_dmem_emu_base_address_map_to
414 dmem emu_ap_list $_dmem_emu_ap_list
415 # We are going local bus, so speed is really dummy here.
416 adapter speed 2500
417 } else {
418 puts "ERROR: ${SOC} data is missing to support dmem access!"
419 }
420 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)