u8500.cfg 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # Copyright (C) ST-Ericsson SA 2011
  3. # Author : michel.jaouen@stericsson.com
  4. # U8500 target
  5. proc mmu_off {} {
  6. set cp [arm mrc 15 0 1 0 0]
  7. set cp [expr {$cp & ~1}]
  8. arm mcr 15 0 1 0 0 $cp
  9. }
  10. proc mmu_on {} {
  11. set cp [arm mrc 15 0 1 0 0]
  12. set cp [expr {$cp | 1}]
  13. arm mcr 15 0 1 0 0 $cp
  14. }
  15. proc ocd_gdb_restart {target_id} {
  16. global _TARGETNAME_1
  17. global _SMP
  18. targets $_TARGETNAME_1
  19. if { $_SMP == 1 } {
  20. cortex_a smp off
  21. }
  22. rst_run
  23. halt
  24. if { $_SMP == 1 } {
  25. cortex_a smp on
  26. }
  27. }
  28. proc smp_reg {} {
  29. global _TARGETNAME_1
  30. global _TARGETNAME_2
  31. targets $_TARGETNAME_1
  32. echo "$_TARGETNAME_1"
  33. set pc1 [reg pc]
  34. set stck1 [reg sp_svc]
  35. targets $_TARGETNAME_2
  36. echo "$_TARGETNAME_1"
  37. set pc2 [reg pc]
  38. set stck2 [reg sp_svc]
  39. }
  40. proc u8500_tapenable {chip val} {
  41. echo "JTAG tap enable $chip"
  42. }
  43. proc pwrsts { } {
  44. global _CHIPNAME
  45. irscan $_CHIPNAME.jrc 0x3a
  46. drscan $_CHIPNAME.jrc 4 0
  47. set pwrsts [drscan $_CHIPNAME.jrc 16 0]
  48. echo "pwrsts ="$pwrsts
  49. set a9 [expr "0x$pwrsts & 0xc"]
  50. set ape [expr "0x$pwrsts & 0x3"]
  51. if {[string equal "0" $ape]} {
  52. echo "ape off"
  53. } else {
  54. echo "ape on"
  55. }
  56. echo "$a9"
  57. switch $a9 {
  58. 4 {
  59. echo "A9 in retention"
  60. }
  61. 8 {
  62. echo "A9 100% DVFS"
  63. }
  64. c {
  65. echo "A9 50% DVFS"
  66. }
  67. }
  68. }
  69. proc poll_pwrsts { } {
  70. global _CHIPNAME
  71. set result 1
  72. set i 0
  73. irscan $_CHIPNAME.jrc 0x3a
  74. drscan $_CHIPNAME.jrc 4 0
  75. set pwrsts [drscan $_CHIPNAME.jrc 16 0]
  76. set pwrsts [expr "0x$pwrsts & 0xc"]
  77. while {[string equal "4" $pwrsts] && $i<20} {
  78. irscan $_CHIPNAME.jrc 0x3a
  79. drscan $_CHIPNAME.jrc 4 0;
  80. set pwrsts [drscan $_CHIPNAME.jrc 16 0]
  81. set pwrsts [expr "0x$pwrsts & 0xc"]
  82. if {![string equal "4" $pwrsts]} {
  83. set result 1
  84. } else {
  85. set result 0
  86. sleep 200
  87. echo "loop $i"
  88. }
  89. incr i
  90. }
  91. return $result
  92. }
  93. proc halt_ { } {
  94. if {[poll_pwrsts]==1} {
  95. halt
  96. } else {
  97. echo "halt failed : target in retention"
  98. }
  99. }
  100. proc u8500_dapenable {chip} {
  101. }
  102. proc u8500_tapdisable {chip val} {
  103. echo "JTAG tap disable $chip"
  104. }
  105. proc enable_apetap {} {
  106. global _CHIPNAME
  107. global _TARGETNAME_2
  108. global _TARGETNAME_1
  109. poll off
  110. irscan $_CHIPNAME.jrc 0x3e
  111. drscan $_CHIPNAME.jrc 8 0xcf
  112. jtag tapenable $_CHIPNAME.dap
  113. irscan $_CHIPNAME.jrc 0x6
  114. drscan $_CHIPNAME.jrc 32 0
  115. irscan $_CHIPNAME.jrc 0x6
  116. drscan $_CHIPNAME.jrc 32 0
  117. set status [$_TARGETNAME_1 curstate]
  118. if {[string equal "unknown" $status]} {
  119. $_TARGETNAME_1 arp_examine
  120. cache_config l2x 0xa0412000 8
  121. }
  122. set status [$_TARGETNAME_2 curstate]
  123. if {[string equal "unknown" $status]} {
  124. $_TARGETNAME_2 arp_examine
  125. }
  126. }
  127. tcl_port 5555
  128. telnet_port 4444
  129. gdb_port 3333
  130. if { [info exists CHIPNAME] } {
  131. global _CHIPNAME
  132. set _CHIPNAME $CHIPNAME
  133. } else {
  134. global _CHIPNAME
  135. set _CHIPNAME u8500
  136. }
  137. if { [info exists ENDIAN] } {
  138. set _ENDIAN $ENDIAN
  139. } else {
  140. # this defaults to a bigendian
  141. set _ENDIAN little
  142. }
  143. # Subsidiary TAP: APE with scan chains for ARM Debug, EmbeddedICE-RT,
  144. if { [info exists CPUTAPID] } {
  145. set _CPUTAPID $CPUTAPID
  146. } else {
  147. set _CPUTAPID 0x4ba00477
  148. }
  149. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0xe -irmask 0xf -expected-id $_CPUTAPID -disable
  150. jtag configure $_CHIPNAME.cpu -event tap-enable \
  151. "u8500_dapenable $_CHIPNAME.cpu"
  152. jtag configure $_CHIPNAME.cpu -event tap-disable \
  153. "u8500_tapdisable $_CHIPNAME.cpu 0xc0"
  154. #CLTAPC TAP JRC equivalent
  155. if { [info exists CLTAPC_ID] } {
  156. set _CLTAPC_ID $CLTAPC_ID
  157. } else {
  158. set _CLTAPC_ID 0x22286041
  159. }
  160. jtag newtap $_CHIPNAME jrc -irlen 6 -ircapture 0x6 -irmask 0xf -expected-id $_CLTAPC_ID -ignore-version
  161. if { ![info exists TARGETNAME_1] } {
  162. global _TARGETNAME_1
  163. set _TARGETNAME_1 $_CHIPNAME.cpu1
  164. } else {
  165. global _TARGETNAME_1
  166. set _TARGETNAME_1 $TARGETNAME_1
  167. }
  168. if { [info exists DAP_DBG1] } {
  169. set _DAP_DBG1 $DAP_DBG1
  170. } else {
  171. set _DAP_DBG1 0x801A8000
  172. }
  173. if { [info exists DAP_DBG2] } {
  174. set _DAP_DBG2 $DAP_DBG2
  175. } else {
  176. set _DAP_DBG2 0x801AA000
  177. }
  178. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  179. target create $_TARGETNAME_1 cortex_a -dap $_CHIPNAME.dap -dbgbase $_DAP_DBG1 -coreid 0 -rtos linux
  180. if { ![info exists TARGETNAME_2] } {
  181. global _TARGETNAME_2
  182. set _TARGETNAME_2 $_CHIPNAME.cpu2
  183. } else {
  184. global _TARGETNAME_2
  185. set _TARGETNAME_2 $TARGETNAME_2
  186. }
  187. target create $_TARGETNAME_2 cortex_a -dap $_CHIPNAME.dap -dbgbase $_DAP_DBG2 -coreid 1 -rtos linux
  188. if {![info exists SMP]} {
  189. global _SMP
  190. set _SMP 1
  191. } else {
  192. global _SMP
  193. set _SMP $SMP
  194. }
  195. global SMP
  196. if { $_SMP == 1} {
  197. target smp $_CHIPNAME.cpu2 $_CHIPNAME.cpu1
  198. }
  199. proc secsts1 { } {
  200. global _CHIPNAME
  201. irscan $_CHIPNAME.jrc 0x3a
  202. drscan $_CHIPNAME.jrc 4 4
  203. set secsts1 [drscan $_CHIPNAME.jrc 16 0]
  204. echo "secsts1 ="$secsts1
  205. set secsts1 [expr "0x$secsts1 & 0x4"]
  206. if {![string equal "4" $secsts1]} {
  207. echo "APE target secured"
  208. } else {
  209. echo "APE target not secured"
  210. }
  211. }
  212. proc att { } {
  213. global _CHIPNAME
  214. jtag arp_init
  215. irscan $_CHIPNAME.jrc 0x3a
  216. drscan $_CHIPNAME.jrc 4 4
  217. set secsts1 [drscan $_CHIPNAME.jrc 16 0]
  218. echo "secsts1 ="$secsts1
  219. set secsts1 [expr "0x$secsts1 & 0x4"]
  220. if {[string equal "4" $secsts1]} {
  221. if {[poll_pwrsts]==1} {
  222. enable_apetap
  223. } else {
  224. echo "target in retention"
  225. }
  226. } else {
  227. echo "target secured"
  228. }
  229. }
  230. proc rst_run { } {
  231. global _CHIPNAME
  232. global _TARGETNAME_2
  233. global _TARGETNAME_1
  234. set status [$_TARGETNAME_1 curstate]
  235. if {[string equal "halted" $status]} {
  236. resume
  237. targets $_TARGETNAME_1
  238. }
  239. set status [$_TARGETNAME_2 curstate]
  240. if {[string equal "halted" $status]} {
  241. resume
  242. targets $_TARGETNAME_2
  243. }
  244. poll off
  245. jtag arp_init
  246. reset
  247. sleep 20
  248. irscan $_CHIPNAME.jrc 0x3a
  249. drscan $_CHIPNAME.jrc 4 4
  250. set secsts1 [drscan $_CHIPNAME.jrc 16 0]
  251. echo "secsts1 ="$secsts1
  252. set secsts1 [expr "0x$secsts1 & 0x4"]
  253. while {![string equal "4" $secsts1]} {
  254. irscan u8500.jrc 0x3a
  255. drscan u8500.jrc 4 4
  256. set secsts1 [drscan $_CHIPNAME.jrc 16 0]
  257. echo "secsts1 ="$secsts1
  258. set secsts1 [expr "0x$secsts1 & 0x4"]
  259. }
  260. echo "ape debugable"
  261. enable_apetap
  262. poll on
  263. targets $_TARGETNAME_1
  264. dap apsel 1
  265. }
  266. if {![info exists MAXSPEED]} {
  267. global _MAXSPEED
  268. set _MAXSPEED 15000
  269. } else {
  270. global _MAXSPEED
  271. set _MAXSPEED $MAXSPEED
  272. }
  273. global _MAXSPEED
  274. adapter speed $_MAXSPEED
  275. gdb_breakpoint_override hard
  276. set mem inaccessible-by-default-off
  277. jtag_ntrst_delay 100
  278. reset_config trst_and_srst combined