summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-core/classes
diff options
context:
space:
mode:
authorRaju Kumar Pothuraju <raju.kumar-pothuraju@xilinx.com>2022-06-27 17:36:14 +0530
committerMark Hatle <mark.hatle@amd.com>2022-06-27 12:57:58 -0700
commit001e3cafc84447ebbcc389026207a1269cdf2fb7 (patch)
tree654f7c8f6f62375182594a404b26cc72eee19dea /meta-xilinx-core/classes
parent516c749a000d3113b2d1ad903e89166729119135 (diff)
downloadmeta-xilinx-001e3cafc84447ebbcc389026207a1269cdf2fb7.tar.gz
image-types-xilinx-qemu: Add qemu-sd-fatimg support
qemu-sd: Qemu 6.X onwards SD image should be of power of 2, this patch will read the generate qemu-sd image and find out its next power of 2 and adjust the size using qemu-img resize command. qemu-sd-fatimg: Due to circular dependencies in yocto when we enable INITRAMFS_IMAGE + wic and we need SD fat image to boot versal on qemu. For this added new image conversion type qemu-sd-fatimg, it will generate the sd fatimg containing boot.bin,boot.scr,rootfs.cpio.gz.u-boot files. Usage: IMAGE_FSTYPES += "cpio.gz.u-boot.qemu-sd-fatimg" NOTE: qemu-sd-fatimg creation is a workaround fix for circular dependencies. Signed-off-by: Raju Kumar Pothuraju <raju.kumar-pothuraju@xilinx.com> Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-xilinx-core/classes')
-rw-r--r--meta-xilinx-core/classes/image-types-xilinx-qemu.bbclass55
1 files changed, 52 insertions, 3 deletions
diff --git a/meta-xilinx-core/classes/image-types-xilinx-qemu.bbclass b/meta-xilinx-core/classes/image-types-xilinx-qemu.bbclass
index 63318087..9532287d 100644
--- a/meta-xilinx-core/classes/image-types-xilinx-qemu.bbclass
+++ b/meta-xilinx-core/classes/image-types-xilinx-qemu.bbclass
@@ -5,6 +5,55 @@
5# block device to match that of valid SD card sizes (which are multiples of 5# block device to match that of valid SD card sizes (which are multiples of
6# 512K). 6# 512K).
7 7
8CONVERSIONTYPES:append = " qemu-sd" 8CONVERSIONTYPES:append = " qemu-sd qemu-sd-fatimg"
9CONVERSION_CMD:qemu-sd = "cp ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.qemu-sd; truncate -s %256M ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.qemu-sd" 9CONVERSION_CMD:qemu-sd () {
10CONVERSION_DEPENDS_qemu-sd = "coreutils-native" 10 cp ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.qemu-sd
11 # Get the wic.qemu-sd file size
12 file_size=`stat -c '%s' ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.qemu-sd`
13 powerof2=1
14 file_size=${file_size%.*}
15 # Get the next power of 2 value for the image size value
16 while [ ${powerof2} -lt ${file_size} ]; do
17 powerof2=$(expr $powerof2 \* 2)
18 done
19 # Resize the image using qemu-img
20 qemu-img resize -f raw ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.qemu-sd ${powerof2}
21}
22
23BOOT_VOLUME_ID ?= "BOOT"
24BOOT_SPACE ?= "1047552"
25IMAGE_ALIGNMENT ?= "1024"
26
27# Create SD image in case of INITRAMFS_IMAGE set due to circular dependencies.
28# This creates FAT partitioned SD image containing boot.bin,boot.scr and rootfs.cpio.gz.u-boot files.
29# This is a workaround fix until we fix the circular dependencies
30# Usage: IMAGE_FSTYPES:append = " cpio.gz.u-boot.qemu-sd-fatimg"
31CONVERSION_CMD:qemu-sd-fatimg () {
32 QEMU_IMG="${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.qemu-sd-fatimg"
33 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ALIGNMENT} - 1)
34 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ALIGNMENT})
35 QEMUIMG_SIZE=$(expr ${IMAGE_ALIGNMENT} + ${BOOT_SPACE_ALIGNED})
36 dd if=/dev/zero of=${QEMU_IMG} bs=1024 count=0 seek=${QEMUIMG_SIZE}
37 parted -s ${QEMU_IMG} mklabel msdos
38 parted -s ${QEMU_IMG} unit KiB mkpart primary fat32 ${IMAGE_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ALIGNMENT} \- 1)
39 parted -s ${QEMU_IMG} set 1 boot on
40 parted ${QEMU_IMG} print
41 BOOT_BLOCKS=$(LC_ALL=C parted -s ${QEMU_IMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
42 rm -f ${WORKDIR}/${BOOT_VOLUME_ID}.img
43 mkfs.vfat -n "${BOOT_VOLUME_ID}" -S 512 -C ${WORKDIR}/${BOOT_VOLUME_ID}.img $BOOT_BLOCKS
44 if [ -e ${DEPLOY_DIR_IMAGE}/boot.bin ]; then
45 mcopy -i ${WORKDIR}/${BOOT_VOLUME_ID}.img -s ${DEPLOY_DIR_IMAGE}/boot.bin ::/
46 fi
47 if [ -e ${DEPLOY_DIR_IMAGE}/boot.scr ]; then
48 mcopy -i ${WORKDIR}/${BOOT_VOLUME_ID}.img -s ${DEPLOY_DIR_IMAGE}/boot.scr ::/
49 fi
50 if [ ${INITRAMFS_IMAGE} = ${IMAGE_BASENAME} ] && [ x"${INITRAMFS_IMAGE_BUNDLE}" != "x1" ]; then
51 mcopy -i ${WORKDIR}/${BOOT_VOLUME_ID}.img -s ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ::rootfs.cpio.gz.u-boot
52 fi
53 dd if=${WORKDIR}/${BOOT_VOLUME_ID}.img of=${QEMU_IMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ALIGNMENT} \* 1024)
54}
55
56CONVERSION_DEPENDS_qemu-sd = "qemu-xilinx-system-native"
57CONVERSION_DEPENDS_qemu-sd-fatimg = "mtools-native:do_populate_sysroot \
58 dosfstools-native:do_populate_sysroot \
59 parted-native:do_populate_sysroot"