1 # Copyright (C) ST-Ericsson SA 2011
2 # Author : michel.jaouen@stericsson.com
6 set cp [arm mrc 15 0 1 0 0]
7 set cp [expr ($cp & ~1)]
12 set cp [arm mrc 15 0 1 0 0]
13 set cp [expr ($cp | 1)]
14 arm mcr 15 0 1 0 0 $cp
17 proc ocd_gdb_restart {target_id} {
20 targets $_TARGETNAME_1
21 if { [expr ($_SMP == 1)] } {
26 if { [expr ($_SMP == 1)]} {
34 targets $_TARGETNAME_1
37 set stck1 [reg sp_svc]
38 targets $_TARGETNAME_2
41 set stck2 [reg sp_svc]
45 proc u8500_tapenable {chip val} {
46 echo "JTAG tap enable $chip"
52 irscan $_CHIPNAME.jrc 0x3a
53 drscan $_CHIPNAME.jrc 4 0
54 set pwrsts [drscan $_CHIPNAME.jrc 16 0]
55 echo "pwrsts ="$pwrsts
56 set a9 [expr (0x$pwrsts & 0xc)]
57 set ape [expr (0x$pwrsts & 0x3)]
58 if {[string equal "0" $ape]} {
66 echo "A9 in retention"
77 proc poll_pwrsts { } {
81 irscan $_CHIPNAME.jrc 0x3a
82 drscan $_CHIPNAME.jrc 4 0
83 set pwrsts [drscan $_CHIPNAME.jrc 16 0]
84 set pwrsts [expr (0x$pwrsts & 0xc)]
85 while {[string equal "4" $pwrsts] && $i<20} {
86 irscan $_CHIPNAME.jrc 0x3a
87 drscan $_CHIPNAME.jrc 4 0;
88 set pwrsts [drscan $_CHIPNAME.jrc 16 0]
89 set pwrsts [expr (0x$pwrsts & 0xc)]
90 if {![string equal "4" $pwrsts]} {
103 if {[poll_pwrsts]==1} {
106 echo "halt failed : target in retention"
111 proc u8500_dapenable {chip} {
114 proc u8500_tapdisable {chip val} {
115 echo "JTAG tap disable $chip"
119 proc enable_apetap {} {
124 irscan $_CHIPNAME.jrc 0x3e
125 drscan $_CHIPNAME.jrc 8 0xcf
126 jtag tapenable $_CHIPNAME.dap
127 irscan $_CHIPNAME.jrc 0x6
128 drscan $_CHIPNAME.jrc 32 0
129 irscan $_CHIPNAME.jrc 0x6
130 drscan $_CHIPNAME.jrc 32 0
131 set status [$_TARGETNAME_1 curstate]
132 if {[string equal "unknown" $status]} {
133 $_TARGETNAME_1 arp_examine
135 set status [$_TARGETNAME_2 curstate]
136 if {[string equal "unknown" $status]} {
137 $_TARGETNAME_2 arp_examine
145 if { [info exists CHIPNAME] } {
147 set _CHIPNAME $CHIPNAME
153 if { [info exists ENDIAN] } {
156 # this defaults to a bigendian
162 # Subsidiary TAP: APE with scan chains for ARM Debug, EmbeddedICE-RT,
163 if { [info exists CPUTAPID ] } {
164 set _CPUTAPID $CPUTAPID
166 set _CPUTAPID 0x4ba00477
168 jtag newtap $_CHIPNAME dap -irlen 4 -ircapture 0xe -irmask 0xf -expected-id $_CPUTAPID -disable
169 jtag configure $_CHIPNAME.dap -event tap-enable \
170 "u8500_dapenable $_CHIPNAME.dap"
171 jtag configure $_CHIPNAME.dap -event tap-disable \
172 "u8500_tapdisable $_CHIPNAME.dap 0xc0"
175 #CLTAPC TAP JRC equivalent
176 if { [info exists CLTAPC_ID ] } {
177 set _CLTAPC_ID $CLTAPC_ID
179 set _CLTAPC_ID 0x22286041
181 jtag newtap $_CHIPNAME jrc -irlen 6 -ircapture 0x6 -irmask 0xf -expected-id $_CLTAPC_ID -ignore-version
184 if { ![info exists TARGETNAME_1 ] } {
186 set _TARGETNAME_1 $_CHIPNAME.cpu1
189 set _TARGETNAME_1 $TARGETNAME_1
192 if { [info exists DAP_DBG1] } {
193 set _DAP_DBG1 $DAP_DBG1
195 set _DAP_DBG1 0x801A8000
197 if { [info exists DAP_DBG2] } {
198 set _DAP_DBG2 $DAP_DBG2
200 set _DAP_DBG2 0x801AA000
203 target create $_TARGETNAME_1 cortex_a8 -chain-position $_CHIPNAME.dap -dbgbase $_DAP_DBG1 -coreid 0
205 $_TARGETNAME_1 configure -event gdb-attach {
210 if { ![info exists TARGETNAME_2 ] } {
212 set _TARGETNAME_2 $_CHIPNAME.cpu2
215 set _TARGETNAME_2 $TARGETNAME_2
218 target create $_TARGETNAME_2 cortex_a8 -chain-position $_CHIPNAME.dap -dbgbase $_DAP_DBG2 -coreid 1
220 $_TARGETNAME_2 configure -event gdb-attach {
225 if {![info exists SMP]} {
234 target smp $_CHIPNAME.cpu2 $_CHIPNAME.cpu1
239 irscan $_CHIPNAME.jrc 0x3a
240 drscan $_CHIPNAME.jrc 4 4
241 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
242 echo "secsts1 ="$secsts1
243 set secsts1 [expr (0x$secsts1 & 0x4)]
244 if {![string equal "4" $secsts1]} {
245 echo "APE target secured"
247 echo "APE target not secured"
254 irscan $_CHIPNAME.jrc 0x3a
255 drscan $_CHIPNAME.jrc 4 4
256 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
257 echo "secsts1 ="$secsts1
258 set secsts1 [expr (0x$secsts1 & 0x4)]
259 if {[string equal "4" $secsts1]} {
260 if {[poll_pwrsts]==1} {
263 echo "target in retention"
266 echo "target secured"
276 set status [$_TARGETNAME_1 curstate]
277 if {[string equal "halted" $status]} {
279 targets $_TARGETNAME_1
281 set status [$_TARGETNAME_2 curstate]
282 if {[string equal "halted" $status]} {
284 targets $_TARGETNAME_2
290 irscan $_CHIPNAME.jrc 0x3a
291 drscan $_CHIPNAME.jrc 4 4
292 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
293 echo "secsts1 ="$secsts1
294 set secsts1 [expr (0x$secsts1 & 0x4)]
295 while {![string equal "4" $secsts1]} {
296 irscan u8500.jrc 0x3a
298 set secsts1 [drscan $_CHIPNAME.jrc 16 0]
299 echo "secsts1 ="$secsts1
300 set secsts1 [expr (0x$secsts1 & 0x4)]
305 targets $_TARGETNAME_1
309 if {![info exists MAXSPEED]} {
314 set _MAXSPEED $MAXSPEED
317 adapter_khz $_MAXSPEED
320 gdb_breakpoint_override hard
321 set mem inaccessible-by-default-off
324 reset_config trst_and_srst combined