From f4fdf38d13817bf5e50c0ca38da2162318e6479b Mon Sep 17 00:00:00 2001 From: Eisenbahnfan Date: Tue, 14 Apr 2026 13:42:10 +0200 Subject: [PATCH] u-boot-exynos5420: Introduce u-boot package for device-samsung-{n1awifi,n2awifi,v1awifi} Part-of: --- device/testing/u-boot-exynos5420/APKBUILD | 65 +++++++++ .../testing/u-boot-exynos5420/update-u-boot | 138 ++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 device/testing/u-boot-exynos5420/APKBUILD create mode 100644 device/testing/u-boot-exynos5420/update-u-boot diff --git a/device/testing/u-boot-exynos5420/APKBUILD b/device/testing/u-boot-exynos5420/APKBUILD new file mode 100644 index 000000000..a892f7488 --- /dev/null +++ b/device/testing/u-boot-exynos5420/APKBUILD @@ -0,0 +1,65 @@ +maintainer="Hendrik Noack " +pkgname=u-boot-exynos5420 +pkgver=2026.04 +pkgrel=0 +pkgdesc="U-Boot bootloader for Samsung Exynos5420" +url="https://gitlab.com/exynos5-mainline/u-boot" +arch="armv7" +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" +depends="android-tools" +makedepends=" + $depends_dev + bash + bc + bison + dtc + flex + openssl-dev + py3-setuptools + python3-dev + swig + gnutls-dev + " +options="!check" +_tag="v${pkgver//_/-}-galaxy-tab-pro" +source=" + $pkgname-$_tag.tar.bz2::$url/-/archive/$_tag/u-boot-$_tag.tar.bz2 + update-u-boot + " +builddir="$srcdir/u-boot-$_tag" + +_devices=" + n1awifi + n2awifi + v1a-wifi + " + +build() { + 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 + + export BUILD_DIR="$builddir"/build + + mkdir -p $BUILD_DIR + for _device in $_devices; do + make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm distclean + make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm ${_device//-/_}_defconfig + make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm all + mv "$BUILD_DIR/u-boot.bin" "$builddir/u-boot-$_device.bin" + done +} + +package() { + for _device in $_devices; do + install -D -m644 "$builddir/u-boot-$_device.bin" \ + -t "$pkgdir/usr/share/u-boot/samsung/" + done + + install -D -m 755 "$srcdir"/update-u-boot "$pkgdir"/usr/sbin/update-u-boot +} + +sha512sums=" +88a6b5555427ea66a33643c8e9d35da73392c01ad5607187c458d491124f8d3bc4fbd1c64d6c40262b23f436d91599eee6dfad130e160d345c53b63304466c57 u-boot-exynos5420-v2026.04-galaxy-tab-pro.tar.bz2 +085effc688328f96f116e1199d55d4da4f34f08fa1045b4bcc7debc8ba7df28c589d54bc3cac7cd7ed9cb9d6c0f3655b5d101c5c3d8c9d5ff5b9ef2c3cb2514d update-u-boot +" diff --git a/device/testing/u-boot-exynos5420/update-u-boot b/device/testing/u-boot-exynos5420/update-u-boot new file mode 100644 index 000000000..d0bdcb64b --- /dev/null +++ b/device/testing/u-boot-exynos5420/update-u-boot @@ -0,0 +1,138 @@ +#!/bin/sh + +board= +partition=/dev/disk/by-partlabel/BOOT +verbose= +dryrun= +imagedir=/usr/share/u-boot/ +skip_delay= + +get_board() { + if [ -z "$board" ] && [ -e /sys/firmware/devicetree/base/compatible ]; then + case "$(cat /sys/firmware/devicetree/base/compatible 2>/dev/null)" in + samsung,n1awifi*) board="n1awifi";; + samsung,n2awifi*) board="n2awifi";; + samsung,v1a-wifi*) board="v1a-wifi";; + esac + fi +} + +die() { + echo "ERROR: $@" + exit 1 +} + +usage() { + get_board + + cat <] [-b|--board ] [-p|--partition ] [-s|--skip-delay] + +options: + + -b,--board Specify the board type: n1awifi, n2awifi, v1awifi + (current default: ${board:-none}) + + -p, --partition Specify partition to flash u-boot to + (current default: ${partition:-none}) + + -i,--imagedir Specify u-boot image directory + (current default: ${imagedir:-none}) + + -n,--dry-run Print commands but don't execute them + + -s,--skip-delay Skip delay and flash the image immediately + +EOF +} + +validate_checksum() { + file="$1" + file_sha512="$file.sha512" + file_size=$(stat -c%s $file) + partition="$2" + bs="$3" + + checksum0=$(cat $file_sha512 | awk {'print $1'}) + checksum1=$(dd if=$partition bs=1 count=$file_size status=none | sha512sum | awk {'print $1'}) + if [ "$checksum0" != "$checksum1" ]; then + echo "File: $checksum0" + echo "Part: $checksum1" + die "Checksum failed" + fi + echo "Successful U-Boot image checksum verification on $partition :" + echo -e "\t$checksum1" +} + +while [ $# -gt 0 ]; do + opt="$1" + shift + case "$opt" in + -b|--board) + case "$1" in + n1awifi) board="n1awifi" ;; + n2awifi) board="n2awifi" ;; + v1awifi) board="v1a-wifi" ;; + *) usage; exit 1;; + esac + shift + ;; + -p|--partition) + partition="$1" + shift + ;; + -i|--imagedir) + imagedir="$1" + shift + ;; + -n|--dry-run) + dryrun="echo" + ;; + -s|--skip-delay) + skip_delay="yes" + ;; + --) + break + ;; + -*) + usage + exit 1 + ;; + esac +done + +get_board + +echo "/!\ WARNING:" +echo "This upgrade may not work reliably, postmarketOS might not boot anymore!" +echo +read -p "Continue? (y/n) [n]: " -n 1 -r +echo +case "$REPLY" in + y|Y) ;; + *) exit 1 ;; +esac + +if [ -z "$dryrun" ]; then + if [ -z "$skip_delay" ]; then + echo "Updating $board u-boot in $device in 3 seconds..." + sleep 3 + else + echo "Updating $board u-boot in $device" + fi +fi + +( +set -e +[ -e "$imagedir/samsung/u-boot-$board.bin" ] || die "$board images not installed, apk add u-boot-exynos5420" +$dryrun echo "Generating android boot image..." +$dryrun mkbootimg --kernel "$imagedir"/samsung/u-boot-$board.bin --base "0x10000000" --kernel_offset "0x00008000" --ramdisk_offset "0x01000000" --tags_offset "0x00000100" --second_offset "0x00f00000" --pagesize "2048" -o /tmp/aboot.img +[ -z "$dryrun" ] && printf "SEANDROIDENFORCE" >> /tmp/aboot.img +[ -z "$dryrun" ] && sha512sum /tmp/aboot.img > /tmp/aboot.img.sha512 +$dryrun dd if=/tmp/aboot.img of=$partition bs=512 oflag=direct status=none +[ -z "$dryrun" ] && validate_checksum /tmp/aboot.img $partition 512 +$dryrun rm -f /tmp/aboot.img /tmp/aboot.img.sha512 +$dryrun sync +) || die "U-Boot installation in $partition failed" + +[ -z "$dryrun" ] && echo "Completed successfully."