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:
    <image deploy directory file>:<destination filename>

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 <christopher.w.clark@gmail.com>
This commit is contained in:
Christopher Clark 2020-07-15 15:46:23 -07:00 committed by Andrei Gherzan
parent eaf4a5f17e
commit c883daa802

View File

@ -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