通過 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終端中依次輸入

halt
reset init
run_uboot

就能夠加載uboot.img(RAM版本)並運行之。
剩下的事情就不用我提醒了 ^_^

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章