source: svn/trunk/newcon3bcm2_21bu/dst/build/jt.cmd

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 8.9 KB
Line 
1set can-use-hw-watchpoints 1
2set remote hardware-breakpoint-limit 2
3set remote hardware-watchpoint-limit 2
4set remotecache off
5set trust-readonly-sections on
6set endian little
7#set endian big
8set confirm off
9#useful settings
10#set disassemble-next-line on
11
12#set debug remote 1
13#set debug serial 1
14
15define tconn
16        dont-repeat
17        target extended-remote 218.36.33.74:50000
18end
19document tconn
20Connect to the target.
21This command simply executes target extended-remote command. It is there for
22convenience.
23end
24
25define tload
26        dont-repeat
27        monitor L
28        set $pc=_start
29#               set $pc=start
30end
31
32document tload
33Load binary file in to the target memory.
34File will be loaded at address that was given to JTAG server on comand line
35with -a switch. After file is loaded PC will be set to the symbol _start.
36end
37
38define taload
39        monitor L,$arg0
40        set $pc=0x$arg0
41end
42
43document taload
44Load binary file in to the target memory at specified address.
45File will be loaded at address that was specified. Note that address must
46be hexdecimal without 0x prefix. After binary is loaded $pc will be set
47to the load address.
48end
49
50define treset
51        dont-repeat
52#       monitor R
53#       disconnect
54#       shell sleep 3
55#       tconn
56        disconnect
57        shell sleep 6
58        tconn
59end
60document treset
61Reset and run target.
62This command should will reset target and run it after reset. Press Ctrl-C to
63regain control over target after reset.
64end
65
66define trg
67    monitor g
68end
69document trg
70Display MIPS CP0 registers.
71Display selected CP0 registers, not shown by "info registers" command.
72end
73
74define trun
75    dont-repeat
76    tload
77    c
78end
79document trun
80Load binary file and execute it.
81File will be loaded at address that was given to JTAG server on comand line
82with -a switch. After file is loaded PC will be set to the symbol _start and
83executed by jumping to that address.
84end
85
86define tcreset
87    dont-repeat
88    set $reset_ctrl = 0xb0404008
89    set $sw_reset = 0xb0404014
90    set *$reset_ctrl = 0x8
91    set *$sw_reset = 0x80000000
92    disconnect
93    shell sleep 3
94    tconn
95end
96document tcreset
97Chip specific reset.
98This command resets chip in a chip specific but more reliable way. This is
99done by wrting reset registers in SUN block. This may not work if you are
100using other than supported chip. If your JTAG supports hardware reset line
101this command is not needed.
102Supported chip - BCM7002, BCM3545
103end
104
105define print-cause
106    set $exccode=($arg0>>2)&0x1f
107    printf "ExcCode %d ", $exccode
108    if (1 == $exccode)
109        printf "TLB modification"
110    end
111    if (2 == $exccode)
112        printf "TLB (load)"
113    end
114    if (3 == $exccode)
115        printf "TLB (store)"
116    end
117    if (4 == $exccode)
118        printf "Address error (load)"
119    end
120    if (5 == $exccode)
121        printf "Address error (store)"
122    end
123    if (6 == $exccode)
124        printf "Bus error (instruction)"
125    end
126    if (7 == $exccode)
127        printf "Bus error (data)"
128    end
129    if (8 == $exccode)
130        printf "Syscall"
131    end
132    if (9 == $exccode)
133        printf "Breakpoint"
134    end
135    if (10 == $exccode)
136        printf  "Reserved instruction"
137    end
138    if (11 == $exccode)
139        printf "Coprocessor unusable"
140    end
141    if (12 == $exccode)
142        printf "Arithmetic Overflow"
143    end
144    echo \n
145end
146document print-cause
147Decode ExcCode field and print in human readable form.
148Usage: "print-cause $cause" or "print-cause value"
149end
150
151define tawatch
152    awatch $arg0
153    printf "maint packet Z4,%08x,%x\n", &($arg0), $arg1
154end
155
156document tawatch
157Set access watchpoint and print command for gdb
158This macro is helper for setting access watchpoint with size greater than
1594 bytes. Gdb refuses to do this without any hacks. Macro takes 2 arguments
160watchpoint address and watchpoint size. It will then set a normal watchpoint
161so gdb can control it. It also will print a command which user must paste on
162the console to set a watchpoint which monitors starting with address and
163within specified size.
164end
165
166define jcload
167        dont-repeat     
168        monitor L,81000000
169        set $pc=0x81000000
170end
171
172document jcload
173Load compressed binary
174This command should be used to load specially built compressed binary with
175decompressor. This binary is much smaller than original ram binary and will
176load much faster. The load address and entry point for this binary are
177different than for an uncompressed binary and equal 0x81000000
178end
179
180define jcrun
181        dont-repeat
182        jcload
183        # hbreak bcm_main
184        set $start_break = $bpnum
185        disable
186        enable $start_break
187        c
188        clear
189        enable
190        c
191end
192
193document jcrun
194Run compressed binary
195This command shouldbe used to run compressed binary. It will make sure that
196all breakpoints that were set will be restored after decompression.
197end
198
199define sbp
200        set $pc += 4
201end
202document sbp
203Skip embedded breakpoint instrucution.
204end
205
206define xmodem
207# for 7002
208        set *0xb0404090=$arg0
209# for 7550
210        set *0xb04040d0=$arg0
211# for 7552
212        set *0xb0404364=$arg0
213end
214
215
216
217define u-set-task
218    set $cur_task = OSTCBList
219    set $prio = $arg0
220    while ($cur_task->OSTCBPrio != $prio)
221        set $cur_task = $cur_task->OSTCBNext
222        if ($cur_task == 0)
223            loop_break
224        end
225    end
226
227    if ($cur_task != 0)
228        printf "Found TCB\n"
229        print *$cur_task
230    end
231end
232document u-set-task
233Find ucos task with given priority. Sets current task for future operations.
234u-find-task [priority]
235end
236
237define u-print-task-registers
238    if ($cur_task != 0)
239        set $frame_ptr = (unsigned long *) ($cur_task->OSTCBStkPtr)
240        printf  "R00 = %08x R01 = %08x R02 = %08x R03=%08x\n", $frame_ptr[0], $frame_ptr[1], $frame_ptr[2], $frame_ptr[3]
241        printf  "R04 = %08x R05 = %08x R06 = %08x R07 = %08x\n", $frame_ptr[4], $frame_ptr[5], $frame_ptr[6], $frame_ptr[7]
242        printf  "R08 = %08x R09 = %08x R10 = %08x R11 = %08x\n", $frame_ptr[8], $frame_ptr[9], $frame_ptr[10], $frame_ptr[11]
243        printf  "R12 = %08x R13 = %08x R14 = %08x R15 = %08x\n", $frame_ptr[12], $frame_ptr[13], $frame_ptr[14], $frame_ptr[15]
244        printf  "R16 = %08x R17 = %08x R18 = %08x R19 = %08x\n", $frame_ptr[16], $frame_ptr[18], $frame_ptr[18], $frame_ptr[19]
245        printf  "R20 = %08x R21 = %08x R22 = %08x R23 = %08x\n", $frame_ptr[20], $frame_ptr[21], $frame_ptr[22], $frame_ptr[23]
246        printf  "R24 = %08x R25 = %08x R26 = %08x R27 = %08x\n", $frame_ptr[24], $frame_ptr[25], $frame_ptr[26], $frame_ptr[27]
247        printf  "R28 = %08x R29 = %08x R30 = %08x R31 = %08x\n", $frame_ptr[28], $frame_ptr[29], $frame_ptr[30], $frame_ptr[31]
248        printf  "Sr  = %08x Lo  = %08x Hi  = %08x Bad = %08x\n", $frame_ptr[32], $frame_ptr[33], $frame_ptr[34], $frame_ptr[35]
249        printf  "Cau = %08x Pc  = %08x\n", $frame_ptr[36], $frame_ptr[37]
250       
251    end
252end
253document u-print-task-registers
254Print registers of the last addressed task.
255end
256
257define u-list-tasks
258    set $next_task = OSTCBList
259    while ($next_task != 0)
260        printf "Task = %d %s\n", $next_task->OSTCBPrio, $next_task->OSTCBTaskName
261        set $next_task = $next_task->OSTCBNext
262    end
263end
264
265define u-save-registers
266    set $reg1 = $at
267    set $reg2 = $v0
268    set $reg3 = $v1
269    set $reg4 = $a0
270    set $reg5 = $a1
271    set $reg6 = $a2
272    set $reg7 = $a3
273    set $reg8 = $t0
274    set $reg9 = $t1
275    set $reg10 = $t2
276    set $reg11 = $t3
277    set $reg12 = $t4
278    set $reg13 = $t5
279    set $reg14 = $t6
280    set $reg15 = $t7
281    set $reg16 = $s0
282    set $reg17 = $s1
283    set $reg18 = $s2
284    set $reg19 = $s3
285    set $reg20 = $s4
286    set $reg21 = $s5
287    set $reg22 = $s6
288    set $reg23 = $s7
289    set $reg24 = $t8
290    set $reg25 = $t9
291    set $reg26 = $k0
292    set $reg27 = $k1
293    set $reg28 = $gp
294    set $reg29 = $sp
295    set $reg30 = $s8
296    set $reg31 = $ra
297    set $reg32 = $pc
298end
299
300define u-restore-registers
301    set $at = $reg1, $v0 = $reg2, $v1 = $reg3, $a0 = $reg4
302    set $a1 = $reg5, $a2 = $reg6, $a3 = $reg7, $t0 = $reg8
303    set $t1 = $reg9, $t2 = $reg10, $t3 = $reg11, $t4 = $reg12
304    set $t5 = $reg13, $t6 = $reg14, $t7 = $reg15, $s0 = $reg16
305    set $s1 = $reg17, $s2 = $reg18, $s3 = $reg19, $s4 = $reg20
306    set $s5 = $reg21, $s6 = $reg22, $s7 = $reg23, $t8 = $reg24
307    set $t9 = $reg25, $k0 = $reg26, $k1 = $reg27, $gp = $reg28
308    set $sp = $reg29, $s8 = $reg30,  $ra = $reg31, $pc = $reg32
309end
310
311define u-load-context
312    if ($cur_task != 0)
313        set $frame_ptr = (unsigned long *) ($cur_task->OSTCBStkPtr)
314        set $at =  $frame_ptr[1], $v0 =  $frame_ptr[2], $v1 =  $frame_ptr[3], $a0 =  $frame_ptr[4]
315        set $a1 = $frame_ptr[5], $a2 = $frame_ptr[6], $a3 = $frame_ptr[7], $t0 = $frame_ptr[8]
316        set $t1 = $frame_ptr[9], $t2 = $frame_ptr[10], $t3 = $frame_ptr[11], $t4 = $frame_ptr[12]
317        set $t5 = $frame_ptr[13], $t6 = $frame_ptr[14], $t7 = $frame_ptr[15], $s0 = $frame_ptr[16]
318        set $s1 = $frame_ptr[17], $s2 = $frame_ptr[18], $s3 = $frame_ptr[19], $s4 = $frame_ptr[20]
319        set $s5 = $frame_ptr[21], $s6 = $frame_ptr[22], $s7 = $frame_ptr[23], $t8 = $frame_ptr[24]
320        set $t9 = $frame_ptr[25], $k0 = $frame_ptr[26], $k1 = $frame_ptr[27], $gp = $frame_ptr[28]
321        set $sp = $frame_ptr[29], $s8 = $frame_ptr[30], $ra = $frame_ptr[31], $pc = $frame_ptr[37]
322    end
323end
324
325
326tconn
Note: See TracBrowser for help on using the repository browser.