# SPDX-License-Identifier: GPL-2.0 # Copyright (C) 2017-2021 Team LibreELEC (https://libreelec.tv) # Copyright (C) 2021-present Fewtarius # Copyright (C) 2023-present Brooksytech PKG_RKBIN="$(get_build_dir rkbin)" PKG_UBOOT="$(get_build_dir u-boot)" source ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/options RKSPI_LOADER=${INSTALL}/usr/share/bootloader/rkspi_loader.img generate_rkspi_loader() { echo "spi: create rkspi_loader.img..." dd if=/dev/zero of=$RKSPI_LOADER bs=1M count=0 seek=16 parted -s $RKSPI_LOADER mklabel gpt parted -s $RKSPI_LOADER unit s mkpart idbloader 64 7167 parted -s $RKSPI_LOADER unit s mkpart vnvm 7168 7679 parted -s $RKSPI_LOADER unit s mkpart reserved_space 7680 8063 parted -s $RKSPI_LOADER unit s mkpart reserved1 8064 8127 parted -s $RKSPI_LOADER unit s mkpart uboot_env 8128 8191 parted -s $RKSPI_LOADER unit s mkpart reserved2 8192 16383 parted -s $RKSPI_LOADER unit s mkpart uboot 16384 32734 echo "spi: write idbloader.img to rkspi_loader.img..." dd if=${PKG_BUILD}/idbloader.img of=$RKSPI_LOADER seek=64 conv=notrunc echo "spi: write uboot.itb to rkspi_loader.img..." dd if=${PKG_BUILD}/u-boot.itb of=$RKSPI_LOADER seek=16384 conv=notrunc } if [ -n "${PKG_DATAFILE}" -a -n "${PKG_LOADER}" ]; then echo "loader: Make idbloader.img from ${PKG_DATAFILE}:${PKG_LOADER}..." case "${PKG_SOC}" in rk35*|rk3399) tools/mkimage -n ${PKG_SOC} -T rksd -d ${PKG_DATAFILE}:${PKG_LOADER} -C bzip2 idbloader.img ;; *) tools/mkimage -n ${PKG_SOC} -T rksd -d "${PKG_DATAFILE}" -C bzip2 idbloader.img cat "${PKG_LOADER}" >> idbloader.img ;; esac fi echo "uboot: copy idbloader.img image to ${INSTALL}/usr/share/bootloader..." cp -av idbloader.img ${INSTALL}/usr/share/bootloader if [ ! -n "${PKG_LOAD_ADDR}" ]; then PKG_LOAD_ADDR="0x00200000" fi case "${PKG_SOC}" in rk35*) echo "uboot: copy u-boot.itb image to ${INSTALL}/usr/share/bootloader..." cp -av u-boot.itb ${INSTALL}/usr/share/bootloader/u-boot.itb generate_rkspi_loader ;; *) echo "uboot: build loader image uboot.img at ${PKG_LOAD_ADDR}..." ${PKG_UBOOT}/tools/loaderimage --pack --uboot u-boot-dtb.bin uboot.img ${PKG_LOAD_ADDR} ||: cp -av uboot.img ${INSTALL}/usr/share/bootloader ;; esac case "${DEVICE}" in RK33*) if [ -n "${PKG_BL31}" ]; then echo "trust: create trust.ini..." cat >trust.ini <${INSTALL}/usr/share/bootloader/boot.ini < "${INSTALL}/usr/share/bootloader/extlinux/extlinux.conf" LABEL ${DISTRO} LINUX /${KERNEL_NAME} ${FDTMODE} APPEND boot=UUID=@BOOT_UUID@ disk=UUID=@DISK_UUID@ ${EXTRA_CMDLINE} EOF fi