temp/u-boot-librem5: enable efidebug, enable auto update (MR 2842)
This enables an auto-update mechanism on post-upgrade for the u-boot firmware on the librem 5 and librem 5 devkit. This mechanism is largely copied from the implementation in the pinephone u-boot package. efidebug is useful for booting the kernel via EFI mode in u-boot.
This commit is contained in:
parent
33c2fa2370
commit
ec9a4e863a
5 changed files with 97 additions and 23 deletions
37
temp/u-boot-librem5/0001-Enable-efidebug-command.patch
Normal file
37
temp/u-boot-librem5/0001-Enable-efidebug-command.patch
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
From 6984c79c9a7a5952ffe324a0a378281d80d1b738 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Clayton Craft <clayton@craftyguy.net>
|
||||||
|
Date: Wed, 12 Jan 2022 22:41:59 -0800
|
||||||
|
Subject: [PATCH] Enable efidebug command
|
||||||
|
|
||||||
|
---
|
||||||
|
configs/librem5_defconfig | 1 +
|
||||||
|
configs/librem5_devkit_defconfig | 1 +
|
||||||
|
2 files changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/configs/librem5_defconfig b/configs/librem5_defconfig
|
||||||
|
index 3ec5ddc155..45f1b3b545 100644
|
||||||
|
--- a/configs/librem5_defconfig
|
||||||
|
+++ b/configs/librem5_defconfig
|
||||||
|
@@ -21,6 +21,7 @@ CONFIG_CMD_GPIO=y
|
||||||
|
CONFIG_CMD_I2C=y
|
||||||
|
CONFIG_CMD_SF=y
|
||||||
|
CONFIG_CMD_CACHE=y
|
||||||
|
+CONFIG_CMD_EFIDEBUG=y
|
||||||
|
CONFIG_CMD_REGULATOR=y
|
||||||
|
CONFIG_CMD_EXT4_WRITE=y
|
||||||
|
CONFIG_OF_CONTROL=y
|
||||||
|
diff --git a/configs/librem5_devkit_defconfig b/configs/librem5_devkit_defconfig
|
||||||
|
index ec9e74feb8..2f76984860 100644
|
||||||
|
--- a/configs/librem5_devkit_defconfig
|
||||||
|
+++ b/configs/librem5_devkit_defconfig
|
||||||
|
@@ -21,6 +21,7 @@ CONFIG_CMD_GPIO=y
|
||||||
|
CONFIG_CMD_I2C=y
|
||||||
|
CONFIG_CMD_SF=y
|
||||||
|
CONFIG_CMD_CACHE=y
|
||||||
|
+CONFIG_CMD_EFIDEBUG=y
|
||||||
|
CONFIG_CMD_REGULATOR=y
|
||||||
|
CONFIG_CMD_EXT4_WRITE=y
|
||||||
|
CONFIG_OF_CONTROL=y
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Forked from Alpine, so we can build it with Librem 5 phone support
|
# Forked from Alpine, so we can build it with Librem 5 phone support
|
||||||
pkgname=u-boot-librem5
|
pkgname=u-boot-librem5
|
||||||
pkgver=0.11
|
pkgver=0.12
|
||||||
pkgrel=0
|
pkgrel=0
|
||||||
# 'librem5' branch in atf repo
|
# 'librem5' branch in atf repo
|
||||||
_atfversion="92c2de12d36b31938ce940d5cac3c30a98665237"
|
_atfversion="92c2de12d36b31938ce940d5cac3c30a98665237"
|
||||||
|
@ -20,8 +20,9 @@ source="
|
||||||
arm-trusted-firmware-${_atfversion}.tar.gz::https://source.puri.sm/Librem5/arm-trusted-firmware/-/archive/${_atfversion}/arm-trusted-firmware-${_atfversion}.tar.gz
|
arm-trusted-firmware-${_atfversion}.tar.gz::https://source.puri.sm/Librem5/arm-trusted-firmware/-/archive/${_atfversion}/arm-trusted-firmware-${_atfversion}.tar.gz
|
||||||
https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-${_firmwareversion}.bin
|
https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-${_firmwareversion}.bin
|
||||||
update-u-boot
|
update-u-boot
|
||||||
|
0001-Enable-efidebug-command.patch
|
||||||
"
|
"
|
||||||
install="$pkgname.post-upgrade"
|
install="$pkgname.post-upgrade $pkgname-devkit.post-upgrade"
|
||||||
subpackages="$pkgname-devkit"
|
subpackages="$pkgname-devkit"
|
||||||
|
|
||||||
_ubootbuilddir="$srcdir"/uboot-imx-${_ubootversion}
|
_ubootbuilddir="$srcdir"/uboot-imx-${_ubootversion}
|
||||||
|
@ -74,17 +75,20 @@ build() {
|
||||||
dd if=/dev/zero of=devkit-boot.img bs=1024 count=1055
|
dd if=/dev/zero of=devkit-boot.img bs=1024 count=1055
|
||||||
dd if="$_m4builddir"/m4.bin conv=notrunc of="$_ubootbuilddir"/devkit-boot.img bs=1024
|
dd if="$_m4builddir"/m4.bin conv=notrunc of="$_ubootbuilddir"/devkit-boot.img bs=1024
|
||||||
dd if="$_ubootbuilddir"/devkit-flash.bin conv=notrunc of="$_ubootbuilddir"/devkit-boot.img bs=1024 seek=31
|
dd if="$_ubootbuilddir"/devkit-flash.bin conv=notrunc of="$_ubootbuilddir"/devkit-boot.img bs=1024 seek=31
|
||||||
|
sha512sum -b "$_ubootbuilddir"/devkit-boot.img > "$_ubootbuilddir"/devkit-boot.img.sha512
|
||||||
|
|
||||||
# phone
|
# phone
|
||||||
dd if=/dev/zero of=phone-boot.img bs=1024 count=1055
|
dd if=/dev/zero of=phone-boot.img bs=1024 count=1055
|
||||||
dd if="$_m4builddir"/m4.bin conv=notrunc of="$_ubootbuilddir"/phone-boot.img bs=1024
|
dd if="$_m4builddir"/m4.bin conv=notrunc of="$_ubootbuilddir"/phone-boot.img bs=1024
|
||||||
dd if="$_ubootbuilddir"/phone-flash.bin conv=notrunc of="$_ubootbuilddir"/phone-boot.img bs=1024 seek=31
|
dd if="$_ubootbuilddir"/phone-flash.bin conv=notrunc of="$_ubootbuilddir"/phone-boot.img bs=1024 seek=31
|
||||||
msg "done!"
|
sha512sum -b "$_ubootbuilddir"/phone-boot.img > "$_ubootbuilddir"/phone-boot.img.sha512
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
install -D -m644 "$_ubootbuilddir"/phone-boot.img \
|
install -D -m644 "$_ubootbuilddir"/phone-boot.img \
|
||||||
"$pkgdir/usr/share/u-boot/librem5/phone-boot.img"
|
"$pkgdir/usr/share/u-boot/librem5/phone-boot.img"
|
||||||
|
install -D -m644 "$_ubootbuilddir"/phone-boot.img.sha512 \
|
||||||
|
"$pkgdir/usr/share/u-boot/librem5/phone-boot.img.sha512"
|
||||||
install -D -m 755 "$srcdir"/update-u-boot \
|
install -D -m 755 "$srcdir"/update-u-boot \
|
||||||
"$pkgdir"/usr/sbin/update-u-boot
|
"$pkgdir"/usr/sbin/update-u-boot
|
||||||
}
|
}
|
||||||
|
@ -93,6 +97,8 @@ devkit() {
|
||||||
pkgdesc="u-boot bootloader for the Purism Librem5 devkit"
|
pkgdesc="u-boot bootloader for the Purism Librem5 devkit"
|
||||||
install -D -m644 "$_ubootbuilddir"/devkit-boot.img \
|
install -D -m644 "$_ubootbuilddir"/devkit-boot.img \
|
||||||
"$subpkgdir/usr/share/u-boot/librem5/devkit-boot.img"
|
"$subpkgdir/usr/share/u-boot/librem5/devkit-boot.img"
|
||||||
|
install -D -m644 "$_ubootbuilddir"/devkit-boot.img.sha512 \
|
||||||
|
"$subpkgdir/usr/share/u-boot/librem5/devkit-boot.img.sha512"
|
||||||
install -D -m 755 "$srcdir"/update-u-boot \
|
install -D -m 755 "$srcdir"/update-u-boot \
|
||||||
"$subpkgdir"/usr/sbin/update-u-boot
|
"$subpkgdir"/usr/sbin/update-u-boot
|
||||||
}
|
}
|
||||||
|
@ -103,5 +109,6 @@ ee540631b4bc0a33dfb29d9ba6e1dcd6a5cb1d43a4bc1ab2c7a29637d9c141d1c6559c933a48b8ce
|
||||||
035a4358ddf586c829da7fa2fb0d9d1df913c0c454f2d0e57ff0c6794552e49950fb6373f9aaf72e0e4c78ab411496aabbc60bf66cd76e35053f7a2d77911735 m4-a017421c340a69f2392086da93841244f78a03c5.tar.gz
|
035a4358ddf586c829da7fa2fb0d9d1df913c0c454f2d0e57ff0c6794552e49950fb6373f9aaf72e0e4c78ab411496aabbc60bf66cd76e35053f7a2d77911735 m4-a017421c340a69f2392086da93841244f78a03c5.tar.gz
|
||||||
cd8c9411ae0e57d2c8c700bf3e8c8d03e7dab955ace249a00911dd8c42b42929e0de3a5885eb9b1d945174abc8cfb177595d83c235e757c70640f451b62547ba arm-trusted-firmware-92c2de12d36b31938ce940d5cac3c30a98665237.tar.gz
|
cd8c9411ae0e57d2c8c700bf3e8c8d03e7dab955ace249a00911dd8c42b42929e0de3a5885eb9b1d945174abc8cfb177595d83c235e757c70640f451b62547ba arm-trusted-firmware-92c2de12d36b31938ce940d5cac3c30a98665237.tar.gz
|
||||||
1f968558bf158401ee5afe1c67e67bdd8ca2cb5d07029e78c745e751c665b68fa74128fca8b7161501a6445bbb18e8d463b42d787a61132db5c8778703462668 firmware-imx-8.12.bin
|
1f968558bf158401ee5afe1c67e67bdd8ca2cb5d07029e78c745e751c665b68fa74128fca8b7161501a6445bbb18e8d463b42d787a61132db5c8778703462668 firmware-imx-8.12.bin
|
||||||
63b6339d2a06b58f47d0f0b6f9a2c0fe25aa8edd523599b630ee3ea683f24ce31150a012e6ec5313b9c247529d0b8813d0c87cb6d0d2e91321c1cf7864cca475 update-u-boot
|
8eb2793814e53752ba8635694094ea43234ed6411ff4fd3e39c970fd4c4fa1b515b292a6d34b6e9a4ffbb573b1cf18a043f6be4e5cf95fa0ff4b9df9afe05c63 update-u-boot
|
||||||
|
24883f7293ebe7995aca8caae872a9c192b56651bfce9f408e5c9d001eda4df59fe755c006e737ff3ca42041577f711e4e600bd71629c2abad4b4a593062906c 0001-Enable-efidebug-command.patch
|
||||||
"
|
"
|
||||||
|
|
1
temp/u-boot-librem5/u-boot-librem5-devkit.post-upgrade
Symbolic link
1
temp/u-boot-librem5/u-boot-librem5-devkit.post-upgrade
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
u-boot-librem5.post-upgrade
|
|
@ -1,9 +1,3 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cat 1>&2 <<EOF
|
update-u-boot -s
|
||||||
*
|
|
||||||
* A new version of u-boot was installed.
|
|
||||||
* For instructions on installing this update to your device, see:
|
|
||||||
* https://wiki.postmarketos.org/wiki/Purism_Librem5_(purism-librem5)#U-boot_Updates
|
|
||||||
*
|
|
||||||
EOF
|
|
||||||
|
|
|
@ -14,12 +14,13 @@ get_defaults() {
|
||||||
if [ -z "$board" ] && [ -e /sys/firmware/devicetree/base/compatible ]; then
|
if [ -z "$board" ] && [ -e /sys/firmware/devicetree/base/compatible ]; then
|
||||||
case "$(cat /sys/firmware/devicetree/base/compatible 2>/dev/null)" in
|
case "$(cat /sys/firmware/devicetree/base/compatible 2>/dev/null)" in
|
||||||
purism,librem5r*) board=librem5;;
|
purism,librem5r*) board=librem5;;
|
||||||
|
purism,librem5-devkit*) board=librem5-devkit;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$device" ]; then
|
if [ -z "$device" ]; then
|
||||||
case "$board" in
|
case "$board" in
|
||||||
librem5) device=/dev/mmcblk0 ;;
|
librem5*) device=/dev/mmcblk0 ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ usage() {
|
||||||
get_defaults
|
get_defaults
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage: $0 [-n,--dry-run] [-i,--imagedir <imagedir>] [-b|--board <board-type>] [-d|--device <device>]
|
usage: $0 [-n,--dry-run] [-i,--imagedir <imagedir>] [-b|--board <board-type>] [-d|--device <device>] [-s|--skip-delay]
|
||||||
|
|
||||||
options:
|
options:
|
||||||
|
|
||||||
|
@ -52,9 +53,30 @@ options:
|
||||||
|
|
||||||
-n,--dry-run Print commands but don't execute them
|
-n,--dry-run Print commands but don't execute them
|
||||||
|
|
||||||
|
-s,--skip-delay Skip delay and flash the image immediately
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validate_checksum() {
|
||||||
|
file="$1"
|
||||||
|
file_sha512="$file.sha512"
|
||||||
|
file_size=$(stat -c%s $file)
|
||||||
|
device="$2"
|
||||||
|
bs="$3"
|
||||||
|
seek="$4"
|
||||||
|
|
||||||
|
checksum0=$(cat $file_sha512 | awk {'print $1'})
|
||||||
|
checksum1=$(dd if=$device bs=1 skip=$(($seek * $bs)) 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 $device :"
|
||||||
|
echo -e "\t$checksum1"
|
||||||
|
}
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
opt="$1"
|
opt="$1"
|
||||||
shift
|
shift
|
||||||
|
@ -77,6 +99,9 @@ while [ $# -gt 0 ]; do
|
||||||
-n|--dry-run)
|
-n|--dry-run)
|
||||||
dryrun="echo"
|
dryrun="echo"
|
||||||
;;
|
;;
|
||||||
|
-s|--skip-delay)
|
||||||
|
skip_delay="yes"
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
@ -94,8 +119,12 @@ if [ -z "$board" -o -z "$device" -o -z "$imagedir" -o ! -e "$imagedir" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$dryrun" ]; then
|
if [ -z "$dryrun" ]; then
|
||||||
|
if [ -z "$skip_delay" ]; then
|
||||||
echo "Updating $board u-boot in $device in 3 seconds..."
|
echo "Updating $board u-boot in $device in 3 seconds..."
|
||||||
sleep 3
|
sleep 3
|
||||||
|
else
|
||||||
|
echo "Updating $board u-boot in $device"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
|
@ -103,7 +132,13 @@ set -e
|
||||||
case "$board" in
|
case "$board" in
|
||||||
librem5)
|
librem5)
|
||||||
[ -e "$imagedir/librem5" ] || die "librem5 images not installed, apk add u-boot-librem5"
|
[ -e "$imagedir/librem5" ] || die "librem5 images not installed, apk add u-boot-librem5"
|
||||||
$dryrun dd if=$imagedir/librem5/phone-boot.img of=$device bs=1k seek=2 status=none
|
$dryrun dd if=$imagedir/librem5/phone-boot.img of=$device bs=1024 seek=2 oflag=direct status=none
|
||||||
|
[ -z "$dryrun" ] && validate_checksum $imagedir/librem5/phone-boot.img $device 1024 2
|
||||||
|
;;
|
||||||
|
librem5-devkit)
|
||||||
|
[ -e "$imagedir/librem5" ] || die "librem5-devkit images not installed, apk add u-boot-librem5-devkit"
|
||||||
|
$dryrun dd if=$imagedir/librem5/devkit-boot.img of=$device bs=1024 seek=2 oflag=direct status=none
|
||||||
|
[ -z "$dryrun" ] && validate_checksum $imagedir/librem5/devkit-boot.img $device 1024 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
$dryrun sync
|
$dryrun sync
|
||||||
|
|
Loading…
Reference in a new issue