通过 Jlink V8 + OpenOCD 对 MT7620 修砖

写在开头的话

很久没有更新博客了,这篇文章作为我重返CSDN的纪念,算是送给大家的一个礼物,顺祝各位朋友新年快乐!

引子

一直有朋友在寻找MT7620的JTAG调试方法(或者想通过JTAG对变砖的u-boot进行修复)。很多人认为Jlink V8没法对mips32进行硬件级的调试,今天我就来创造一下奇迹!

OpenOCD针对MT7620的配置文件

保存为 openocd-mt7620-jlink.cfg

# for mt7620, powered by manfeel
set  _CHIPNAME mt762x

# little endian
set  _ENDIAN little

set _TARGETNAME $_CHIPNAME.cpu

set _CPUTAPID 0x1635224f

#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface jlink

#jtag_speed 0
adapter_khz 500

jtag_nsrst_delay 100
jtag_ntrst_delay 100

jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_CPUTAPID
	
target create $_TARGETNAME mips_m4k -endian little -chain-position $_TARGETNAME

$_TARGETNAME configure -event gdb-attach {
   halt
}

$_TARGETNAME configure -event gdb-attach {
   reset init
}

$_TARGETNAME configure -event reset-init {
	# manfeel, call ralink_init
	ralink_init
}

proc ralink_init { } {

	# ==================================================
	echo "Manfeel notes, pll initialization @ 580Mhz"

	mww 0xb0000058 0x00e3c000
	mww 0xb0000054 0x8005a070
	
	sleep 2
	
	mww 0xb0000058 0x05e3c000
	mww 0xb0000054 0x8005a070
	
	sleep 2
	
	mww 0xb0000058 0x01810000
	mww 0xb0000058 0x00e3c000
	
	# ==================================================

	echo "Manfeel notes, setup DDR2 RAM with 64M Bytes"

	sleep 200                         
	mww 0xb0000014 0x260c50f

	# DDR initialization: reset pin to 0
	sleep 1
	mww 0xb0000034 0x0
	sleep 1
	mww 0xb0000348 0x68000c43
	sleep 1
	mww 0xb0000350 0x9
	sleep 1
	mww 0xb0000348 0x68000c43
	sleep 1
	mww 0xb000034c 0x00000416
	sleep 1
	mww 0xb0000350 0x0000000a
	sleep 1
	mww 0xb0000368 0x40404848
	sleep 1
	mww 0xb0000340 0x249aa2e5
	sleep 1
	mww 0xb0000344 0x22322323
	sleep 1
	#manfeel notes: MUST be 0x3ffff NOT 1
	mww 0xb000031c 0x3ffff
	sleep 1
	#manfeel nots: MUST be 0x0e120003 NOT 0x0e120013
	mww 0xb0000318 0x0e120003
}

proc run_uboot { } {
	halt
	sleep 1
	load_image /Users/manfeel/works/uboot_ralink/uboot.img 0x801fffc0
	resume 0x80200000
}

运行 openocd

openocd -f openocd-mt7620-jlink.cfg

运行 telnet

telnet localhost 4444

telnet终端中依次输入

运行命令之前最好将spiflash的5脚(MOSI)和4脚(GND)短接,这样能够让PC停在0x9C000000

halt
reset init
run_uboot

就能够加载uboot.img(RAM版本)并运行之。
剩下的事情就不用我提醒了 ^_^

你可能感兴趣的:(mt7620,u-boot,jtag,OpenOCD)