| 1 | set can-use-hw-watchpoints 1 |
|---|
| 2 | set remote hardware-breakpoint-limit 2 |
|---|
| 3 | set remote hardware-watchpoint-limit 2 |
|---|
| 4 | set remotecache off |
|---|
| 5 | set trust-readonly-sections on |
|---|
| 6 | set endian little |
|---|
| 7 | #set endian big |
|---|
| 8 | set confirm off |
|---|
| 9 | #useful settings |
|---|
| 10 | #set disassemble-next-line on |
|---|
| 11 | |
|---|
| 12 | #set debug remote 1 |
|---|
| 13 | #set debug serial 1 |
|---|
| 14 | |
|---|
| 15 | define tconn |
|---|
| 16 | dont-repeat |
|---|
| 17 | target extended-remote 218.36.33.74:50000 |
|---|
| 18 | end |
|---|
| 19 | document tconn |
|---|
| 20 | Connect to the target. |
|---|
| 21 | This command simply executes target extended-remote command. It is there for |
|---|
| 22 | convenience. |
|---|
| 23 | end |
|---|
| 24 | |
|---|
| 25 | define tload |
|---|
| 26 | dont-repeat |
|---|
| 27 | monitor L |
|---|
| 28 | set $pc=_start |
|---|
| 29 | # set $pc=start |
|---|
| 30 | end |
|---|
| 31 | |
|---|
| 32 | document tload |
|---|
| 33 | Load binary file in to the target memory. |
|---|
| 34 | File will be loaded at address that was given to JTAG server on comand line |
|---|
| 35 | with -a switch. After file is loaded PC will be set to the symbol _start. |
|---|
| 36 | end |
|---|
| 37 | |
|---|
| 38 | define taload |
|---|
| 39 | monitor L,$arg0 |
|---|
| 40 | set $pc=0x$arg0 |
|---|
| 41 | end |
|---|
| 42 | |
|---|
| 43 | document taload |
|---|
| 44 | Load binary file in to the target memory at specified address. |
|---|
| 45 | File will be loaded at address that was specified. Note that address must |
|---|
| 46 | be hexdecimal without 0x prefix. After binary is loaded $pc will be set |
|---|
| 47 | to the load address. |
|---|
| 48 | end |
|---|
| 49 | |
|---|
| 50 | define treset |
|---|
| 51 | dont-repeat |
|---|
| 52 | # monitor R |
|---|
| 53 | # disconnect |
|---|
| 54 | # shell sleep 3 |
|---|
| 55 | # tconn |
|---|
| 56 | disconnect |
|---|
| 57 | shell sleep 6 |
|---|
| 58 | tconn |
|---|
| 59 | end |
|---|
| 60 | document treset |
|---|
| 61 | Reset and run target. |
|---|
| 62 | This command should will reset target and run it after reset. Press Ctrl-C to |
|---|
| 63 | regain control over target after reset. |
|---|
| 64 | end |
|---|
| 65 | |
|---|
| 66 | define trg |
|---|
| 67 | monitor g |
|---|
| 68 | end |
|---|
| 69 | document trg |
|---|
| 70 | Display MIPS CP0 registers. |
|---|
| 71 | Display selected CP0 registers, not shown by "info registers" command. |
|---|
| 72 | end |
|---|
| 73 | |
|---|
| 74 | define trun |
|---|
| 75 | dont-repeat |
|---|
| 76 | tload |
|---|
| 77 | c |
|---|
| 78 | end |
|---|
| 79 | document trun |
|---|
| 80 | Load binary file and execute it. |
|---|
| 81 | File will be loaded at address that was given to JTAG server on comand line |
|---|
| 82 | with -a switch. After file is loaded PC will be set to the symbol _start and |
|---|
| 83 | executed by jumping to that address. |
|---|
| 84 | end |
|---|
| 85 | |
|---|
| 86 | define 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 |
|---|
| 95 | end |
|---|
| 96 | document tcreset |
|---|
| 97 | Chip specific reset. |
|---|
| 98 | This command resets chip in a chip specific but more reliable way. This is |
|---|
| 99 | done by wrting reset registers in SUN block. This may not work if you are |
|---|
| 100 | using other than supported chip. If your JTAG supports hardware reset line |
|---|
| 101 | this command is not needed. |
|---|
| 102 | Supported chip - BCM7002, BCM3545 |
|---|
| 103 | end |
|---|
| 104 | |
|---|
| 105 | define 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 |
|---|
| 145 | end |
|---|
| 146 | document print-cause |
|---|
| 147 | Decode ExcCode field and print in human readable form. |
|---|
| 148 | Usage: "print-cause $cause" or "print-cause value" |
|---|
| 149 | end |
|---|
| 150 | |
|---|
| 151 | define tawatch |
|---|
| 152 | awatch $arg0 |
|---|
| 153 | printf "maint packet Z4,%08x,%x\n", &($arg0), $arg1 |
|---|
| 154 | end |
|---|
| 155 | |
|---|
| 156 | document tawatch |
|---|
| 157 | Set access watchpoint and print command for gdb |
|---|
| 158 | This macro is helper for setting access watchpoint with size greater than |
|---|
| 159 | 4 bytes. Gdb refuses to do this without any hacks. Macro takes 2 arguments |
|---|
| 160 | watchpoint address and watchpoint size. It will then set a normal watchpoint |
|---|
| 161 | so gdb can control it. It also will print a command which user must paste on |
|---|
| 162 | the console to set a watchpoint which monitors starting with address and |
|---|
| 163 | within specified size. |
|---|
| 164 | end |
|---|
| 165 | |
|---|
| 166 | define jcload |
|---|
| 167 | dont-repeat |
|---|
| 168 | monitor L,81000000 |
|---|
| 169 | set $pc=0x81000000 |
|---|
| 170 | end |
|---|
| 171 | |
|---|
| 172 | document jcload |
|---|
| 173 | Load compressed binary |
|---|
| 174 | This command should be used to load specially built compressed binary with |
|---|
| 175 | decompressor. This binary is much smaller than original ram binary and will |
|---|
| 176 | load much faster. The load address and entry point for this binary are |
|---|
| 177 | different than for an uncompressed binary and equal 0x81000000 |
|---|
| 178 | end |
|---|
| 179 | |
|---|
| 180 | define 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 |
|---|
| 191 | end |
|---|
| 192 | |
|---|
| 193 | document jcrun |
|---|
| 194 | Run compressed binary |
|---|
| 195 | This command shouldbe used to run compressed binary. It will make sure that |
|---|
| 196 | all breakpoints that were set will be restored after decompression. |
|---|
| 197 | end |
|---|
| 198 | |
|---|
| 199 | define sbp |
|---|
| 200 | set $pc += 4 |
|---|
| 201 | end |
|---|
| 202 | document sbp |
|---|
| 203 | Skip embedded breakpoint instrucution. |
|---|
| 204 | end |
|---|
| 205 | |
|---|
| 206 | define xmodem |
|---|
| 207 | # for 7002 |
|---|
| 208 | set *0xb0404090=$arg0 |
|---|
| 209 | # for 7550 |
|---|
| 210 | set *0xb04040d0=$arg0 |
|---|
| 211 | # for 7552 |
|---|
| 212 | set *0xb0404364=$arg0 |
|---|
| 213 | end |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | define 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 |
|---|
| 231 | end |
|---|
| 232 | document u-set-task |
|---|
| 233 | Find ucos task with given priority. Sets current task for future operations. |
|---|
| 234 | u-find-task [priority] |
|---|
| 235 | end |
|---|
| 236 | |
|---|
| 237 | define 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 |
|---|
| 252 | end |
|---|
| 253 | document u-print-task-registers |
|---|
| 254 | Print registers of the last addressed task. |
|---|
| 255 | end |
|---|
| 256 | |
|---|
| 257 | define 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 |
|---|
| 263 | end |
|---|
| 264 | |
|---|
| 265 | define 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 |
|---|
| 298 | end |
|---|
| 299 | |
|---|
| 300 | define 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 |
|---|
| 309 | end |
|---|
| 310 | |
|---|
| 311 | define 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 |
|---|
| 323 | end |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | tconn |
|---|