mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
project: add common bootloader files
This commit is contained in:
parent
77b1d8f017
commit
709a60e423
7
projects/Amlogic/bootloader/box.ini
Normal file
7
projects/Amlogic/bootloader/box.ini
Normal file
@ -0,0 +1,7 @@
|
||||
WETEK-UBOOT-CONFIG
|
||||
|
||||
# This is a helper file for WeTek Hub and Play2 devices.
|
||||
# It is not used and safe to delete on every other device.
|
||||
|
||||
fatload mmc 0 1020000 s905_autoscript
|
||||
autoscr 1020000
|
19
projects/Amlogic/bootloader/canupdate.sh
Normal file
19
projects/Amlogic/bootloader/canupdate.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
# detect legacy kernel installs and abort to prevent upgrades
|
||||
if [ "$(uname -r)" = "3.14.29" ]; then
|
||||
echo "Update from 3.14 is not supported!"
|
||||
sleep 10
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# allow upgrades between aarch64 and arm images
|
||||
PROJECT=$("$1" | cut -d. -f1)
|
||||
if [ "$1" = "${PROJECT}.aarch64" -o "$1" = "${PROJECT}.arm" ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
3
projects/Amlogic/bootloader/config
Normal file
3
projects/Amlogic/bootloader/config
Normal file
@ -0,0 +1,3 @@
|
||||
CONFIG_LZ4=y
|
||||
CONFIG_LZO=y
|
||||
CONFIG_LZMA=y
|
123
projects/Amlogic/bootloader/install
Normal file
123
projects/Amlogic/bootloader/install
Normal file
@ -0,0 +1,123 @@
|
||||
# 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
|
30
projects/Amlogic/bootloader/mkimage
Normal file
30
projects/Amlogic/bootloader/mkimage
Normal file
@ -0,0 +1,30 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
. config/options $1
|
||||
|
||||
case "${UBOOT_SYSTEM}" in
|
||||
box|"")
|
||||
DTB="@@DTB_NAME@@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "image: writing u-boot to $(basename $DISK)"
|
||||
dd if="$INSTALL/usr/share/bootloader/u-boot.bin.sd.bin" of="$DISK" conv=fsync,notrunc bs=1 count=112 >"$SAVE_ERROR" 2>&1 || show_error
|
||||
dd if="$INSTALL/usr/share/bootloader/u-boot.bin.sd.bin" of="$DISK" conv=fsync,notrunc bs=512 skip=1 seek=1 >"$SAVE_ERROR" 2>&1 || show_error
|
||||
|
||||
DTB="$(${SCRIPTS}/uboot_helper ${PROJECT} ${DEVICE} ${UBOOT_SYSTEM} dtb)"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "image: creating uEnv.ini"
|
||||
cat << EOF > "${LE_TMP}/uEnv.ini"
|
||||
dtb_name=/dtb/${DTB}
|
||||
bootargs=boot=UUID=${UUID_SYSTEM} disk=UUID=${UUID_STORAGE} quiet ${EXTRA_CMDLINE}
|
||||
EOF
|
||||
mcopy -s "${LE_TMP}/uEnv.ini" ::
|
||||
|
||||
touch "$RELEASE_DIR/3rdparty/bootloader/aml_autoscript.zip"
|
||||
|
||||
echo "image: copying autoscript files and device trees"
|
||||
mcopy -s ${RELEASE_DIR}/3rdparty/bootloader/* ::
|
25
projects/Amlogic/bootloader/release
Normal file
25
projects/Amlogic/bootloader/release
Normal file
@ -0,0 +1,25 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
mkdir -p "$RELEASE_DIR/3rdparty/bootloader"
|
||||
cp -a $(get_build_dir u-boot-script)/* $RELEASE_DIR/3rdparty/bootloader
|
||||
|
||||
if find_file_path bootloader/${UBOOT_SYSTEM}.ini; then
|
||||
cp -av ${FOUND_PATH} $RELEASE_DIR/3rdparty/bootloader/boot.ini
|
||||
fi
|
||||
|
||||
mkdir -p "$RELEASE_DIR/3rdparty/bootloader/dtb"
|
||||
case ${DEVICE:-$PROJECT} in
|
||||
AMLGX)
|
||||
cp -a $(get_build_dir linux)/arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*gxbb*.dtb $RELEASE_DIR/3rdparty/bootloader/dtb
|
||||
cp -a $(get_build_dir linux)/arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*gxl*.dtb $RELEASE_DIR/3rdparty/bootloader/dtb
|
||||
cp -a $(get_build_dir linux)/arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*gxm*.dtb $RELEASE_DIR/3rdparty/bootloader/dtb
|
||||
;;
|
||||
AMLG12)
|
||||
cp -a $(get_build_dir linux)/arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*g12a*.dtb $RELEASE_DIR/3rdparty/bootloader/dtb
|
||||
cp -a $(get_build_dir linux)/arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*g12b*.dtb $RELEASE_DIR/3rdparty/bootloader/dtb
|
||||
;;
|
||||
*)
|
||||
cp -a $(get_build_dir linux)/arch/$TARGET_KERNEL_ARCH/boot/dts/amlogic/*.dtb $RELEASE_DIR/3rdparty/bootloader/dtb
|
||||
;;
|
||||
esac
|
40
projects/Amlogic/bootloader/update.sh
Normal file
40
projects/Amlogic/bootloader/update.sh
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
[ -z "$SYSTEM_ROOT" ] && SYSTEM_ROOT=""
|
||||
[ -z "$BOOT_ROOT" ] && BOOT_ROOT="/flash"
|
||||
[ -z "$BOOT_PART" ] && BOOT_PART=$(df "$BOOT_ROOT" | tail -1 | awk {' print $1 '})
|
||||
|
||||
# identify the boot device
|
||||
if [ -z "$BOOT_DISK" ]; then
|
||||
case $BOOT_PART in
|
||||
/dev/sd[a-z][0-9]*)
|
||||
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,[0-9]*,,g")
|
||||
;;
|
||||
/dev/mmcblk*)
|
||||
BOOT_DISK=$(echo $BOOT_PART | sed -e "s,p[0-9]*,,g")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# mount $BOOT_ROOT rw
|
||||
mount -o remount,rw $BOOT_ROOT
|
||||
|
||||
# update device trees
|
||||
for dtbfile in $BOOT_ROOT/dtb/*.dtb ; do
|
||||
dtb=$(basename $dtbfile)
|
||||
echo "Updating $dtb"
|
||||
cp -p $SYSTEM_ROOT/usr/share/bootloader/$dtb $BOOT_ROOT/dtb/ 2>/dev/null || true
|
||||
done
|
||||
|
||||
# update u-boot scripts
|
||||
for scriptfile in $SYSTEM_ROOT/usr/share/bootloader/*_autoscript* $SYSTEM_ROOT/usr/share/bootloader/*.scr ; do
|
||||
echo "Updating $(basename $scriptfile)"
|
||||
cp -p $scriptfile $BOOT_ROOT 2>/dev/null || true
|
||||
done
|
||||
|
||||
# mount $BOOT_ROOT ro
|
||||
sync
|
||||
mount -o remount,ro $BOOT_ROOT
|
@ -0,0 +1,11 @@
|
||||
defenv
|
||||
setenv bootcmd 'run start_autoscript; run storeboot'
|
||||
setenv start_autoscript 'mmcinfo && run start_mmc_autoscript; usb start && run start_usb_autoscript; run start_emmc_autoscript'
|
||||
setenv start_emmc_autoscript 'fatload mmc 1 1020000 emmc_autoscript && autoscr 1020000'
|
||||
setenv start_mmc_autoscript 'fatload mmc 0 1020000 s905_autoscript && autoscr 1020000'
|
||||
setenv start_usb_autoscript 'for usbdev in 0 1 2 3; do fatload usb ${usbdev} 1020000 s905_autoscript && autoscr 1020000; done'
|
||||
setenv system_part b
|
||||
setenv upgrade_step 2
|
||||
saveenv
|
||||
sleep 1
|
||||
reboot
|
@ -0,0 +1,4 @@
|
||||
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}uEnv.ini && env import -t ${kernel_addr_r} ${filesize}
|
||||
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}KERNEL
|
||||
load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${dtb_name}
|
||||
bootm ${kernel_addr_r} - ${fdt_addr_r}
|
@ -0,0 +1,7 @@
|
||||
setenv env_addr 0x10400000
|
||||
setenv boot_start 'bootm ${loadaddr} - ${dtb_mem_addr}'
|
||||
setenv addmac 'if printenv mac; then setenv bootargs ${bootargs} mac=${mac}; elif printenv eth_mac; then setenv bootargs ${bootargs} mac=${eth_mac}; fi'
|
||||
setenv try_boot_start 'if fatload ${devtype} ${devnum} ${loadaddr} KERNEL; then fatload ${devtype} ${devnum} ${env_addr} uEnv.ini && env import -t ${env_addr} ${filesize} && run addmac; fatload ${devtype} ${devnum} ${dtb_mem_addr} ${dtb_name} && run boot_start; fi'
|
||||
setenv devtype mmc
|
||||
setenv devnum 1
|
||||
run try_boot_start
|
@ -0,0 +1,9 @@
|
||||
setenv env_addr 0x10400000
|
||||
setenv boot_start 'bootm ${loadaddr} - ${dtb_mem_addr}'
|
||||
setenv addmac 'if printenv mac; then setenv bootargs ${bootargs} mac=${mac}; elif printenv eth_mac; then setenv bootargs ${bootargs} mac=${eth_mac}; fi'
|
||||
setenv try_boot_start 'if fatload ${devtype} ${devnum} ${loadaddr} KERNEL; then fatload ${devtype} ${devnum} ${env_addr} uEnv.ini && env import -t ${env_addr} ${filesize} && run addmac; fatload ${devtype} ${devnum} ${dtb_mem_addr} ${dtb_name} && run boot_start; fi'
|
||||
setenv devtype mmc
|
||||
setenv devnum 0
|
||||
run try_boot_start
|
||||
setenv devtype usb
|
||||
for devnum in 0 1 2 3 ; run try_boot_start ; done
|
Loading…
x
Reference in New Issue
Block a user