u-boot-amlogic: upgrade to v2026.04, switch to gxlimg

The reasoning behind switching to gxlimg for image creation is that the
official Amlogic tools are not only proprietary (which makes them
undesirable in the first place), but they are also x86_64-only, which
increases maintenance burden as hacks have to be implemented for them to
work on non-x86_64 systems. They are also not officially supported, are
buggy, and tend to depend on glibc.

gxlimg has been packaged in Alpine Linux for a very long while, and the
intention behind packaging in Alpine has always been that it will be
used for the u-boot package going forward.

The main disadvantage of gxlimg is that it does not yet support
compressing the u-boot binary in the FIP, but we don't use that feature
in the proprietary tools anyway.

Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6900>
This commit is contained in:
Ferass El Hafidi 2025-08-08 13:56:18 +00:00 committed by The Friendly Meow (merge) Bot
parent 28d9252720
commit 5bbe347a01
No known key found for this signature in database

View file

@ -3,7 +3,7 @@
# Co-Maintainer: hexaheximal <hexaheximal@proton.me>
maintainer="Ferass El Hafidi <funderscore@postmarketos.org>"
pkgname=u-boot-amlogic
pkgver=2024.04
pkgver=2026.04
pkgrel=0
pkgdesc="U-Boot bootloader for Amlogic AArch64-based devices"
url="https://u-boot.org/"
@ -16,6 +16,8 @@ makedepends="$depends_dev
crust
dtc
flex
gxlimg
gnutls-dev
openssl-dev
py3-setuptools
python3-dev
@ -45,15 +47,20 @@ replaces="
_fip_builddir="$srcdir/amlogic-boot-fip-$_amlogicblob_commit"
# Format: <board>:<board u-boot defconfig>,<amlogic-boot-fip board files>
_boards="
amediatech-x96-mini:x96_mini,jethub-j80
bananapi-bpi-cm4-cm4io:bananapi-cm4-cm4io,bananapi-cm4io
_gxl_boards="
beelink-gt1:beelink-gt1-ultimate,beelink-gt1
librecomputer-lepotato:libretech-cc,lepotato
"
_g12a_boards="
bananapi-bpi-cm4-cm4io:bananapi-cm4-cm4io,bananapi-cm4io
odroid-c4:odroid-c4,odroid-c4
odroid-n2plus:odroid-n2,odroid-n2-plus
radxa-zero:radxa-zero,radxa-zero
"
_boards="
$_gxl_boards
$_g12a_boards
"
for board in $_boards; do
_board_codename=${board%%:*}
@ -64,6 +71,97 @@ prepare() {
default_prepare
}
#
# Generic u-boot building
#
_build_u_boot() {
board_config="$1"
touch include/config.h
LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h
make ${board_config}_defconfig all
}
#
# SoC-specific FIP building
#
_build_fip_gxl() {
board_fip_dir="$1"
u_boot="$2"
# create amlogic fip
python "$board_fip_dir/acs_tool.py" "$board_fip_dir/bl2.bin" "$board_fip_dir/bl2_acs.bin" "$board_fip_dir/acs.bin" 0
"$board_fip_dir/blx_fix.sh" "$board_fip_dir/bl2_acs.bin" "$board_fip_dir/zero_tmp" \
"$board_fip_dir/bl2_zero.bin" "$board_fip_dir/bl21.bin" \
"$board_fip_dir/bl21_zero.bin" "$board_fip_dir/bl2_new.bin" bl2
gxlimg -t bl2 -s "$board_fip_dir/bl2_new.bin" "$board_fip_dir/bl2.bin.sig"
bl2bin="$board_fip_dir/bl2.bin.sig"
# encrypt BL30 and BL31
"./$board_fip_dir/blx_fix.sh" "$board_fip_dir/bl30.bin" "$board_fip_dir/zero_tmp" \
"$board_fip_dir/bl30_zero.bin" "$board_fip_dir/bl301.bin" \
"$board_fip_dir/bl301_zero.bin" "$board_fip_dir/bl30_new.bin" bl30
gxlimg -t bl3x -c "$board_fip_dir/bl30_new.bin" "$board_fip_dir/bl30.bin.enc"
gxlimg -t bl3x -c "$board_fip_dir/bl31.img" "$board_fip_dir/bl31.img.enc"
bl30bin="$board_fip_dir/bl30.bin.enc"
bl31bin="$board_fip_dir/bl31.img.enc"
# encrypt u-boot
gxlimg -t bl3x -c "$u_boot" "$board_fip_dir/u-boot.enc"
# and finally create the final image
gxlimg -t fip \
--bl2 "$bl2bin" \
--bl30 "$bl30bin" \
--bl31 "$bl31bin" \
--bl33 "$board_fip_dir/u-boot.enc" \
"$board_fip_dir/u-boot.bin"
}
_build_fip_g12a() {
board_fip_dir="$1"
u_boot="$2"
# create amlogic fip
"./$board_fip_dir/blx_fix.sh" "$board_fip_dir/bl2.bin" "$board_fip_dir/zero_tmp" \
"$board_fip_dir/bl2_zero.bin" "$board_fip_dir/acs.bin" \
"$board_fip_dir/bl21_zero.bin" "$board_fip_dir/bl2_new.bin" bl2
gxlimg -t bl2 -s "$board_fip_dir/bl2_new.bin" "$board_fip_dir/bl2.bin.sig"
bl2bin="$board_fip_dir/bl2.bin.sig"
# encrypt BL30 and BL31
"./$board_fip_dir/blx_fix.sh" "$board_fip_dir/bl30.bin" "$board_fip_dir/zero_tmp" \
"$board_fip_dir/bl30_zero.bin" "$board_fip_dir/bl301.bin" \
"$board_fip_dir/bl301_zero.bin" "$board_fip_dir/bl30_new.bin" bl30
gxlimg -t bl30 -s "$board_fip_dir/bl30_new.bin" "$board_fip_dir/bl30.bin.enc"
gxlimg -t bl3x -s "$board_fip_dir/bl31.img" "$board_fip_dir/bl31.img.enc"
bl30bin="$board_fip_dir/bl30.bin.enc"
bl31bin="$board_fip_dir/bl31.img.enc"
# encrypt u-boot
gxlimg -t bl3x -s "$builddir/u-boot.bin" "$board_fip_dir/u-boot.enc"
ddrfw="
--ddrfw $board_fip_dir/ddr4_1d.fw --ddrfw $board_fip_dir/ddr4_2d.fw --ddrfw $board_fip_dir/ddr3_1d.fw
--ddrfw $board_fip_dir/piei.fw --ddrfw $board_fip_dir/lpddr4_1d.fw --ddrfw $board_fip_dir/lpddr4_2d.fw
--ddrfw $board_fip_dir/diag_lpddr4.fw --ddrfw $board_fip_dir/aml_ddr.fw
"
if [ -e "$board_fip_dir"/lpddr3_1d.fw ]; then
ddrfw="$ddrfw --ddrfw $board_fip_dir/lpddr3_1d.fw"
fi
# and finally create the final image
gxlimg -t fip --rev v3 \
--bl2 "$bl2bin" \
--bl30 "$bl30bin" \
--bl31 "$bl31bin" \
--bl33 "$board_fip_dir/u-boot.enc" \
$ddrfw \
"$board_fip_dir/u-boot.bin"
}
build() {
for board in $_boards; do
local board_names=${board##*:} board_config board_codename="" board_fip_dir
@ -71,19 +169,21 @@ build() {
board_codename=${board%%:*}
board_fip_dir=${board##*,}
msg "Building U-Boot for $board_codename (config: $board_config, FIP: $board_fip_dir)"
touch include/config.h
LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h
make -j8 ${board_config}_defconfig all
msg "Building U-Boot for $board_codename (config: $board_config)"
_build_u_boot $board_config
msg "Building Amlogic firmware package for $board_codename (FIP: $board_fip_dir)"
cd $_fip_builddir
mkdir -p ./build
./build-fip.sh $board_fip_dir $builddir/u-boot.bin ./build
cd ./build
dd if=u-boot.bin.sd.bin of=u-boot-$board_codename.bin.sd-stripped.bin conv=fsync,notrunc bs=512 skip=1
if echo $_gxl_boards | grep -q $board; then
msg "Building Amlogic GXL firmware package for $board_codename (FIP: $board_fip_dir)"
_build_fip_gxl "$board_fip_dir" "$builddir/u-boot.bin"
elif echo $_g12a_boards | grep -q $board; then
msg "Building Amlogic G12A firmware package for $board_codename (FIP: $board_fip_dir)"
_build_fip_g12a "$board_fip_dir" "$builddir/u-boot.bin"
fi
dd if="$board_fip_dir/u-boot.bin" of="./build/u-boot-$board_codename.bin.sd-stripped.bin" conv=fsync,notrunc bs=512
cd $builddir
done
}
@ -109,7 +209,7 @@ for board in $_boards; do
done
sha512sums="
be9b0176337fe9321ac244a16a17dfc1fb976b019de36c78d52149fe7c9d89d2907321be4c0c2faf0d47a4982212501f29063dbd01a005ce2c54e072159e0e3e u-boot-v2024.04.tar.gz
3e88bde53d54edc08b0ef108c5f87760fd57fd9932ce9d4a99f75bc1aa085f6d877801251f085adbf211351ca0a5d99dcc810bb8b4510fdc06159b9bf6ee850c u-boot-v2026.04.tar.gz
415e81dedca92da59bb12025e64a02b14c8cd43c1a7d80b58e808db8f61402ecf396bf6c072c1cc18546254a5c88c9573c255c37496078a71c825abea87211be 0001-add-x96-mini-support.patch
74c57daff859e7f449bd2743c7a8c0358b8dbe5d321ddb3a5b242b4d35683890d500d23e769490b1419a18bed233aea03ee11103bb4d646c502e4018283ba975 amlogic-fip.tar.gz
"