Lakka-LibreELEC/projects/Rockchip/bootloader/install
Alex Bee d07974f0cc Rockchip: bootloader: allow ROCKCHIP_LEGACY_BOOT to be passed from command line
Also document that option in README.md and drop the non-required U_BOOT_CONFIG form bootloader/install script
2023-02-11 11:48:39 +01:00

55 lines
2.2 KiB
Plaintext

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
PKG_RKBIN="$(get_build_dir rkbin)"
PKG_SOC="${DEVICE/RK/rk}"
if [ "${ROCKCHIP_LEGACY_BOOT}" = "1" ]; then
echo "install: building Rockchip legacy boot chain ..."
if [ ! -f u-boot-dtb.bin ]; then
echo "install: u-boot-dtb.bin does not exist UBOOT_TARGET: ${UBOOT_TARGET}"
exit 1
fi
PKG_BOOT_INI="${PKG_RKBIN}"/RKBOOT/"${DEVICE}"MINIALL.ini
if [ ! -f "${PKG_BOOT_INI}" ]; then
echo "install: ${PKG_BOOT_INI} does not exist"
exit 1
fi
PKG_DDR_BIN="${PKG_RKBIN}"/$(sed -n "/FlashData/s/FlashData=//p" "${PKG_BOOT_INI}")
PKG_MINILOADER="${PKG_RKBIN}"/$(sed -n "/FlashBoot/s/FlashBoot=//p" "${PKG_BOOT_INI}")
PKG_LOAD_ADDR=$(sed -n "/SYS_TEXT_BASE/s/#define CONFIG_SYS_TEXT_BASE //p" u-boot.cfg)
# Override sdram frequency
if [ "${DEVICE}" = "RK3328" ]; then
sed -s 's/\x4d\x1\x4d\x1\x4d\x1\x4d\x1\x4d\x1\x4d\x1/\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3/g' -i "${PKG_DDR_BIN}"
sed -s 's/\x90\x1\x90\x1\x90\x1\x90\x1\x90\x1\x90\x1/\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3\x20\x3/g' -i "${PKG_DDR_BIN}"
fi
${PKG_RKBIN}/tools/mkimage -n "${PKG_SOC}" -T rksd -d "${PKG_DDR_BIN}":"${PKG_MINILOADER}" idbloader.img.rk || exit 1
${PKG_RKBIN}/tools/loaderimage --pack --uboot u-boot-dtb.bin uboot.img.rk "${PKG_LOAD_ADDR}" || exit 1
dd if=idbloader.img.rk of="${UBOOT_FIT_IMAGE}" seek=0 conv=fsync,notrunc > /dev/null 2>&1 || exit 1
dd if=uboot.img.rk of="${UBOOT_FIT_IMAGE}" seek=16320 conv=fsync,notrunc > /dev/null 2>&1 || exit 1
if [ "${TARGET_ARCH}" = "aarch64" -o "${TARGET_KERNEL_ARCH}" = "arm64" ]; then
PKG_ATF_INI="${PKG_RKBIN}"/RKTRUST/"${DEVICE}"TRUST.ini
if [ ! -f "${PKG_ATF_INI}" ]; then
echo "install: ${PKG_ATF_INI} does not exist"
exit 1
fi
"${PKG_RKBIN}"/tools/trust_merger --ignore-bl32 --prepath "${PKG_RKBIN}"/ "${PKG_ATF_INI}" || exit 1
dd if=trust.img of="${UBOOT_FIT_IMAGE}" seek=24512 conv=fsync,notrunc > /dev/null 2>&1 || exit 1
fi
fi
if [ -f "${UBOOT_FIT_IMAGE}" ]; then
cp -av "${UBOOT_FIT_IMAGE}" "${INSTALL}"/usr/share/bootloader
else
echo "install: bootloader ${UBOOT_FIT_IMAGE} was not built."
exit 1
fi