zynqMP调试笔记(包含如何调试U-BOOT)

创建工程:
kunyi02@kunyi02-PC:~/alinx/4ev-p/shao-Alps$ petalinux-create -t project -n petalinux --template zynqMP

配置工程:
xsa文件由硬件提供
kunyi02@kunyi02-PC:~/alinx/4ev-p/shao-Alps/petalinux$ petalinux-config --get-hw-description ../hardware/design_1_wrapper.xsa

uboot device tree config:
xilinx_zynqmp_virt_defconfig
⇒zynqmp-zcu100-revC.dts
qemu:
INFO: Sourcing build tools
ERROR: Failed to boot. Image file '/home/kunyi02/alinx/4ev-p/shao-Alps/petalinux/pre-built/linux/images/pmu_rom_qemu_sha3.elf' doesn't exist.
pmu_rom_qemu_sha3.elf需要手动拷贝(官网下载一个zynqmp的bsp包)
petalinux-boot --qemu --u-boot
petalinux-boot --qemu --kernel

编译内核:
①xilinx linux5.15.36 ----> rt-linux5.15.36
# 检查patch是否可用
kunyi02@kunyi02-PC:~/alinx/4ev-p/shao-Alps/linux-xlnx-xlnx_rebase_v5.15_LTS$ git apply --check patch-5.15.36-rt41.patch
# 内核打上patch
kunyi02@kunyi02-PC:~/alinx/4ev-p/shao-Alps/linux-xlnx-xlnx_rebase_v5.15_LTS$ git apply patch-5.15.36-rt41.patch
(虽然可以直接打上,但是某些xilinx的驱动程序还未确定是否需要改动)

②生成Image
export ARCH=arm
export CROSS_COMPILE=aarch64-linux-gnu-
make xilinx_zynqmp_defconfig
make all -j4(小于CPU的最大线程数)
⇒ arch/arm64/boot/Image

do_shared_workdir 稍微调查一下这个函数

https://support.xilinx.com/s/article/65467?language=en_US


打包boot.bin(包含fsbl )
~/alinx/4ev-p/shao-Alps/HILIOHUB/petalinux/images/linux$ petalinux-package --boot --u-boot --fsbl --force

BOOT.BIN烧写失败:
===== mrd->addr=0xFF5E0204, data=0x00000000 =====

BOOT_MODE REG = 0x0000

Downloading FSBL...

Running FSBL...

Finished running FSBL.

Problem in running uboot

Flash programming initialization failed.

ERROR: Flash Operation Failed
推测是petalinux生成的fsbl有问题,尝试用vitis生成的fsbl可以成功烧录:
①利用xsa文件创建vitis工程
②利用vitis工程中的fslb + linux生成的BOOT.BIN 烧写
还未验证启动,因为串口没有连出来

使用vitis的xsct加载uboot
tcl脚本:https://blog.csdn.net/aatu/article/details/121529283
connect
targets
targets -set -filter {name =~ "PSU"}
mwr 0xffca0038 0x1ff
targets

targets -set -filter {name =~ "MicroBlaze PMU"}
targets
dow /home/kunyi/vitis_P/u-boot/pmufw.elf
con

targets -set -filter {name =~ "Cortex-A53 #0"}
rst -processor
dow /home/kunyi/vitis_P/u-boot/zynqmp_fsbl.elf
con
stop

dow /home/kunyi/vitis_P/u-boot/bl31.elf
con
stop

dow -data /home/kunyi/vitis_P/u-boot/system.dtb 0x100000
dow /home/kunyi/vitis_P/u-boot/u-boot.elf
stop

反汇编(用于后续调式时查看汇编与函数的对应关系):
aarch64-linux-gnu-objdump -d u-boot > u-boot.asm

更换PetaLinux工程的HDF/XSA文件后,PetaLinux工程编译出现FSBL do_configureh错误。
使用命令“petalinux-build -x mrproper -f ”,彻底清除工程,再编译工程,不再有问题。


调试:
https://blog.csdn.net/hitxiaohongming/article/details/96374814
https://support.xilinx.com/s/article/76616?language=zh_CN
https://www.xilinx.com/htmldocs/xilinx2018_1/SDK_Doc/xsct/breakpoints/reference_breakpoints_bpadd.html

解决qemu安装失败问题(ubuntu20.04)
https://support.xilinx.com/s/article/2021-1-PetaLinux?language=en_US

DEBUG时的注意点:
1. 执行自己编写的tcl脚本(参照上面)
⇒自动将uboot.elf加载到IOHUB上
2. relocate之前添加断点
⇒bpadd board_init_f(在u-boot relocate之前可以利用函数名添加断点)
3.relocate地址查看
⇒bpadd setup_reloc
⇒通过vitis查看gd->relocaddr 0x000000007fdbb000为relocate之后的u-boot地址
4. relocate之后添加断点
⇒bpadd -addr 0x7fdd7214 (在u-boot relocate之后不能利用函数名添加断点,因为U-boot在内存上的地址改变了)
# ⇒ memmap -file /home/kunyi/vitis_P/u-boot/u-boot.elf -reloc 0x7fdbb000 (没有成功https://support.xilinx.com/s/article/1151076?language=en_US)

断点计算:
relocate之前:0x0000000008000000
relocate之后:0x000000007fdbb000
根据relocate之后运行的地址 计算差值 去u-boot.asm中去对比执行到哪里:
0x7fdd9fd0 - 0x7fdbb000 1efd0 000000000801efd0 <board_init_r>
0x7fdd7214 - 0x7fdbb000 1C214 000000000801c210 <main_loop>
0x7fdd97cc - 0x7fdbb000 1e7cc 000000000801e7cc <autoboot_command>

bpadd board_init_f
bpadd -addr 0x7fdd7214
bpadd -addr 0x7fdd97cc
bpadd -addr 0x7fdd9fd0

posted on 2023-05-11 16:48  Ctrl攻城狮  阅读(928)  评论(0编辑  收藏  举报