Here are the steps to boot the Xilinx's ZynqMP based kernel through QEMU supported flash devices. These steps are validated against 2017.4 release version.

Using SD for Boot

Follow the below steps to boot the images


1. Create the FSBL after applying the attached patch.
Steps to apply the patch:-
  • copy the attached patch file to project-spec/meta-user/recipes-bsp/fsbl/files/
  • Update the project-spec/meta-user/recipes-bsp/fsbl/fsbl_%.bbappend
Attached the working 2017.4 FSBL for reference

2. Create the SD boot image using these steps:
dd if=/dev/zero of=qemu_sd.img bs=128M count=1
mkfs.vfat -F 32 qemu_sd.img
mcopy -i qemu_sd.img BOOT.BIN ::/
mcopy -i qemu_sd.img image.ub ::/
mcopy -i qemu_sd.img system.dtb ::/

3. Now to start the linux kernel booting, we need to run 2 QEMU instances one for PMUFW and ARM images.

PMU Instance:
qemu-system-microblazeel -M microblaze-fdt -nographic -dtb <proj>/pre-built/linux/images/zynqmp-qemu-multiarch-pmu.dtb -kernel <proj>/pre-built/linux/images/pmu_rom_qemu_sha3.elf
-device loader,file=<proj>/pre-built/linux/images/pmufw.elf -machine-path /tmp/ -gdb tcp::9005

ARM Instance:
qemu-system-aarch64 -M arm-generic-fdt -nographic -dtb pre-built/linux/images/zynqmp-qemu-multiarch-arm.dtb -device loader,file=zynqmp_fsbl.elf,cpu-num=0 -global xlnx,zynqmp-boot.cpu-num=0 -global xlnx,zynqmp-boot.use-pmufw=false -machine-path /tmp/ -gdb tcp::9001 -drive file=qemu_sd.img,if=sd,format=raw,index=1 -boot mode=5 -m 4G

4. This will stop at u-boot prompt. Issue this command to boot kernel from u-boot:

ZynqMP> fatload mmc 0:0 ${netstart} ${kernel_img} && bootm

Alternatively, instead of using extra command on u-boot to load kernel, we can copy the images into partition 1 as explained in ug1169 (SD-Card Partitioning and Loading an Ubuntu-core File System) and boot it directly without interruption

Using QSPI for Boot


In parallel mode, that the QSPI data passes in for each flash is unique to that flash chip.
Because the QSPI controller implements bit-striping in dual parallel mode, a special utilityis needed to take a single QSPI data image and format into the two images.

The Flash Striper Utility Section in the QEMU User Guide (UG1169) requires a flash_stripe.c file to stripe a single QSPI data image and format it into two images.
This file is currently not present in the QEMU utilities being shipped with PetaLinux
Please download flash_stripe.c attached to this Answer Record and follow the instructions below to build it.
https://www.xilinx.com/support/answers/69975.html

Steps to compile:

gcc flash_stripe.c -o flash_stripe -DFLASH_STRIPE_BE -DFLASH_STRIPE_BW

For example to create QSPI images for Dual Parallel Mode, here are the steps:-
dd if=/dev/zero bs=128M count=1 of=qemu_qspi_tmp.bin
dd if=BOOT.BIN of=qemu_qspi_tmp.bin bs=1 seek=0 conv=notrunc
flash_stripe qemu_qspi_tmp.bin qemu_qspi_low.bin qemu_qspi_high.bin

To boot the images through QEMU, run the below two instances:-
PMU instance:-
qemu-system-microblazeel -M microblaze-fdt -display none -kernel <proj>/pre-built/linux/images/pmu_rom_qemu_sha3.elf -device loader,file= <proj>/pre-built/linux/images/pmufw.elf -hw-dtb <proj>/pre-built/linux/images/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

ARM instanace:-

qemu-system-aarch64 -M arm-generic-fdt -global xlnx,zynqmp-boot.cpu-num=0 -global xlnx,zynqmp-boot.use-pmufw=true -global xlnx,zynqmp-boot.load-pmufw-cfg=false -serial mon:stdio -serial /dev/null -display none -device loader,file=pre-built/linux/images/bl31.elf,cpu-num=0 -device loader,file=pre-built/linux/images/Image,addr=0x00080000 -device loader,file=pre-built/linux/images/system.dtb,addr=0x1407f000 -device loader,file=build/misc/linux-boot/linux-boot.elf -gdb tcp::9000 -dtb pre-built/linux/images/system.dtb -hw-dtb pre-built/linux/images/zynqmp-qemu-multiarch-arm.dtb -machine-path /tmp/ -drive file=images/linux/qspi/qemu_qspi_high.bin,if=mtd,format=raw,index=0 -drive file=images/linux/qspi/qemu_qspi_low.bin,if=mtd,format=raw,index=1 -boot mode=2 -device loader,file=images/linux/zynqmp_fsbl.elf,cpu-num=0 -m 4G

This will stops at u-boot command prompt. Issue the "bootm" command to further boot the kernel.
ZynqMP> bootm

NOTE:- In future releases of petalinux, we will ship flash_strip utility as part of petalinux installation. If we source petalinux, then this utility is available to users and no need to compile this seperately.





Insert Code: Use Widget-> Insert Code
Insert your code here.

Related Links


1) Now we will have flash_strip in 18.1 petalinux release @/proj/petalinux/petalinux-v2018.1_0313_2/petalinux-v2018.1-final/tools/linux-i386/petalinux/bin/flash_strip_be_bw