脚本代码分为4个文件:busblaster-ftdi-hg255d.cmd,mips_busblaster.cfg,openocd-ralink.cfg,run-telnet.bat,这4个文件在openocd-0.9.0/bin目录下。硬件连接好上电后,依次运行busblaster-ftdi-hg255d.cmd和run-telnet.bat。
脚本代码
busblaster-ftdi-hg255d.cmd
openocd.exe -f mips_busblaster.cfg -f openocd-ralink.cfg
pause
mips_busblaster.cfg
#
# Dangerous Prototyes - Bus Blaster v3
# The Bus Blaster has a configurable buffer between the FTDI and the
# JTAG header which allows it to emulate various debugger types.
#
# Bus Blaster V3c for MIPS Kit - http://www.seeedstudio.com/depot/Bus-Blaster-V3c-for-MIPS-Kit-p-2258.html
# Manufacture - http://dangerousprototypes.com/docs/Bus_Blaster
#
interface ftdi
transport select jtag
#ftdi_device_desc "Dual RS232-HS"
#ftdi_vid_pid 0x0403 0x6010
ftdi_device_desc "BUSBLASTERv3c"
ftdi_vid_pid 0x0403 0x7780
#0x0908代表FTDI GPIO data,从openocd源码ft2232.c中分析获得,0x0f1b代表FTDI GPIO direction,从amontec jtagkey引脚连接图分析获得
ftdi_layout_init 0x0908 0x0f1b
ftdi_layout_signal nTRST -data 0x0100 -noe 0x0400
ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800
adapter_khz 1000
busblaser V3C(图片来自网络)
busblaster V3C 的ftdi layout跟jtagkey一致
openocd关于jtagkey的配置源码
static int jtagkey_init(void)
{
low_output = 0x08;
low_direction = 0x1b;
/* initialize low byte for jtag */
if (ft2232_set_data_bits_low_byte(low_output, low_direction) != ERROR_OK) {
LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout");
return ERROR_JTAG_INIT_FAILED;
}
if (strcmp(layout->name, "jtagkey") == 0) {
nTRST = 0x01;
nTRSTnOE = 0x4;
nSRST = 0x02;
nSRSTnOE = 0x08;
} else if ((strcmp(layout->name, "jtagkey_prototype_v1") == 0)
|| (strcmp(layout->name, "oocdlink") == 0)) {
nTRST = 0x02;
nTRSTnOE = 0x1;
nSRST = 0x08;
nSRSTnOE = 0x04;
} else {
LOG_ERROR("BUG: jtagkey_init called for non jtagkey layout");
exit(-1);
}
high_output = 0x0;
high_direction = 0x0f;
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN) {
high_output |= nTRSTnOE;
high_output &= ~nTRST;
} else {
high_output &= ~nTRSTnOE;
high_output |= nTRST;
}
if (jtag_reset_config & RESET_SRST_PUSH_PULL) {
high_output &= ~nSRSTnOE;
high_output |= nSRST;
} else {
high_output |= nSRSTnOE;
high_output &= ~nSRST;
}
/* initialize high byte for jtag */
if (ft2232_set_data_bits_high_byte(high_output, high_direction) != ERROR_OK) {
LOG_ERROR("couldn't initialize FT2232 with 'JTAGkey' layout");
return ERROR_JTAG_INIT_FAILED;
}
return ERROR_OK;
}
openocd-ralink.cfg
set _CHIPNAME rt3052
set _ENDIAN little
#daemon configuration
telnet_port 4444
gdb_port 3333
#jtag_speed 0
#adapter_khz 500
set _CPUTAPID 0x1335024F
adapter_nsrst_delay 100
jtag_ntrst_delay 100
reset_config trst_and_srst
#jtag newtap rt30xx cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id 1
jtag newtap rt30xx cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id 0x1305224f
target create rt30xx.cpu mips_m4k -endian little -chain-position rt30xx.cpu
rt30xx.cpu configure -event reset-halt-post {
#set memory
mww 0x10000300 0xD1825272
sleep 10
mww 0x10000304 0xE0120600
halt
}
rt30xx.cpu configure -event reset-init {
halt
#set memory
mww 0x10000300 0xD1825272
sleep 1
mww 0x10000304 0xE1110600
sleep 10000 ;# wait for lock
halt
sleep 1
flash probe 0
}
proc ralink_init { } {
halt
sleep 10
mww 0x10000300 0xD1825272
sleep 1
mww 0x10000304 0xE0120600 ;# Set Memory 32Mbyte in 32Bit(16MBx16bitx2)
sleep 1 ;# wait for lock
}
proc erase_uboot { } {
flash probe 0
flash erase_sector 0 0 4
}
proc flash_uboot { } {
ralink_init
sleep 1
flash probe 0
flash write_bank 0 uboot.bin 0x0
}
proc run_uboot { } {
#ralink_init
sleep 1
load_image uboot.bin 0x200000
#resume 0x00200000
}
proc run_uboot_command { } {
ralink_init
sleep 1
load_image uboot_command.bin 0x00200000
resume 0x00200000
}
# setup working area somewhere in RAM
#rt30xx.cpu configure \
# -work-area-phys 0xa0600000 \
# -work-area-size 65536 \
# -work-area-backup 0
#rt30xx.cpu configure -work-area-phys 0xbf020000 -work-area-size 0x0010000 -work-area-backup 0
rt30xx.cpu configure -work-area-phys 0x00000000 -work-area-size 0x0010000 -work-area-backup 0
#rt30xx.cpu configure -work-area-phys 0xa0600000 -work-area-size 0x20000 -work-area-backup 0
#rt30xx.cpu configure -work-area-phys 0x00600000 -work-area-size 0x40000
# serial SPI capable flash
# flash bank <driver> <base> <size> <chip_width> <bus_width>
#flash bank rt30xx.flash cfi 0x1f000000 0x1000000 2 2 rt30xx.cpu
flash bank rt30xx.flash cfi 0xbf000000 0x1000000 2 2 rt30xx.cpu
#mips32 scan_delay 2000
#flash probe 0
run-telnet.bat
start "telnet" cmd.exe /K telnet localhost 4444