Files
Arch-R/projects/Amlogic/bootloader/install
2019-06-05 22:58:44 +02:00

124 lines
4.5 KiB
Plaintext

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
echo "$BOOTLOADER: creating u-boot.bin"
DESTDIR="$PKG_BUILD/fip"
mkdir -p $DESTDIR
FIPDIR="$(get_build_dir amlogic-boot-fip)"
case "${UBOOT_SYSTEM}" in
box|"")
# No-op, use vendor booloader
;;
odroid-c2)
FIPDIR+="/fip"
FUSEDIR="$(get_build_dir amlogic-boot-fip)/sd_fuse"
$FIPDIR/fip_create --bl30 $FIPDIR/gxb/bl30.bin \
--bl301 $FIPDIR/gxb/bl301.bin \
--bl31 $FIPDIR/gxb/bl31.bin \
--bl33 $(get_build_dir $BOOTLOADER)/u-boot.bin $DESTDIR/fip.bin
$FIPDIR/fip_create --dump $DESTDIR/fip.bin
cat $FIPDIR/gxb/bl2.package $DESTDIR/fip.bin > $DESTDIR/boot_new.bin
$FIPDIR/gxb/aml_encrypt_gxb --bootsig --input $DESTDIR/boot_new.bin --output $DESTDIR/u-boot.img
dd if=$DESTDIR/u-boot.img of=$DESTDIR/u-boot.gxbb bs=512 skip=96
dd if=$FUSEDIR/bl1.bin.hardkernel of=$DESTDIR/u-boot.bin.sd.bin conv=fsync,notrunc bs=1 count=442
dd if=$FUSEDIR/bl1.bin.hardkernel of=$DESTDIR/u-boot.bin.sd.bin conv=fsync,notrunc bs=512 skip=1 seek=1
dd if=$DESTDIR/u-boot.gxbb of=$DESTDIR/u-boot.bin.sd.bin conv=fsync,notrunc bs=512 seek=97
;;
nanopi-k2)
cp $FIPDIR/gxb/bl2.bin $DESTDIR/
cp $FIPDIR/gxb/acs.bin $DESTDIR/
cp $FIPDIR/gxb/bl21.bin $DESTDIR/
cp $FIPDIR/gxb/bl30.bin $DESTDIR/
cp $FIPDIR/gxb/bl301.bin $DESTDIR/
cp $FIPDIR/gxb/bl31.img $DESTDIR/
cp $(get_build_dir $BOOTLOADER)/u-boot.bin $DESTDIR/bl33.bin
$FIPDIR/blx_fix.sh $DESTDIR/bl30.bin \
$DESTDIR/zero_tmp \
$DESTDIR/bl30_zero.bin \
$DESTDIR/bl301.bin \
$DESTDIR/bl301_zero.bin \
$DESTDIR/bl30_new.bin bl30
$FIPDIR/fip_create --bl30 $DESTDIR/bl30_new.bin \
--bl31 $DESTDIR/bl31.img \
--bl33 $DESTDIR/bl33.bin \
$DESTDIR/fip.bin
$FIPDIR/fip_create --dump $DESTDIR/fip.bin
python2 $FIPDIR/acs_tool.pyc $DESTDIR/bl2.bin \
$DESTDIR/bl2_acs.bin \
$DESTDIR/acs.bin 0
$FIPDIR/blx_fix.sh $DESTDIR/bl2_acs.bin \
$DESTDIR/zero_tmp \
$DESTDIR/bl2_zero.bin \
$DESTDIR/bl21.bin \
$DESTDIR/bl21_zero.bin \
$DESTDIR/bl2_new.bin bl2
cat $DESTDIR/bl2_new.bin $DESTDIR/fip.bin > $DESTDIR/boot_new.bin
$FIPDIR/gxb/aml_encrypt_gxb --bootsig --input $DESTDIR/boot_new.bin --output $DESTDIR/u-boot.bin.sd.bin
;;
*)
cp $FIPDIR/gxl/bl2.bin $DESTDIR/
cp $FIPDIR/gxl/acs.bin $DESTDIR/
cp $FIPDIR/gxl/bl21.bin $DESTDIR/
cp $FIPDIR/gxl/bl30.bin $DESTDIR/
cp $FIPDIR/gxl/bl301.bin $DESTDIR/
cp $FIPDIR/gxl/bl31.img $DESTDIR/
cp $(get_build_dir $BOOTLOADER)/u-boot.bin $DESTDIR/bl33.bin
$FIPDIR/blx_fix.sh $DESTDIR/bl30.bin \
$DESTDIR/zero_tmp \
$DESTDIR/bl30_zero.bin \
$DESTDIR/bl301.bin \
$DESTDIR/bl301_zero.bin \
$DESTDIR/bl30_new.bin bl30
python2 $FIPDIR/acs_tool.pyc $DESTDIR/bl2.bin $DESTDIR/bl2_acs.bin $DESTDIR/acs.bin 0
$FIPDIR/blx_fix.sh $DESTDIR/bl2_acs.bin \
$DESTDIR/zero_tmp \
$DESTDIR/bl2_zero.bin \
$DESTDIR/bl21.bin \
$DESTDIR/bl21_zero.bin \
$DESTDIR/bl2_new.bin bl2
$FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input $DESTDIR/bl30_new.bin
$FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input $DESTDIR/bl31.img
$FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input $DESTDIR/bl33.bin
$FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input $DESTDIR/bl2_new.bin --output $DESTDIR/bl2.n.bin.sig
$FIPDIR/gxl/aml_encrypt_gxl --bootmk --output $DESTDIR/u-boot.bin.sd.bin --bl2 $DESTDIR/bl2.n.bin.sig --bl30 $DESTDIR/bl30_new.bin.enc --bl31 $DESTDIR/bl31.img.enc --bl33 $DESTDIR/bl33.bin.enc
;;
esac
# Clean up after previous build
rm -rf $INSTALL/usr/share/bootloader/boot.ini
rm -rf $INSTALL/usr/share/bootloader/u-boot.bin.sd.bin
mkdir -p $INSTALL/usr/share/bootloader
if [ -f $DESTDIR/u-boot.bin.sd.bin ] ; then
cp -av $DESTDIR/u-boot.bin.sd.bin $INSTALL/usr/share/bootloader
fi
# Install boot.ini if it exists
if find_file_path bootloader/${UBOOT_SYSTEM}.ini; then
cp -av ${FOUND_PATH} $INSTALL/usr/share/bootloader/boot.ini
fi