使用lauterbach debug uboot之重定位

1.首先运行cmm脚本,attach cpu,让cpu停在romcode阶段

当运行完cmm脚本后,观察下右下角lauterbach的状态栏变化,最终状态是stopped。

power down -> Running -> stopped

 

cmm脚本内容如下

 1 RESet
 2 SYStem.RESET
 3 SYStem.config SWDP ON
 4 SYStem.CPU CortexA7MPCORE
 5 SYStem.CONFIG CoreNumber 4.
 6 system.resetout
 7 CORE.NUMber 4.
 8 
 9 SYStem.CONFIG DEBUGACCESSPORT 0.
10 SYStem.CONFIG APBACCESSPORT 0.
11 SYStem.CONFIG MEMORYACCESSPORT 1.
12 SYStem.CONFIG AXIACCESSPORT 1.
13 
14 SYStem.CONFIG COREDEBUG Base DAP:0x80030000 DAP:0x80032000 ;DAP:0x80014000 DAP:0x80710000
15 SYStem.CONFIG BMC       Base DAP:0x80031000 DAP:0x80033000 ;DAP:0x80630000 DAP:0x80730000
16 
17 SYStem.JtagClock 2MHz
18 
19 SYStem.CONFIG.DEBUGPORTTYPE SWD
20 
21 SYStem.Mode Attach
22 break
23 
24 ENDDO

2.加载spl elf,完成ddr的初始化

2.1可以选中文件直接拖进来,也可以输入以下命令。

Data.LOAD.Elf Y:\sdk\SDK_2024\boot\bl1\spl\spl.elf

2.2 设置断点到uboot的第一条指令

从代码里面可以看到spl跳到uboot执行的地址是 0x50000400

 

2.3 点击go,完成ddr的初始化

 

 3. 加载uboot.bin到ddr地址0x50000400

Data.LOAD.Binary Y:\sdk\SDK_2024\boot\uboot\u-boot-2020.04\u-boot.bin 0x50000400

并加载对应的elf文件到lauterbach

Data.LOAD Y:\sdk\SDK_2024\boot\uboot\u-boot-2020.04\u-boot /nocode

4.做源代码路径转换

sYmbol.SourcePATH.Translate "/home/zhongshan" "Y:\"

我是把虚拟机ubuntu里面的/home/zhongshan通过samba服务器映射为windows上的Y盘

5.设置断点并查看reloc_off值

5.1 setup_reloc

5.2 点击go

5.3 查看reloc_off值

 6.用offset重新加载对应的elf文件到lauterbach

Data.LOAD Y:\sdk\SDK_2024\boot\uboot\u-boot-2020.04\u-boot 0x2ff09c00 /nocode

7.在重定位后的board_init_r打断点(一定要删除重定位前打的断点,不然会出现错误)

 

 点击go,观察串口输出

8.在启动linux kernel的do_bootm_states打断点

打完断点后,点击go,查看串口log

 

注1:参考网上的两个图片

 

posted @ 2025-06-03 14:22  midhillzhou  阅读(55)  评论(0)    收藏  举报