set can-use-hw-watchpoints 1 set remote hardware-breakpoint-limit 2 set remote hardware-watchpoint-limit 2 set remotecache off set trust-readonly-sections on set endian little #set endian big set confirm off #useful settings #set disassemble-next-line on #set debug remote 1 #set debug serial 1 define tconn dont-repeat target extended-remote 218.36.33.74:50000 end document tconn Connect to the target. This command simply executes target extended-remote command. It is there for convenience. end define tload dont-repeat monitor L set $pc=_start # set $pc=start end document tload Load binary file in to the target memory. File will be loaded at address that was given to JTAG server on comand line with -a switch. After file is loaded PC will be set to the symbol _start. end define taload monitor L,$arg0 set $pc=0x$arg0 end document taload Load binary file in to the target memory at specified address. File will be loaded at address that was specified. Note that address must be hexdecimal without 0x prefix. After binary is loaded $pc will be set to the load address. end define treset dont-repeat # monitor R # disconnect # shell sleep 3 # tconn disconnect shell sleep 6 tconn end document treset Reset and run target. This command should will reset target and run it after reset. Press Ctrl-C to regain control over target after reset. end define trg monitor g end document trg Display MIPS CP0 registers. Display selected CP0 registers, not shown by "info registers" command. end define trun dont-repeat tload c end document trun Load binary file and execute it. File will be loaded at address that was given to JTAG server on comand line with -a switch. After file is loaded PC will be set to the symbol _start and executed by jumping to that address. end define tcreset dont-repeat set $reset_ctrl = 0xb0404008 set $sw_reset = 0xb0404014 set *$reset_ctrl = 0x8 set *$sw_reset = 0x80000000 disconnect shell sleep 3 tconn end document tcreset Chip specific reset. This command resets chip in a chip specific but more reliable way. This is done by wrting reset registers in SUN block. This may not work if you are using other than supported chip. If your JTAG supports hardware reset line this command is not needed. Supported chip - BCM7002, BCM3545 end define print-cause set $exccode=($arg0>>2)&0x1f printf "ExcCode %d ", $exccode if (1 == $exccode) printf "TLB modification" end if (2 == $exccode) printf "TLB (load)" end if (3 == $exccode) printf "TLB (store)" end if (4 == $exccode) printf "Address error (load)" end if (5 == $exccode) printf "Address error (store)" end if (6 == $exccode) printf "Bus error (instruction)" end if (7 == $exccode) printf "Bus error (data)" end if (8 == $exccode) printf "Syscall" end if (9 == $exccode) printf "Breakpoint" end if (10 == $exccode) printf "Reserved instruction" end if (11 == $exccode) printf "Coprocessor unusable" end if (12 == $exccode) printf "Arithmetic Overflow" end echo \n end document print-cause Decode ExcCode field and print in human readable form. Usage: "print-cause $cause" or "print-cause value" end define tawatch awatch $arg0 printf "maint packet Z4,%08x,%x\n", &($arg0), $arg1 end document tawatch Set access watchpoint and print command for gdb This macro is helper for setting access watchpoint with size greater than 4 bytes. Gdb refuses to do this without any hacks. Macro takes 2 arguments watchpoint address and watchpoint size. It will then set a normal watchpoint so gdb can control it. It also will print a command which user must paste on the console to set a watchpoint which monitors starting with address and within specified size. end define jcload dont-repeat monitor L,81000000 set $pc=0x81000000 end document jcload Load compressed binary This command should be used to load specially built compressed binary with decompressor. This binary is much smaller than original ram binary and will load much faster. The load address and entry point for this binary are different than for an uncompressed binary and equal 0x81000000 end define jcrun dont-repeat jcload # hbreak bcm_main set $start_break = $bpnum disable enable $start_break c clear enable c end document jcrun Run compressed binary This command shouldbe used to run compressed binary. It will make sure that all breakpoints that were set will be restored after decompression. end define sbp set $pc += 4 end document sbp Skip embedded breakpoint instrucution. end define xmodem # for 7002 set *0xb0404090=$arg0 # for 7550 set *0xb04040d0=$arg0 # for 7552 set *0xb0404364=$arg0 end define u-set-task set $cur_task = OSTCBList set $prio = $arg0 while ($cur_task->OSTCBPrio != $prio) set $cur_task = $cur_task->OSTCBNext if ($cur_task == 0) loop_break end end if ($cur_task != 0) printf "Found TCB\n" print *$cur_task end end document u-set-task Find ucos task with given priority. Sets current task for future operations. u-find-task [priority] end define u-print-task-registers if ($cur_task != 0) set $frame_ptr = (unsigned long *) ($cur_task->OSTCBStkPtr) printf "R00 = %08x R01 = %08x R02 = %08x R03=%08x\n", $frame_ptr[0], $frame_ptr[1], $frame_ptr[2], $frame_ptr[3] printf "R04 = %08x R05 = %08x R06 = %08x R07 = %08x\n", $frame_ptr[4], $frame_ptr[5], $frame_ptr[6], $frame_ptr[7] printf "R08 = %08x R09 = %08x R10 = %08x R11 = %08x\n", $frame_ptr[8], $frame_ptr[9], $frame_ptr[10], $frame_ptr[11] printf "R12 = %08x R13 = %08x R14 = %08x R15 = %08x\n", $frame_ptr[12], $frame_ptr[13], $frame_ptr[14], $frame_ptr[15] printf "R16 = %08x R17 = %08x R18 = %08x R19 = %08x\n", $frame_ptr[16], $frame_ptr[18], $frame_ptr[18], $frame_ptr[19] printf "R20 = %08x R21 = %08x R22 = %08x R23 = %08x\n", $frame_ptr[20], $frame_ptr[21], $frame_ptr[22], $frame_ptr[23] printf "R24 = %08x R25 = %08x R26 = %08x R27 = %08x\n", $frame_ptr[24], $frame_ptr[25], $frame_ptr[26], $frame_ptr[27] printf "R28 = %08x R29 = %08x R30 = %08x R31 = %08x\n", $frame_ptr[28], $frame_ptr[29], $frame_ptr[30], $frame_ptr[31] printf "Sr = %08x Lo = %08x Hi = %08x Bad = %08x\n", $frame_ptr[32], $frame_ptr[33], $frame_ptr[34], $frame_ptr[35] printf "Cau = %08x Pc = %08x\n", $frame_ptr[36], $frame_ptr[37] end end document u-print-task-registers Print registers of the last addressed task. end define u-list-tasks set $next_task = OSTCBList while ($next_task != 0) printf "Task = %d %s\n", $next_task->OSTCBPrio, $next_task->OSTCBTaskName set $next_task = $next_task->OSTCBNext end end define u-save-registers set $reg1 = $at set $reg2 = $v0 set $reg3 = $v1 set $reg4 = $a0 set $reg5 = $a1 set $reg6 = $a2 set $reg7 = $a3 set $reg8 = $t0 set $reg9 = $t1 set $reg10 = $t2 set $reg11 = $t3 set $reg12 = $t4 set $reg13 = $t5 set $reg14 = $t6 set $reg15 = $t7 set $reg16 = $s0 set $reg17 = $s1 set $reg18 = $s2 set $reg19 = $s3 set $reg20 = $s4 set $reg21 = $s5 set $reg22 = $s6 set $reg23 = $s7 set $reg24 = $t8 set $reg25 = $t9 set $reg26 = $k0 set $reg27 = $k1 set $reg28 = $gp set $reg29 = $sp set $reg30 = $s8 set $reg31 = $ra set $reg32 = $pc end define u-restore-registers set $at = $reg1, $v0 = $reg2, $v1 = $reg3, $a0 = $reg4 set $a1 = $reg5, $a2 = $reg6, $a3 = $reg7, $t0 = $reg8 set $t1 = $reg9, $t2 = $reg10, $t3 = $reg11, $t4 = $reg12 set $t5 = $reg13, $t6 = $reg14, $t7 = $reg15, $s0 = $reg16 set $s1 = $reg17, $s2 = $reg18, $s3 = $reg19, $s4 = $reg20 set $s5 = $reg21, $s6 = $reg22, $s7 = $reg23, $t8 = $reg24 set $t9 = $reg25, $k0 = $reg26, $k1 = $reg27, $gp = $reg28 set $sp = $reg29, $s8 = $reg30, $ra = $reg31, $pc = $reg32 end define u-load-context if ($cur_task != 0) set $frame_ptr = (unsigned long *) ($cur_task->OSTCBStkPtr) set $at = $frame_ptr[1], $v0 = $frame_ptr[2], $v1 = $frame_ptr[3], $a0 = $frame_ptr[4] set $a1 = $frame_ptr[5], $a2 = $frame_ptr[6], $a3 = $frame_ptr[7], $t0 = $frame_ptr[8] set $t1 = $frame_ptr[9], $t2 = $frame_ptr[10], $t3 = $frame_ptr[11], $t4 = $frame_ptr[12] set $t5 = $frame_ptr[13], $t6 = $frame_ptr[14], $t7 = $frame_ptr[15], $s0 = $frame_ptr[16] set $s1 = $frame_ptr[17], $s2 = $frame_ptr[18], $s3 = $frame_ptr[19], $s4 = $frame_ptr[20] set $s5 = $frame_ptr[21], $s6 = $frame_ptr[22], $s7 = $frame_ptr[23], $t8 = $frame_ptr[24] set $t9 = $frame_ptr[25], $k0 = $frame_ptr[26], $k1 = $frame_ptr[27], $gp = $frame_ptr[28] set $sp = $frame_ptr[29], $s8 = $frame_ptr[30], $ra = $frame_ptr[31], $pc = $frame_ptr[37] end end tconn