Jlink + Vmware虛擬機器除錯uboot
以前的筆記丟了,重寫一下,細節部分就不說了,還是比較簡單的.
Jlink 版本V4.34d, 網上有人說V4.40以上不識別山寨JLINK V8
注意Localhost only 不要選上,不讓通過虛擬機器連線時會連不上
我以前就沒有注意這個,老版本直接可以連,新版本不能連了,還以為是軟體取消了這個功能或者是軟體bug
虛擬機器的設定要設定成橋接,如果設定成NAT,開發板是看不見虛擬機器的
設定為橋接,好要和開發主機在同一網段
我的HOST 192.168.1.18, 虛擬機器 192.168.1.19
網管 192.168.1.2
uboot 連線指令碼是0x33ff8000開始的,因為uboot開始的彙編是位置無關的,這部分程式碼負責copy uboot到0x33f80000
我們如果是在記憶體中除錯的話,可以通過巨集定義去掉這部分copy的程式碼
如果要在記憶體中除錯,首先要初始化RAM,這部分內容要通過偵錯程式gdb來完成
主要就是時鐘,sdram重新整理之類的時鐘,網上搜來的配置
##main function defined for initial the S3C2440 CPU.
define reset_2440
monitor endian little ##little endian, should be the same as your application.
##copied from JLinkGDBServer Document.
monitor reset ##reset the S3C2440
monitor reg cpsr = 0xd3 ##setup cpsr register.
monitor speed auto ##Link Speed.
##translated from VIVI S3C2440 version.
#disable watchdog
monitor MemU32 0x53000000 = 0
#disalbe interrupt --- int-mask register
monitor MemU32 0x4A000008 = 0xFFFFFFFF
#disalbe interrupt --- int-sub-mask register
monitor MemU32 0x4A00001C = 0x7FFF ## vivi set it as 0x7FF, why???
#initialize system clocks --- locktime register
monitor long 0x4C000000 = 0x00FFFFFF
#initialize system clocks --- clock-divn register
monitor long 0x4C000014 = 0x5 #CLKDVIN_400_148
# monitor cp15 1 0 0 0
# monitor cp15 1 0 0 0 =0xc0000078
#initialize system clocks --- mpll register
monitor long 0x4C000004 = 0x7f021 #default clock
monitor long 0x4C000004 = 0x7f021 #default clock
#setup memory controller
monitor MemU32 0x48000000 = 0x22111110 #conw
monitor MemU32 0x48000004 = 0x00000700 #bank0
monitor MemU32 0x48000008 = 0x00000700 #bank1
monitor MemU32 0x4800000c = 0x00000700 #bank2
monitor MemU32 0x48000010 = 0x00000700 #bank3
monitor MemU32 0x48000014 = 0x00000700 #bank4
monitor MemU32 0x48000018 = 0x00000700 #bank5
monitor MemU32 0x4800001c = 0x00018009 #bank6
monitor MemU32 0x48000020 = 0x00018009 #bank7
monitor MemU32 0x48000024 = 0x008c04F4 #vREFRESH HCLK: 100M
monitor MemU32 0x48000028 = 0x32 #vBANKSIZE -- 128M/128M --- should
according to the physical
memory size? --- 0xB0 ??
monitor MemU32 0x4800002c = 0x30 #vMRSRB6
monitor MemU32 0x48000030 = 0x30 #vMRSRB7
end
##main function defined for connect to the TARGET.
##arg0 = IP address.
##arg1 = PORT number of JLINK gdb server.
define connect_jlink
# set $ip = 192.168.1.18
# set $port = 2331
target remote 192.168.1.18:2331
reset_2440
end
我用emacs除錯uboot,gdb命令列
/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gdb --annotate=3 u-boot
執行後進入除錯介面
(gdb) connect_jlink
0x00000000 in ?? ()
Target endianess set to "little endian"
Expected an decimal digit (0-9)
Writing register (CPSR = 0x000000D3)
Select auto JTAG speed (8000 kHz)
Writing 0x00000000 @ address 0x53000000
Writing 0xFFFFFFFF @ address 0x4A000008
Writing 0x00007FFF @ address 0x4A00001C
Writing 0xFF000000 @ address 0x4C000000
Writing 0x00000005 @ address 0x4C000014
Writing 0x0007F021 @ address 0x4C000004
Writing 0x22111110 @ address 0x48000000
Writing 0x00000700 @ address 0x48000004
Writing 0x00000700 @ address 0x48000008
Writing 0x00000700 @ address 0x4800000C
Writing 0x00000700 @ address 0x48000010
Writing 0x00000700 @ address 0x48000014
Writing 0x00000700 @ address 0x48000018
Writing 0x00018009 @ address 0x4800001C
Writing 0x00018009 @ address 0x48000020
Writing 0x008E04EB @ address 0x48000024
Writing 0x000000B2 @ address 0x48000028
Undefined command: "according". Try "help".
(gdb) load
Loading section .text, size 0x2dd68 lma 0x33f80000
Loading section .rodata, size 0x64f4 lma 0x33fadd68
Loading section .data, size 0x562c lma 0x33fb425c
Loading section .u_boot_cmd, size 0x578 lma 0x33fb9888
Start address 0x33f80000, load size 237056
Transfer rate: 378 KB/sec, 13944 bytes/write.
(gdb) s
http://blog.chinaunix.net/uid-21977330-id-3257174.html