2023-01-08 22:49:32 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Copyright (C) 2017-2021 Team LibreELEC (https://libreelec.tv)
|
|
|
|
# Copyright (C) 2021-present Fewtarius
|
|
|
|
|
|
|
|
PKG_RKBIN="$(get_build_dir rkbin)"
|
|
|
|
PKG_UBOOT="$(get_build_dir u-boot)"
|
|
|
|
source ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/options
|
|
|
|
|
2023-01-10 23:39:16 +00:00
|
|
|
SPI_IMAGE=${INSTALL}/usr/share/bootloader/rkspi_loader.img
|
|
|
|
|
|
|
|
generate_spi_image() {
|
|
|
|
echo "spi: create rkspi_loader.img..."
|
|
|
|
dd if=/dev/zero of=$SPI_IMAGE bs=1M count=0 seek=16
|
|
|
|
parted -s $SPI_IMAGE mklabel gpt
|
|
|
|
parted -s $SPI_IMAGE unit s mkpart idbloader 64 7167
|
|
|
|
parted -s $SPI_IMAGE unit s mkpart vnvm 7168 7679
|
|
|
|
parted -s $SPI_IMAGE unit s mkpart reserved_space 7680 8063
|
|
|
|
parted -s $SPI_IMAGE unit s mkpart reserved1 8064 8127
|
|
|
|
parted -s $SPI_IMAGE unit s mkpart uboot_env 8128 8191
|
|
|
|
parted -s $SPI_IMAGE unit s mkpart reserved2 8192 16383
|
|
|
|
parted -s $SPI_IMAGE unit s mkpart uboot 16384 32734
|
|
|
|
echo "spi: write idbloader.img to rkspi_loader.img..."
|
|
|
|
dd if=${PKG_BUILD}/idbloader.img of=$SPI_IMAGE seek=64 conv=notrunc
|
|
|
|
echo "spi: write u-boot.itb to rkspi_loader.img..."
|
|
|
|
dd if=${PKG_BUILD}/u-boot.itb of=$SPI_IMAGE seek=16384 conv=notrunc
|
|
|
|
}
|
|
|
|
|
2023-01-08 22:49:32 +00:00
|
|
|
if [ -n "${PKG_DATAFILE}" -a -n "${PKG_LOADER}" ]; then
|
|
|
|
echo "loader: Make idbloader.img from ${PKG_DATAFILE}:${PKG_LOADER}..."
|
|
|
|
case "${PKG_SOC}" in
|
|
|
|
rk3588)
|
|
|
|
export CROSS_COMPILE=aarch64-linux-gnu-
|
|
|
|
make BL31=${PKG_BL31} ${PKG_LOADER} u-boot.dtb u-boot.itb
|
|
|
|
tools/mkimage -n ${PKG_SOC} -T rksd -d ${PKG_DATAFILE}:${PKG_LOADER} idbloader.img
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
tools/mkimage -n ${PKG_SOC} -T rksd -d "${PKG_DATAFILE}" -C bzip2 idbloader.img
|
|
|
|
cat "${PKG_LOADER}" >> idbloader.img
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2023-01-10 23:39:16 +00:00
|
|
|
echo "uboot: copy idbloader.img image to ${INSTALL}/usr/share/bootloader..."
|
2023-01-08 22:49:32 +00:00
|
|
|
cp -av idbloader.img ${INSTALL}/usr/share/bootloader
|
|
|
|
|
|
|
|
if [ ! -n "${PKG_LOAD_ADDR}" ]; then
|
|
|
|
PKG_LOAD_ADDR="0x00200000"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "${PKG_SOC}" in
|
|
|
|
rk3588)
|
|
|
|
echo "uboot: copy u-boot.itb image to ${INSTALL}/usr/share/bootloader..."
|
2023-01-10 23:39:16 +00:00
|
|
|
cp -av u-boot.itb ${INSTALL}/usr/share/bootloader/u-boot.itb
|
|
|
|
generate_spi_image
|
2023-01-08 22:49:32 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
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 "${PKG_SOC}" in
|
|
|
|
rk3399)
|
|
|
|
|
|
|
|
if [ -n "${PKG_BL31}" ]; then
|
|
|
|
echo "trust: create trust.ini..."
|
|
|
|
cat >trust.ini <<EOF
|
|
|
|
[BL30_OPTION]
|
|
|
|
SEC=0
|
|
|
|
BL31_OPTION]
|
|
|
|
SEC=1
|
|
|
|
PATH=${PKG_BL31}
|
|
|
|
ADDR=0x00010000
|
|
|
|
[BL32_OPTION]
|
|
|
|
SEC=0
|
|
|
|
[BL33_OPTION]
|
|
|
|
SEC=0
|
|
|
|
[OUTPUT]
|
|
|
|
PATH=trust.img
|
|
|
|
EOF
|
|
|
|
TROPTS="--verbose"
|
|
|
|
${PKG_UBOOT}/tools/trust_merger ${TROPTS} trust.ini
|
|
|
|
cp -av trust.img ${INSTALL}/usr/share/bootloader
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ "${BOOT_INI}" == true ]
|
|
|
|
then
|
|
|
|
echo "boot: create boot.ini..."
|
|
|
|
cat >${INSTALL}/usr/share/bootloader/boot.ini <<EOF
|
|
|
|
odroidgoa-uboot-config
|
|
|
|
|
|
|
|
setenv fdt_addr_r "0x01f00000"
|
|
|
|
setenv dtb_name "${DEVICE_DTB[0]}.dtb"
|
|
|
|
setenv loadaddr "${PKG_LOAD_ADDR}"
|
|
|
|
setenv scriptaddr "0x00500000"
|
|
|
|
setenv kernel_addr_r "0x02008000"
|
|
|
|
|
|
|
|
sysboot mmc ${BOOT_PART} any \${scriptaddr} /extlinux/extlinux.conf
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "boot: create extlinux.conf..."
|
|
|
|
mkdir -p "${INSTALL}/usr/share/bootloader/extlinux"
|
|
|
|
cat << EOF > "${INSTALL}/usr/share/bootloader/extlinux/extlinux.conf"
|
|
|
|
LABEL ${DISTRO}
|
|
|
|
LINUX /${KERNEL_NAME}
|
|
|
|
FDT /${DEVICE_DTB}.dtb
|
|
|
|
APPEND boot=UUID=@BOOT_UUID@ disk=UUID=@DISK_UUID@ ${EXTRA_CMDLINE}
|
|
|
|
EOF
|