ZCU102开发 (2) Xen

以下流程基于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

Image

Image(1)


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

Image(2)

Image(9)

从ZCU102 BSP中拷贝这两个文件,

Image(3)

修改sytem-user.dtsi

project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

Image(10)

/include/ "system-conf.dtsi"

/include/ "xen-overlay.dtsi"

/ {

};

xen-overlay.dtsi内容如下,

Image(11)

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

Image(12)

SRC_URI_append ="\

file://system-user.dtsi \

file://xen-overlay.dtsi \

"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

编译

petalinux-build

Image(13)

生成的结果都在images/linux下面,

mkimage -l xen.ub

Image(14)

[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

Image(15)

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文件如下,

Image(16)

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

Image(17)

bootm的三个参数分别是 xen.ub, rootfs.cpio.gz.u-boot , system.dtb

Image(18)

Image(19)

Image(20)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值