From bfde594164a0d3f9cfaf60fccd3bc4c85fa8c19c Mon Sep 17 00:00:00 2001 From: Christopher Clark Date: Wed, 15 Jul 2020 15:46:23 -0700 Subject: sdcard_image-rpi.bbclass: enable extensible inclusion into boot Add DEPLOYPAYLOAD, similar to the existing FATPAYLOAD, to enable adding files to the boot partition from the image deploy directory. Files such as hypervisor binaries may not be present (and in fact unwanted) within the root filesystem, so FATPAYLOAD is not sufficient. DEPLOYPAYLOAD is implemented with support for file renaming from the source file in the image deploy directory to the filename written into the boot image. DEPLOYPAYLOAD is a space-separated list of entries for additions, each of which can optionally be colon-separated: : If the colon separator is omitted, the source deploy directory filename is used as the destination filename. The support for specifying the destination filename is used for including Xen, which produces a machine-specific file in the image deploy directory, and is written to the image partition with its expected filename: xen. Files that are to be included from the image deploy directory will be produced by tasks that the do_image_rpi_sdimg[depends] must list, so enable adding entries to that via a new variable: RPI_SDIMG_EXTRA_DEPENDS. These changes enable retiring a Xen-specific Raspberry Pi SD card bbclass from meta-virtualization and have been tested on the Raspberry Pi 4. Signed-off-by: Christopher Clark --- classes/sdcard_image-rpi.bbclass | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/classes/sdcard_image-rpi.bbclass b/classes/sdcard_image-rpi.bbclass index 43426b2..779a9e2 100644 --- a/classes/sdcard_image-rpi.bbclass +++ b/classes/sdcard_image-rpi.bbclass @@ -59,6 +59,7 @@ do_image_rpi_sdimg[depends] = " \ ${@bb.utils.contains('MACHINE_FEATURES', 'armstub', 'armstubs:do_deploy', '' ,d)} \ ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'u-boot:do_deploy', '',d)} \ ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'u-boot-default-script:do_deploy', '',d)} \ + ${RPI_SDIMG_EXTRA_DEPENDS} \ " do_image_rpi_sdimg[recrdeps] = "do_build" @@ -148,6 +149,22 @@ IMAGE_CMD_rpi-sdimg () { fi fi + # Add files (eg. hypervisor binaries) from the deploy dir + if [ -n "${DEPLOYPAYLOAD}" ] ; then + echo "Copying deploy file payload into VFAT" + for entry in ${DEPLOYPAYLOAD} ; do + # Split entry at optional ':' to enable file renaming for the destination + if [ $(echo "$entry" | grep -c :) = "0" ] ; then + DEPLOY_FILE="$entry" + DEST_FILENAME="$entry" + else + DEPLOY_FILE="$(echo "$entry" | cut -f1 -d:)" + DEST_FILENAME="$(echo "$entry" | cut -f2- -d:)" + fi + mcopy -v -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${DEPLOY_FILE} ::${DEST_FILENAME} || bbfatal "mcopy cannot copy ${DEPLOY_DIR_IMAGE}/${DEPLOY_FILE} into boot.img" + done + fi + if [ -n "${FATPAYLOAD}" ] ; then echo "Copying payload into VFAT" for entry in ${FATPAYLOAD} ; do -- cgit v1.2.3-54-g00ecf