2023-01-08 22:49:32 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Copyright (C) 2017-2020 Team LibreELEC (https://libreelec.tv)
|
2023-10-24 16:00:57 +00:00
|
|
|
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
|
2023-01-08 22:49:32 +00:00
|
|
|
|
|
|
|
source ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/options
|
|
|
|
|
2023-05-04 18:06:54 +00:00
|
|
|
case "${PKG_SOC}" in
|
2023-06-23 03:14:11 +00:00
|
|
|
rk35*|rk3399)
|
2023-05-04 18:06:54 +00:00
|
|
|
IDBSEEK="bs=512 seek=64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
IDBSEEK="bs=32k seek=1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2023-01-08 22:49:32 +00:00
|
|
|
if [ -f "${RELEASE_DIR}/3rdparty/bootloader/idbloader.img" ]; then
|
2023-05-04 18:06:54 +00:00
|
|
|
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
|
2023-01-08 22:49:32 +00:00
|
|
|
fi
|
2023-01-09 22:26:15 +00:00
|
|
|
|
2023-05-04 18:06:54 +00:00
|
|
|
|
|
|
|
|
2023-01-08 22:49:32 +00:00
|
|
|
case "${PKG_SOC}" in
|
2023-02-16 22:40:39 +00:00
|
|
|
rk35*)
|
2024-01-09 23:30:50 +00:00
|
|
|
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
|
|
|
|
;;
|
|
|
|
rk3399)
|
|
|
|
if [ -f "${RELEASE_DIR}/3rdparty/bootloader/rk3399-uboot.bin" ]; then
|
|
|
|
echo "image: burn u-boot.bin to image..."
|
|
|
|
dd if="${RELEASE_DIR}/3rdparty/bootloader/rk3399-uboot.bin" of="${DISK}" bs=512 seek=64 conv=sync,noerror,notrunc >"${SAVE_ERROR}" 2>&1 || show_error
|
|
|
|
fi
|
2023-05-04 18:06:54 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
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
|
|
|
|
;;
|
2023-01-08 22:49:32 +00:00
|
|
|
esac
|
|
|
|
|
2023-05-11 19:11:56 +00:00
|
|
|
#Create boot.ini
|
|
|
|
if [ "${BOOT_INI}" == true ]
|
|
|
|
then
|
2023-11-06 11:24:29 +00:00
|
|
|
echo "boot: create boot.ini..."
|
|
|
|
cp -f ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/boot/boot.ini ${LE_TMP}/boot.ini
|
2023-11-06 12:27:57 +00:00
|
|
|
sed -i "s~@UUID_SYSTEM@~${UUID_SYSTEM}~g" ${LE_TMP}/boot.ini
|
|
|
|
sed -i "s~@UUID_STORAGE@~${UUID_STORAGE}~g" ${LE_TMP}/boot.ini
|
|
|
|
sed -i "s~@EXTRA_CMDLINE@~${EXTRA_CMDLINE}~g" ${LE_TMP}/boot.ini
|
2023-11-06 11:24:29 +00:00
|
|
|
mcopy -so "${LE_TMP}/boot.ini" ::
|
2023-01-08 22:49:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "${LE_TMP}/extlinux"
|
|
|
|
|
|
|
|
# copy device trees to part1
|
|
|
|
for DTB in ${DEVICE_DTB[@]}
|
|
|
|
do
|
|
|
|
if [ -e "${DTB}.dtb" ]
|
|
|
|
then
|
2023-03-10 13:14:45 +00:00
|
|
|
echo "image: copy device trees to image..."
|
2023-01-08 22:49:32 +00:00
|
|
|
mcopy -o "${DTB}.dtb" ::
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2023-05-11 19:11:56 +00:00
|
|
|
if [ "${EXT_LINUX_CONF}" == true ]
|
|
|
|
then
|
2023-01-08 22:49:32 +00:00
|
|
|
mkdir -p "${LE_TMP}/extlinux"
|
|
|
|
|
2023-11-21 21:47:47 +00:00
|
|
|
if [ "${TRUST_LABEL}" = "resource" ] || \
|
2023-11-21 23:02:54 +00:00
|
|
|
[ "${#DEVICE_DTB[@]}" -gt 1 ]
|
2023-02-21 22:32:31 +00:00
|
|
|
then
|
2023-03-10 13:14:45 +00:00
|
|
|
echo "image: Set FDTDIR to /..."
|
2023-02-21 22:32:31 +00:00
|
|
|
FDTMODE="FDTDIR /"
|
|
|
|
else
|
2023-03-23 21:12:16 +00:00
|
|
|
echo "image: Set FDT to ${DEVICE_DTB}..."
|
2023-02-21 22:32:31 +00:00
|
|
|
FDTMODE="FDT /${DEVICE_DTB}.dtb"
|
|
|
|
fi
|
|
|
|
|
2023-03-10 13:14:45 +00:00
|
|
|
echo "image: Set extlinux.conf..."
|
2023-01-08 22:49:32 +00:00
|
|
|
cat << EOF > "${LE_TMP}/extlinux/extlinux.conf"
|
|
|
|
LABEL ${DISTRO}
|
|
|
|
LINUX /${KERNEL_NAME}
|
2023-02-21 22:32:31 +00:00
|
|
|
${FDTMODE}
|
2023-01-08 22:49:32 +00:00
|
|
|
APPEND boot=UUID=${UUID_SYSTEM} disk=UUID=${UUID_STORAGE} ${EXTRA_CMDLINE}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
mcopy -so "${LE_TMP}/extlinux" ::
|
2023-05-11 19:11:56 +00:00
|
|
|
fi
|