102 lines
3.4 KiB
Text
Executable file
102 lines
3.4 KiB
Text
Executable file
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (C) 2017-2020 Team LibreELEC (https://libreelec.tv)
|
|
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
|
|
|
source ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/options
|
|
|
|
case "${PKG_SOC}" in
|
|
rk35*|rk3399)
|
|
IDBSEEK="bs=512 seek=64"
|
|
;;
|
|
*)
|
|
IDBSEEK="bs=32k seek=1"
|
|
;;
|
|
esac
|
|
|
|
if [ -f "${RELEASE_DIR}/3rdparty/bootloader/idbloader.img" ]; then
|
|
echo "image: burn idbloader.img to image... (${PKG_SOC},${IDBSEEK})"
|
|
dd if="${RELEASE_DIR}/3rdparty/bootloader/idbloader.img" of="$DISK" ${IDBSEEK} conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error
|
|
fi
|
|
|
|
|
|
|
|
case "${PKG_SOC}" in
|
|
rk35*)
|
|
if [ -f "${RELEASE_DIR}/3rdparty/bootloader/u-boot.itb" ]; then
|
|
echo "image: burn uboot.itb to image... (${PKG_SOC})"
|
|
dd if="${RELEASE_DIR}/3rdparty/bootloader/u-boot.itb" of="${DISK}" bs=512 seek=16384 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error
|
|
fi
|
|
if [ -f "${RELEASE_DIR}/3rdparty/bootloader/trust.img" ]; then
|
|
echo "image: burn trust.img to image..."
|
|
dd if="${RELEASE_DIR}/3rdparty/bootloader/trust.img" of="${DISK}" bs=512 seek=24576 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error
|
|
elif [ -f "${RELEASE_DIR}/3rdparty/bootloader/resource.img" ]; then
|
|
echo "image: burn resource.img to image..."
|
|
dd if="${RELEASE_DIR}/3rdparty/bootloader/resource.img" of="${DISK}" bs=512 seek=24576 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error
|
|
fi
|
|
;;
|
|
*)
|
|
if [ -f "${RELEASE_DIR}/3rdparty/bootloader/uboot.img" ]; then
|
|
echo "image: burn uboot.img to image..."
|
|
dd if="${RELEASE_DIR}/3rdparty/bootloader/uboot.img" of="$DISK" bs=512 seek=16384 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error
|
|
fi
|
|
if [ -f "${RELEASE_DIR}/3rdparty/bootloader/trust.img" ]; then
|
|
echo "image: burn trust.img to image..."
|
|
dd if="${RELEASE_DIR}/3rdparty/bootloader/trust.img" of="$DISK" bs=512 seek=24576 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
#Create boot.scr
|
|
if [ "${BOOT_INI}" == true ]
|
|
then
|
|
echo "image: create boot.scr..."
|
|
if [ -e "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/boot.scr" ]
|
|
then
|
|
cp ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/boot.scr ${LE_TMP}/boot.scr
|
|
sed -i "s~@BOOT_UUID@~${BOOT_UUID}~g" ${LE_TMP}/boot.scr
|
|
sed -i "s~@DISK_UUID@~${DISK_UUID}~g" ${LE_TMP}/boot.scr
|
|
sed -i "s~@EXTRA_CMDLINE@~${EXTRA_CMDLINE}~g" ${LE_TMP}/boot.scr
|
|
sed -i "s~@PKG_LOAD_ADDR@~${PKG_LOAD_ADDR}~g" ${LE_TMP}/boot.scr
|
|
sed -i "s~@DTB_LOAD_ADDR@~${DTB_LOAD_ADDR}~g" ${LE_TMP}/boot.scr
|
|
mcopy -so "${LE_TMP}/boot.scr" ::
|
|
else
|
|
echo "ERROR: No boot.scr found in ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
mkdir -p "${LE_TMP}/extlinux"
|
|
|
|
# copy device trees to part1
|
|
for DTB in ${DEVICE_DTB[@]}
|
|
do
|
|
if [ -e "${DTB}.dtb" ]
|
|
then
|
|
echo "image: copy device trees to image..."
|
|
mcopy -o "${DTB}.dtb" ::
|
|
fi
|
|
done
|
|
|
|
if [ "${EXT_LINUX_CONF}" == true ]
|
|
then
|
|
mkdir -p "${LE_TMP}/extlinux"
|
|
|
|
if [ "${#DEVICE_DTB}" -gt 1 ]
|
|
then
|
|
echo "image: Set FDTDIR to /..."
|
|
FDTMODE="FDTDIR /"
|
|
else
|
|
echo "image: Set FDT to ${DEVICE_DTB}..."
|
|
FDTMODE="FDT /${DEVICE_DTB}.dtb"
|
|
fi
|
|
|
|
echo "image: Set extlinux.conf..."
|
|
cat << EOF > "${LE_TMP}/extlinux/extlinux.conf"
|
|
LABEL ${DISTRO}
|
|
LINUX /${KERNEL_NAME}
|
|
${FDTMODE}
|
|
APPEND boot=UUID=${UUID_SYSTEM} disk=UUID=${UUID_STORAGE} ${EXTRA_CMDLINE}
|
|
EOF
|
|
|
|
mcopy -so "${LE_TMP}/extlinux" ::
|
|
fi
|