【分享】使用Petalinux的boot文件、根文件系統,和開源Linux的Image啟動


使用Petalinux的boot文件、根文件系統,和開源Linux的Image啟動

概述

作者: 付漢傑 hankf@xilinx.com hankf@amd.com
測試環境: Vivado/PetaLinux 2021.2, Linux 5.10.0,VCK190

image.ub啟動

Petalinux編譯后,在images/linux里,既有Image,也有image.ub。image.ub已經帶文件系統,可以獨立啟動。查看boot.scr,可以看到uboot加載image.ub后,執行命令“bootm 0x10000000”,啟動了Linux。

fitimage_name=image.ub

	if test -e ${devtype} ${devnum}:${distro_bootpart} /${fitimage_name}; then
		fatload ${devtype} ${devnum}:${distro_bootpart} 0x10000000 ${fitimage_name};
		bootm 0x10000000;
    fi

使用image.ub,只有一個文件,使用起來最簡單方便。

Image啟動

在調試時,也可以使用分開的Image、rootfs.cpio.gz.u-boot、system.dtb。查看boot.scr,可以看到uboot依次檢查上述3個文件是否存在。如果存在,就加載。加載完rootfs.cpio.gz.u-boot后,執行命令“booti 0x00200000 0x04000000 0x00001000”,啟動了Linux。

kernel_name=Image
rootfs_name=rootfs.cpio.gz.u-boot

	if test -e ${devtype} ${devnum}:${distro_bootpart} /${kernel_name}; then
		fatload ${devtype} ${devnum}:${distro_bootpart} 0x00200000 ${kernel_name};
	fi
	
	if test -e ${devtype} ${devnum}:${distro_bootpart} /system.dtb; then
		fatload ${devtype} ${devnum}:${distro_bootpart} 0x00001000 system.dtb;
	fi
	
	if test -e ${devtype} ${devnum}:${distro_bootpart} /${rootfs_name} && test "${skip_ramdisk}" != "yes"; then
		fatload ${devtype} ${devnum}:${distro_bootpart} 0x04000000 ${rootfs_name};
		booti 0x00200000 0x04000000 0x00001000
	fi

如果Image和image.ub都存在,優先使用image.ub啟動。

使用Petalinux的boot文件、根文件系統,和開源Linux的Image啟動

使用PetaLinux編譯時,會自動生成根文件系統,耗時較長,導致調試不方便。在編譯PetaLinux工程后,把Linux kernel的代碼和配置文件復制出來。修改Linux kernel的代碼后,直接編譯,得到對應的Image和ko文件,也可以使用上述命令啟動。

hankf$ find -name "kernel-source"
./build/tmp/work-shared/versal-generic/kernel-source

hankf$ find -name ".config" | xargs -n 1 ls
./build/tmp/work/versal_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/linux-xlnx-5.10+git999/.config
./build/tmp/work/versal_generic-xilinx-linux/u-boot-xlnx/v2021.01-xilinx-v2021.2+gitAUTOINC+63b6d260db-r0/build/.config
./build/tmp/work-shared/versal-generic/kernel-build-artifacts/.config

其中體積最大的文件,是Linux的配置文件。復制到默認配置文件夾,比如arm64的是“arch/arm64/configs/”中,命名為xilinx_xxx_defconfig,比如命名為 xilinx_vck190_defconfig。

hankf$ ls arch/arm64/configs/ -l
total 236
-rw-r--r-- 1 hankf hankf  25682 Mar  1 15:41 defconfig
-rw-r--r-- 1 hankf hankf  11334 Mar  1 15:41 xilinx_defconfig
-rw-r--r-- 1 hankf hankf 179126 Mar  2 10:37 xilinx_vck190_defconfig
-rw-r--r-- 1 hankf hankf   5635 Mar  1 15:41 xilinx_versal_defconfig
-rw-r--r-- 1 hankf hankf   9726 Mar  1 15:41 xilinx_zynqmp_defconfig

在Linux kernel的代碼的代碼目錄,執行“make xilinx_vck190_defconfig”,再編譯,就能得到對應的Image和ko文件。相對PetaLinux編譯,這種方式更快,也能使用PetaLinux的boot文件和根文件系統。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM