Files
Arch-R/projects/Rockchip/bootloader/update.sh

78 lines
2.6 KiB
Bash
Raw Normal View History

# SPDX-License-Identifier: GPL-2.0
2018-07-16 20:45:36 +02:00
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
2017-11-01 22:57:41 +01:00
[ -z "${SYSTEM_ROOT}" ] && SYSTEM_ROOT=""
[ -z "${BOOT_ROOT}" ] && BOOT_ROOT="/flash"
[ -z "${BOOT_PART}" ] && BOOT_PART=$(df "${BOOT_ROOT}" | tail -1 | awk {' print $1 '})
if [ -z "${BOOT_DISK}" ]; then
case ${BOOT_PART} in
2017-11-01 22:57:41 +01:00
/dev/sd[a-z][0-9]*)
BOOT_DISK=$(echo ${BOOT_PART} | sed -e "s,[0-9]*,,g")
2017-11-01 22:57:41 +01:00
;;
/dev/mmcblk*)
BOOT_DISK=$(echo ${BOOT_PART} | sed -e "s,p[0-9]*,,g")
2017-11-01 22:57:41 +01:00
;;
esac
fi
# mount ${BOOT_ROOT} r/w
mount -o remount,rw ${BOOT_ROOT}
2017-11-01 22:57:41 +01:00
# update device tree
for all_dtb in ${BOOT_ROOT}/*.dtb; do
dtb=$(basename ${all_dtb})
# device tree mappings for update from vendor to mainline kernel
case "${dtb}" in
rk3288-miniarm.dtb)
new_dtb=rk3288-tinker-s.dtb
;;
rk3328-box.dtb|rk3328-box-trn9.dtb|rk3328-box-z28.dtb|rk3328-rockbox.dtb)
new_dtb=rk3328-a1.dtb
;;
rk3399-rock-pi-4.dtb)
new_dtb=rk3399-rock-pi-4b.dtb
;;
*)
new_dtb="${dtb}"
;;
esac
if [ "${dtb}" != "${new_dtb}" -a -f ${SYSTEM_ROOT}/usr/share/bootloader/${new_dtb} ]; then
echo -n "Replacing ${dtb} with ${new_dtb} ... "
cp -p ${SYSTEM_ROOT}/usr/share/bootloader/${new_dtb} ${BOOT_ROOT} && \
sed -e "s/FDT \/${dtb}/FDT \/${new_dtb}/g" \
-i ${BOOT_ROOT}/extlinux/extlinux.conf && \
rm -f ${BOOT_ROOT}/${dtb}
2017-11-01 22:57:41 +01:00
echo "done"
else
if [ -f ${SYSTEM_ROOT}/usr/share/bootloader/${dtb} ]; then
echo -n "Updating ${dtb}... "
cp -p ${SYSTEM_ROOT}/usr/share/bootloader/${dtb} ${BOOT_ROOT}
echo "done"
elif [ "$(grep -c "FDT /${dtb}" ${BOOT_ROOT}/extlinux/extlinux.conf)" -ne 0 ]; then
non_existend_dtb="${dtb}"
fi
2017-11-01 22:57:41 +01:00
fi
done
# update bootloader
2022-09-11 01:06:20 +02:00
if [ -f ${SYSTEM_ROOT}/usr/share/bootloader/u-boot-rockchip.bin ]; then
echo -n "Updating fit image u-boot-rockchip.bin ... "
2023-02-11 09:32:39 +01:00
dd if=${SYSTEM_ROOT}/usr/share/bootloader/u-boot-rockchip.bin of=${BOOT_DISK} bs=32k seek=1 conv=fsync,notrunc &>/dev/null
2017-11-01 22:57:41 +01:00
echo "done"
fi
# mount ${BOOT_ROOT} r/o
2017-11-01 22:57:41 +01:00
sync
mount -o remount,ro ${BOOT_ROOT}
# warning if device tree was not updated
if [ -n "${non_existend_dtb}" ]; then
echo "The device tree ${non_existend_dtb} your installation uses does not exist in this update package."
echo "The updated system will continue to use the device tree from the previous system and your installation might be broken."
echo "Please check documentation to find out which boards are supported by this package."
sleep 10
fi