ti_k3.cfg 14 KB

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