以前的笔记丢了,重写一下,细节部分就不说了,还是比较简单的.
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