Compare commits

...
Author SHA1 Message Date
Ferass El Hafidi 47455a65d4 u-boot-amlogic: more hacks and typo fixes
Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2026-01-26 22:17:21 +00:00
Ferass El Hafidi 4f98bfd8a4 u-boot-amlogic: fix typo
Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2026-01-26 21:28:50 +00:00
Ferass El Hafidi caf20c87c3 u-boot-amlogic: more c2 workarounds
Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2026-01-26 18:36:43 +00:00
Ferass El Hafidi 8a6e0a08dd u-boot-amlogic: odroid-c2 bizzare BL2 packaging workaround
Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2026-01-23 23:09:49 +00:00
Ferass El Hafidi 91d79f2dd9 u-boot-amlogic: C2: switch to p201
Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2026-01-11 18:28:04 +00:00
Ferass El Hafidi 83a2eb914e u-boot-amlogic: fix header
Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2026-01-11 18:14:19 +00:00
Ferass El Hafidi 1cf877f2f6 WIP: odroid-c2: new device
Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2025-12-19 22:12:47 +00:00
Ferass El Hafidi 35492bc26d u-boot-amlogic: upgrade to v2025.07, 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.

Also add post-upgrade script to tell users how to upgrade their
bootloader.

Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2025-12-17 14:56:17 +00:00
5 changed files with 251 additions and 11 deletions

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: Ferass El Hafidi <funderscore@postmarketos.org>
pkgname=device-odroid-c2
pkgdesc="HardKernel ODROID-C2"
pkgver=1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
linux-postmarketos-amlogic
postmarketos-base
soc-amlogic-aarch64
u-boot-amlogic-odroid-c2
"
makedepends="devicepkg-dev"
source="
deviceinfo
modules-initfs
"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware"
build() {
devicepkg_build $startdir $pkgname
}
package() {
devicepkg_package $startdir $pkgname
}
nonfree_firmware() {
pkgdesc="vdec firmware"
depends="linux-firmware-meson"
mkdir "$subpkgdir"
}
sha512sums="
13bc3979ed4285fa8862dcbf42bffa5dfd3053c71a198bb77a13325f1192e45edd97e04e1e618194fec34b60949e25afb8edfda5c07bacf347fbd396c76f96ed deviceinfo
52948c2884a6f6384e12b7a598f70878526d0d3293c214425170145231144ec7de805c038641741a4a5d75b50e554f6a3fa3769784a674217ed032f9b6a233c8 modules-initfs
"
@@ -0,0 +1,32 @@
# Reference: <https://postmarketos.org/deviceinfo>
# Please use double quotes only. You can source this file in shell
# scripts.
deviceinfo_format_version="0"
deviceinfo_name="ODROID C2"
deviceinfo_manufacturer="ODROID"
deviceinfo_codename="odroid-c2"
deviceinfo_year="2016"
deviceinfo_dtb="amlogic/meson-gxbb-odroidc2"
deviceinfo_arch="aarch64"
deviceinfo_partition_type="msdos"
# Device related
deviceinfo_chassis="embedded"
deviceinfo_external_storage="true"
deviceinfo_drm="true"
deviceinfo_screen_width="800"
deviceinfo_screen_height="600"
# Bootloader related
deviceinfo_boot_filesystem="fat32"
deviceinfo_generate_extlinux_config="true"
# We need to workaround the bootROM being stupid with offset requirements,
# so we have two @AML bootloader headers in the image:
# - one at the beginning => eMMC header
# - one at offset 512 => SD header
# and there's just a little bit of space in-between for MBR to coexist too.
deviceinfo_sd_embed_firmware_step_size="512"
deviceinfo_sd_embed_firmware="u-boot/odroid-c2/u-boot.bin.sd-stripped.bin:1"
deviceinfo_boot_part_start="4096"
deviceinfo_kernel_cmdline="quiet loglevel=2"
@@ -0,0 +1,3 @@
meson_drm
meson_dw_hdmi
display_connector
+167 -11
View File
@@ -3,19 +3,23 @@
# Co-Maintainer: exkc <exxxxkc@getgoogleoff.me>
# Co-Maintainer: hexaheximal <hexaheximal@proton.me>
pkgname=u-boot-amlogic
pkgver=2024.04
pkgrel=0
pkgver=2025.07
pkgrel=1
pkgdesc="U-Boot bootloader for Amlogic AArch64-based devices"
url="https://u-boot.org/"
arch="aarch64"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
ISC LGPL-2.0-only LGPL-2.1-only X11 proprietary"
makedepends="$depends_dev
arm-trusted-firmware-tools
bc
bison
crust
dtc
flex
gxlimg
gnutls-dev
meson-tools
openssl-dev
py3-setuptools
python3-dev
@@ -42,18 +46,28 @@ replaces="
u-boot-odroid-n2plus
u-boot-radxa-zero
"
install="$pkgname.post-upgrade"
_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
_gxbb_boards="
odroid-c2:odroid-c2,odroid-c2
"
_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="
$_gxbb_boards
$_gxl_boards
$_g12a_boards
"
for board in $_boards; do
_board_codename=${board%%:*}
@@ -65,7 +79,7 @@ prepare() {
}
build() {
for board in $_boards; do
for board in $_gxbb_boards; do
local board_names=${board##*:} board_config board_codename="" board_fip_dir
board_config=${board_names%%,*}
board_codename=${board%%:*}
@@ -75,15 +89,155 @@ build() {
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
make ${board_config}_defconfig all
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 [ -f "$board_fip_dir/bl2.package" ]; then
# special handling for ODROID-C2
python "$board_fip_dir/../p200/acs_tool.py" "$board_fip_dir/../p200/bl2.bin" "$board_fip_dir/bl2_acs.bin" "$board_fip_dir/../p200/acs.bin" 0
"$board_fip_dir/../p200/blx_fix.sh" "$board_fip_dir/bl2_acs.bin" "$board_fip_dir/zero_tmp" "$board_fip_dir/bl2_zero.bin" "$board_fip_dir/../p200/bl21.bin" "$board_fip_dir/bl21_zero.bin" "$board_fip_dir/bl2_new.bin" bl2
bl2bin="$board_fip_dir/bl2_new.bin"
# embed bl301 in bl30
"./$board_fip_dir/../p200/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
bl30bin="$board_fip_dir/bl30.bin"
else
# 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_new.bin"
# embed bl301 in bl30
"./$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
bl30bin="$board_fip_dir/bl30_new.bin"
fi
# bl31.img is basically bl31.bin but with an extra image header.
if [ -f "$board_fip_dir/bl31.bin" ]; then
bl31bin="$board_fip_dir/bl31.bin"
else
bl31bin="$board_fip_dir/bl31.bin"
fi
# fip.bin
fiptool create --align 16384 --scp-fw "$bl30bin" --soc-fw "$bl31bin" --nt-fw "$builddir/u-boot.bin" "$board_fip_dir/fip.bin"
fipbin="$board_fip_dir/fip.bin"
cat "$bl2bin" "$fipbin" > "$board_fip_dir/u-boot_unsig.bin"
# and finally create the final image
amlbootsig "$board_fip_dir/u-boot_unsig.bin" "$board_fip_dir/u-boot.bin"
#./build-fip.sh $board_fip_dir $builddir/u-boot.bin ./build
#cd ./build
#dd if="$board_fip_dir/u-boot.bin" of="./build/u-boot-$board_codename.bin.sd-stripped.bin" conv=fsync,notrunc bs=512 skip=1 # broken
cp "$board_fip_dir/u-boot.bin" "./build/u-boot-$board_codename.bin.sd-stripped.bin"
cd $builddir
done
for board in $_gxl_boards; do
local board_names=${board##*:} board_config board_codename="" board_fip_dir
board_config=${board_names%%,*}
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 ${board_config}_defconfig all
msg "Building Amlogic firmware package for $board_codename (FIP: $board_fip_dir)"
cd $_fip_builddir
mkdir -p ./build
# 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 "$builddir/u-boot.bin" "$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.sh $board_fip_dir $builddir/u-boot.bin ./build
#cd ./build
dd if="$board_fip_dir/u-boot.bin" of="./build/u-boot-$board_codename.bin.sd-stripped.bin" conv=fsync,notrunc bs=512 skip=1
cd $builddir
done
for board in $_g12a_boards; do
local board_names=${board##*:} board_config board_codename="" board_fip_dir
board_config=${board_names%%,*}
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 ${board_config}_defconfig all
msg "Building Amlogic firmware package for $board_codename (FIP: $board_fip_dir)"
cd $_fip_builddir
mkdir -p ./build
# 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 -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 -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-fip.sh $board_fip_dir $builddir/u-boot.bin ./build
#cd ./build
dd if="$board_fip_dir/u-boot.bin" of="./build/u-boot-$board_codename.bin.sd-stripped.bin" conv=fsync,notrunc bs=512 skip=1
cd $builddir
done
}
@@ -100,6 +254,8 @@ _board_package() {
mkdir -p "$subpkgdir/usr/share/u-boot/$board_codename/"
install -D -m644 "$srcdir/amlogic-boot-fip-$_amlogicblob_commit/build/u-boot-$board_codename.bin.sd-stripped.bin" \
"$subpkgdir/usr/share/u-boot/$board_codename/u-boot.bin.sd-stripped.bin"
#install -D -m644 "$srcdir/amlogic-boot-fip-$_amlogicblob_commit/build/u-boot-$board_codename.bin.emmc-header.bin" \
# "$subpkgdir/usr/share/u-boot/$board_codename/u-boot.bin.emmc-header.bin"
}
for board in $_boards; do
@@ -109,7 +265,7 @@ for board in $_boards; do
done
sha512sums="
be9b0176337fe9321ac244a16a17dfc1fb976b019de36c78d52149fe7c9d89d2907321be4c0c2faf0d47a4982212501f29063dbd01a005ce2c54e072159e0e3e u-boot-v2024.04.tar.gz
83a29ba69009dca7b890561093dba20e0f38b74837f511e8951d9b8a9ad56f9537ca052635e1fa0940789872a4ba249284b6ace601b73dc654b700e1fa9770b3 u-boot-v2025.07.tar.gz
415e81dedca92da59bb12025e64a02b14c8cd43c1a7d80b58e808db8f61402ecf396bf6c072c1cc18546254a5c88c9573c255c37496078a71c825abea87211be 0001-add-x96-mini-support.patch
74c57daff859e7f449bd2743c7a8c0358b8dbe5d321ddb3a5b242b4d35683890d500d23e769490b1419a18bed233aea03ee11103bb4d646c502e4018283ba975 amlogic-fip.tar.gz
"
@@ -0,0 +1,8 @@
#!/bin/sh
echo "## An upgraded u-boot package was installed ##"
echo "## To upgrade the bootloader in use, check /usr/share/u-boot/. For further ##"
echo "## information on how to proceed, please check the Amlogic wiki page: ##"
echo "## https://wiki.postmarketos.org/wiki/Category:Amlogic#How_to_upgrade_U-Boot ##"
exit 0