以下流程基于petalinux 2017.2实现。
petalinux-create -t project -n example --template zynqMP
petalinux-config --get-hw-description -p example/
文件系统选initrd,最终文件系统不会集成到linux kernel image中,名称为rootfs.cipi.gz,默认是Initramfs(集成在linux内核image中)
Image Packaging Configuration ---> Root filesystem type (INITRAMFS) ---> (X) INITRD
initrd vs. initramfs
- Using initrd, kernel and initial file system are splitted. Making changes to kernel or filesystem doesn't touch the other one. The download size (e.g. while development) of one component is smaller.
- Creating and modifying an initramfs is easier than with initrd (unzip & mount & unmount & zip)
- Having one big image (kernel & initramfs) is easier to handle (e.g. download or flashing) than having two splitted images.
cd example
petalinux-config -c rootfs
Filesystem Packages ---> misc ---> packagegroup-petalinux-xen ---> [*] packagegroup-petalinux-xen
从ZCU102 BSP中拷贝这两个文件,
修改sytem-user.dtsi
project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
/include/ "system-conf.dtsi"
/include/ "xen-overlay.dtsi"
/ {
};
xen-overlay.dtsi内容如下,
QEMU dts文件修改如下,
There is a bug on QEMU where the CPUs running in SMP sometimes cause hangs. To avoid this we only tell Xen about a single CPU.
/include/ "system-conf.dtsi"
/include/ "xen-overlay.dtsi"
/ {
cpus {
cpu@1 {
device_type = "none";
};
cpu@2 {
device_type = "none";
};
cpu@3 {
device_type = "none";
};
};
};
修改下面文件,
project-spec/meta-user/recipes-bsp/device-tree/device-tree-generation_%.bbappend
SRC_URI_append ="\
file://system-user.dtsi \
file://xen-overlay.dtsi \
"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
编译
petalinux-build
生成的结果都在images/linux下面,
mkimage -l xen.ub
[ttan@xterra1 plnx_aarch64]$ file xen.ub
xen.ub: u-boot legacy uImage, , Linux/ OS Kernel Image (Not compressed), 721216 bytes, Mon Jun 19 20:37:18 2017, Load Address: 0x05000000, Entry Point: 0x05000000, Header CRC: 0x974E7A3F, Data CRC: 0xA212F4D9
xen和xen.efi是同一个文件,xen.ub是用mkimage在xen前面加上了64byte uboot头
Xen in EFI
Xen 4.3 and later can be built as EFI binaries. Xen 4.5 can be built as an EFI binary under ARM. Xen 4.9 can be built with Multiboot2 support which GRUB2 2.02 uses.
Linux 3.17 and later when built with CONFIG_XEN_EFI can be booted under Xen in EFI platform.
检查一下image.ub的组成,
[ttan@xterra1 linux]$ mkimage -l image.ub
FIT description: U-Boot fitImage for plnx_aarch64 kernel
Created: Wed Dec 13 21:01:41 2017
Image 0 (kernel@0)
Description: Linux Kernel
Created: Wed Dec 13 21:01:41 2017
Type: Kernel Image
Compression: uncompressed
Data Size: 13171200 Bytes = 12862.50 kB = 12.56 MB
Architecture: AArch64
OS: Linux
Load Address: 0x00080000
Entry Point: 0x00080000
Hash algo: sha1
Hash value: 9997c10bd518a2777a2272c668207b44b05a79e7
Image 1 (fdt@0)
Description: Flattened Device Tree blob
Created: Wed Dec 13 21:01:41 2017
Type: Flat Device Tree
Compression: uncompressed
Data Size: 32845 Bytes = 32.08 kB = 0.03 MB
Architecture: AArch64
Hash algo: sha1
Hash value: 1e42b839a643fa14f51efb64c788cdbe56831b98
Image 2 (ramdisk@0)
Description: ramdisk
Created: Wed Dec 13 21:01:41 2017
Type: RAMDisk Image
Compression: uncompressed
Data Size: 38505066 Bytes = 37602.60 kB = 36.72 MB
Architecture: AArch64
OS: Linux
Load Address: unavailable
Entry Point: unavailable
Hash algo: sha1
Hash value: 61c6a03449342922af06f9aa7f4a07bcedca98c0
Default Configuration: 'conf@1'
Configuration 0 (conf@1)
Description: Boot Linux kernel with FDT blob + ramdisk
Kernel: kernel@0
Init Ramdisk: ramdisk@0
FDT: fdt@0
Configuration 1 (conf@2)
Description: Boot Linux kernel with FDT blob
Kernel: kernel@0
FDT: fdt@0
生成image.ub用的its文件如下,
QEMU启动uboot,在本地建一个tmp目录。同时从ZCU102 BSP中拷一些QEMU要用的文件,如zynqmp-qemu-multiarch-pmu.dtb
可以考虑把下面内容放到一个脚本文件中,这样可以直接运行,
#!/bin/bash
qemu-system-microblazeel \
-M microblaze-fdt \
-display none \
-kernel ./images/linux/pmu_rom_qemu_sha3.elf \
-device loader,file=./images/linux/pmufw.elf \
-hw-dtb ./images/linux/zynqmp-qemu-multiarch-pmu.dtb \
-machine-path ./tmp \
-device loader,addr=0xfd1a0074,data=0x1011003,data-len=4 \
-device loader,addr=0xfd1a007C,data=0x1010f03,data-len=4 &
qemu-system-aarch64 \
-M arm-generic-fdt \
-global xlnx,zynqmp-boot.cpu-num=0 \
-global xlnx,zynqmp-boot.use-pmufw=true \
-serial mon:stdio -serial /dev/null \
-display none \
-device loader,file=./images/linux/bl31.elf,cpu-num=0 \
-device loader,file=./images/linux/u-boot.elf \
-gdb tcp::9000 \
-dtb ./images/linux/system.dtb \
-net nic -net nic -net nic -net nic,vlan=1 -net user,vlan=1,tftp=images/linux \
-hw-dtb ./images/linux/zynqmp-qemu-multiarch-arm.dtb \
-machine-path ./tmp \
-m 4G
执行完上面脚本后,会进入uboot,接着执行下面命令加载并启动Linux
setenv serverip 10.0.2.2
tftpb 4000000 system.dtb; tftpb 0x80000 Image; tftpb 6000000 xen.ub; tftpb 0x1000000 rootfs.cpio.gz.u-boot; bootm 6000000 0x1000000 4000000
bootm的三个参数分别是 xen.ub, rootfs.cpio.gz.u-boot , system.dtb