Files
auracaster-os/board/raspberrypi3_swupdate/post-image.sh
2025-04-17 13:21:38 +02:00

63 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
set -e
BOARD_DIR="$(dirname $0)"
BOARD_NAME="$(basename ${BOARD_DIR})"
GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
# Copy u-boot.bin to the firmware directory for Raspberry Pi bootloader
echo "Copying u-boot.bin to rpi-firmware directory..."
if [ -f "${BINARIES_DIR}/u-boot.bin" ]; then
cp "${BINARIES_DIR}/u-boot.bin" "${BINARIES_DIR}/rpi-firmware/"
else
echo "WARNING: u-boot.bin not found in ${BINARIES_DIR}" >&2
fi
# Pass arguments to genimage
GENIMAGE_ARGS="--rootpath ${TARGET_DIR}"
# Create the boot.scr U-Boot script
${HOST_DIR}/bin/mkimage -A arm -O linux -T script -C none -d ${BOARD_DIR}/boot.scr.txt ${BINARIES_DIR}/boot.scr
# Create a file to indicate that this is rootfs A
touch ${TARGET_DIR}/etc/rootfs-A
# Create an empty ext4 rootfs-B image of the same size as rootfs
cp ${BINARIES_DIR}/rootfs.ext4 ${BINARIES_DIR}/rootfs-B.ext4
# Create uboot environment
${HOST_DIR}/bin/mkenvimage -s 131072 -o "${BINARIES_DIR}/uboot-env.img" "${BOARD_DIR}/uboot-env.txt"
# Copy U-Boot environment image as uboot.env to rpi-firmware directory
cp "${BINARIES_DIR}/uboot-env.img" "${BINARIES_DIR}/rpi-firmware/uboot.env"
# Create version file
echo "VERSION=${BR2_VERSION_FULL}" > ${BINARIES_DIR}/version
# Mark inactive rootfs partition as clean
touch ${BINARIES_DIR}/.rootfs-B.ext4.done
# Copy the cmdline.txt and config.txt files
cp ${BOARD_DIR}/cmdline.txt ${BINARIES_DIR}/cmdline.txt
cp ${BOARD_DIR}/config.txt ${BINARIES_DIR}/config.txt
rm -rf "${GENIMAGE_TMP}"
genimage \
--loglevel 1 \
${GENIMAGE_ARGS} \
--tmppath "${GENIMAGE_TMP}" \
--inputpath "${BINARIES_DIR}" \
--outputpath "${BINARIES_DIR}" \
--config "${GENIMAGE_CFG}"
# Create symlink for easy flashing with dd
ln -sf "${BINARIES_DIR}/sdcard.img" "${BINARIES_DIR}/auracaster-swupdate.img"
# Create a compressed version for distribution
if [ -x "$(command -v xz)" ]; then
xz -T0 -c "${BINARIES_DIR}/sdcard.img" > "${BINARIES_DIR}/auracaster-swupdate.img.xz"
fi
exit $?