From 2f78939f94f80f07b0ef612a04725084ca7bd452 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Mon, 7 Mar 2022 17:06:25 -0800 Subject: [PATCH] temp/u-boot-librem5: upgrade to 2022.04_rc1_git20220214 (MR 2983) Updates the u-boot on the Librem 5 to a branch that is much closer to mainline u-boot. - adds support for booting from SD card to the u-boot boot script - m4 is no longer necessary, at least not right now (may be re-added by purism in the future for supporting some low power modes) - adds a patch to enable u-boot console on uart 4 (on the m.2 connector) for the debug board - drops the patch to enable efidebug command, this isn't necessary anymore with mainline u-boot Co-authored-by: Bart Ribbers --- .../0001-Enable-efidebug-command.patch | 37 ------ ...0001-librem5-enable-console-on-UART4.patch | 25 ++++ temp/u-boot-librem5/APKBUILD | 120 ++++++++---------- temp/u-boot-librem5/update-u-boot | 10 +- 4 files changed, 87 insertions(+), 105 deletions(-) delete mode 100644 temp/u-boot-librem5/0001-Enable-efidebug-command.patch create mode 100644 temp/u-boot-librem5/0001-librem5-enable-console-on-UART4.patch diff --git a/temp/u-boot-librem5/0001-Enable-efidebug-command.patch b/temp/u-boot-librem5/0001-Enable-efidebug-command.patch deleted file mode 100644 index 0d843c5df..000000000 --- a/temp/u-boot-librem5/0001-Enable-efidebug-command.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 6984c79c9a7a5952ffe324a0a378281d80d1b738 Mon Sep 17 00:00:00 2001 -From: Clayton Craft -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 - diff --git a/temp/u-boot-librem5/0001-librem5-enable-console-on-UART4.patch b/temp/u-boot-librem5/0001-librem5-enable-console-on-UART4.patch new file mode 100644 index 000000000..af588f5e0 --- /dev/null +++ b/temp/u-boot-librem5/0001-librem5-enable-console-on-UART4.patch @@ -0,0 +1,25 @@ +From be5e9f092e96a0cdd759e517133146a28f10c093 Mon Sep 17 00:00:00 2001 +From: Clayton Craft +Date: Mon, 31 Jan 2022 16:37:13 -0800 +Subject: [PATCH] librem5: enable console on UART4 + +--- + include/configs/librem5.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/configs/librem5.h b/include/configs/librem5.h +index d826f856e1..46b07ba5be 100644 +--- a/include/configs/librem5.h ++++ b/include/configs/librem5.h +@@ -59,7 +59,7 @@ + + #define CONFIG_USB_GADGET_VBUS_DRAW 2 + +-#define CONSOLE_ON_UART1 ++#define CONSOLE_ON_UART4 + #define CONFIG_BAUDRATE 115200 + + #ifdef CONSOLE_ON_UART1 +-- +2.35.1 + diff --git a/temp/u-boot-librem5/APKBUILD b/temp/u-boot-librem5/APKBUILD index a1d328107..0910c1e0a 100644 --- a/temp/u-boot-librem5/APKBUILD +++ b/temp/u-boot-librem5/APKBUILD @@ -1,93 +1,87 @@ # Forked from Alpine, so we can build it with Librem 5 phone support pkgname=u-boot-librem5 -pkgver=0.12 +pkgver=2022.04_rc1_git20220214 pkgrel=0 +# 'upstream/librem5' branch in uboot repo +_commit="cf03130d32f69fb78f404d64f1262b7f5c9ce4b5" # 'librem5' branch in atf repo -_atfversion="92c2de12d36b31938ce940d5cac3c30a98665237" -# 'librem5' branch in uboot repo -_ubootversion="0c1162a11d5f9736edde7a30cf0085f3e0277b47" -_m4version="a017421c340a69f2392086da93841244f78a03c5" +_atf_commit="92c2de12d36b31938ce940d5cac3c30a98665237" _firmwareversion="8.12" pkgdesc="u-boot bootloader for the Purism Librem5 phone" url="http://www.denx.de/wiki/U-Boot/" arch="aarch64" license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs" -makedepends="$depends_dev bc dtc python3-dev swig binutils coreutils zlib-dev newlib-arm-none-eabi bison flex" +makedepends=" + bc + binutils + bison + coreutils + dtc + flex + openssl-dev + py3-setuptools + python3-dev + swig + zlib-dev + " options="!check !tracedeps pmb:cross-native" source=" - uboot-imx-${_ubootversion}.tar.gz::https://source.puri.sm/Librem5/uboot-imx/-/archive/${_ubootversion}/uboot-imx-${_ubootversion}.tar.gz - m4-${_m4version}.tar.gz::https://source.puri.sm/Librem5/Cortex_M4/-/archive/${_m4version}/Cortex_M4-${_m4version}.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://source.puri.sm/Librem5/uboot-imx/-/archive/$_commit/uboot-imx-$_commit.tar.gz + https://source.puri.sm/Librem5/arm-trusted-firmware/-/archive/$_atf_commit/arm-trusted-firmware-$_atf_commit.tar.gz + https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-$_firmwareversion.bin update-u-boot - 0001-Enable-efidebug-command.patch + 0001-librem5-enable-console-on-UART4.patch " -install="$pkgname.post-upgrade $pkgname-devkit.post-upgrade" -subpackages="$pkgname-devkit" +install="$pkgname.post-upgrade" +# install="$pkgname.post-upgrade $pkgname-devkit.post-upgrade" +# subpackages="$pkgname-devkit" -_ubootbuilddir="$srcdir"/uboot-imx-${_ubootversion} -_atfbuilddir="$srcdir"/arm-trusted-firmware-${_atfversion} -_m4builddir="$srcdir"/Cortex_M4-${_m4version} -_firmwarebuilddir="$srcdir"/firmware-imx-${_firmwareversion} -builddir="$_ubootbuilddir" +_atf_builddir="$srcdir/arm-trusted-firmware-$_atf_commit" +_firmware_builddir="$srcdir/firmware-imx-$_firmwareversion" +builddir="$srcdir/uboot-imx-$_commit" prepare() { default_prepare msg "Extracting DDR & HDMI firmware" cd "$srcdir" - chmod +x firmware-imx-${_firmwareversion}.bin - ./firmware-imx-${_firmwareversion}.bin --auto-accept - cp -v "$_firmwarebuilddir"/firmware/ddr/synopsys/lpddr4*.bin "$_ubootbuilddir"/ - cp -v "$_firmwarebuilddir"/firmware/hdmi/cadence/signed*.bin "$_ubootbuilddir"/ + chmod +x firmware-imx-$_firmwareversion.bin + ./firmware-imx-$_firmwareversion.bin --auto-accept + cp -v "$_firmware_builddir"/firmware/ddr/synopsys/lpddr4*.bin $builddir/ + cp -v "$_firmware_builddir"/firmware/hdmi/cadence/signed_*imx8m.bin $builddir/ } build() { - msg "Building M4" - cd "$_m4builddir" - make - msg "Building ARM trusted firmware" - cd "$_atfbuilddir" + cd "$_atf_builddir" LDFLAGS="" make PLAT=imx8mq bl31 # Overwrite default bl31 binary with one made here - cp -v "$_atfbuilddir"/build/imx8mq/release/bl31.bin "$_ubootbuilddir"/ + export BL31="$_atf_builddir/build/imx8mq/release/bl31.bin" + cp -v "$_atf_builddir"/build/imx8mq/release/bl31.bin "$builddir"/ msg "Building u-boot" - cd "$_ubootbuilddir" - # Note: HOSTCC is set explicitly here else it tries to use cc, which - # doesn't exist on Alpine - # + cd $builddir + # Devkit uboot firmware - make distclean - make ARCH=arm HOSTCC=gcc librem5_devkit_defconfig - make ARCH=arm HOSTCC=gcc flash.bin - mv flash.bin devkit-flash.bin + # NOTE: disabled, not supported yet in the new mainline branch + # make distclean + # make librem5_devkit_defconfig + # make ARCH=arm + # mv "$builddir"/flash.bin "$builddir"/devkit-boot.img + # sha512sum -b "$builddir"/devkit-boot.img > "$builddir"/devkit-boot.img.sha512 # Phone uboot firmware make distclean - make ARCH=arm HOSTCC=gcc librem5_defconfig - make ARCH=arm HOSTCC=gcc flash.bin - mv flash.bin phone-flash.bin - - msg "Building u-boot flashing images" - # devkit - 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="$_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 - 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="$_ubootbuilddir"/phone-flash.bin conv=notrunc of="$_ubootbuilddir"/phone-boot.img bs=1024 seek=31 - sha512sum -b "$_ubootbuilddir"/phone-boot.img > "$_ubootbuilddir"/phone-boot.img.sha512 + make librem5_defconfig + make ARCH=arm + mv flash.bin phone-boot.img + sha512sum -b phone-boot.img > phone-boot.img.sha512 } package() { - install -D -m644 "$_ubootbuilddir"/phone-boot.img \ + install -D -m644 "$builddir"/phone-boot.img \ "$pkgdir/usr/share/u-boot/librem5/phone-boot.img" - install -D -m644 "$_ubootbuilddir"/phone-boot.img.sha512 \ + install -D -m644 "$builddir"/phone-boot.img.sha512 \ "$pkgdir/usr/share/u-boot/librem5/phone-boot.img.sha512" install -D -m 755 "$srcdir"/update-u-boot \ "$pkgdir"/usr/sbin/update-u-boot @@ -95,20 +89,18 @@ package() { devkit() { pkgdesc="u-boot bootloader for the Purism Librem5 devkit" - install -D -m644 "$_ubootbuilddir"/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 -m644 "$builddir"/devkit-boot.img \ + "$pkgdir/usr/share/u-boot/librem5/devkit-boot.img" + install -D -m644 "$builddir"/devkit-boot.img.sha512 \ + "$pkgdir/usr/share/u-boot/librem5/devkit-boot.img.sha512" install -D -m 755 "$srcdir"/update-u-boot \ - "$subpkgdir"/usr/sbin/update-u-boot + "$pkgdir"/usr/sbin/update-u-boot } - sha512sums=" -ee540631b4bc0a33dfb29d9ba6e1dcd6a5cb1d43a4bc1ab2c7a29637d9c141d1c6559c933a48b8ce67d5bc140e7875a92cfc1846eb3ff7ce2826b8d12ff56b4e uboot-imx-0c1162a11d5f9736edde7a30cf0085f3e0277b47.tar.gz -035a4358ddf586c829da7fa2fb0d9d1df913c0c454f2d0e57ff0c6794552e49950fb6373f9aaf72e0e4c78ab411496aabbc60bf66cd76e35053f7a2d77911735 m4-a017421c340a69f2392086da93841244f78a03c5.tar.gz +c4650c686e0ed6cf07d3b41c3e5e99d2cecad6f3bbaffafef5c2e99f1463b58b2e771b2844c76b26f714988e016398d08bd66ece3eef25f2f0a986dd29eabf37 uboot-imx-cf03130d32f69fb78f404d64f1262b7f5c9ce4b5.tar.gz cd8c9411ae0e57d2c8c700bf3e8c8d03e7dab955ace249a00911dd8c42b42929e0de3a5885eb9b1d945174abc8cfb177595d83c235e757c70640f451b62547ba arm-trusted-firmware-92c2de12d36b31938ce940d5cac3c30a98665237.tar.gz 1f968558bf158401ee5afe1c67e67bdd8ca2cb5d07029e78c745e751c665b68fa74128fca8b7161501a6445bbb18e8d463b42d787a61132db5c8778703462668 firmware-imx-8.12.bin -8eb2793814e53752ba8635694094ea43234ed6411ff4fd3e39c970fd4c4fa1b515b292a6d34b6e9a4ffbb573b1cf18a043f6be4e5cf95fa0ff4b9df9afe05c63 update-u-boot -24883f7293ebe7995aca8caae872a9c192b56651bfce9f408e5c9d001eda4df59fe755c006e737ff3ca42041577f711e4e600bd71629c2abad4b4a593062906c 0001-Enable-efidebug-command.patch +e46a863001872943301f9712e45797553ce52d8b0c3e63dba7beb1a54b857e8f3a715863b84cd7ab784f039f82d29a2b19b581891d11a84c342b1570e5ccfed3 update-u-boot +acccd93ca755c619f8ac63987c4d0d149afb808d3c4f4ac923e4793855deae12e68b3e042f48fe1bed59aac47f5080e26ea2737cb9466404fa3e4771b5da2af8 0001-librem5-enable-console-on-UART4.patch " diff --git a/temp/u-boot-librem5/update-u-boot b/temp/u-boot-librem5/update-u-boot index 6b5d85788..31e307e9e 100644 --- a/temp/u-boot-librem5/update-u-boot +++ b/temp/u-boot-librem5/update-u-boot @@ -131,14 +131,16 @@ fi set -e case "$board" in librem5) + seek=33 [ -e "$imagedir/librem5" ] || die "librem5 images not installed, apk add u-boot-librem5" - $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 + $dryrun dd if=$imagedir/librem5/phone-boot.img of=$device bs=1024 seek="$seek" oflag=direct status=none + [ -z "$dryrun" ] && validate_checksum $imagedir/librem5/phone-boot.img $device 1024 "$seek" ;; librem5-devkit) + seek=33 [ -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 + $dryrun dd if=$imagedir/librem5/devkit-boot.img of=$device bs=1024 seek="$seek" oflag=direct status=none + [ -z "$dryrun" ] && validate_checksum $imagedir/librem5/devkit-boot.img $device 1024 "$seek" ;; esac $dryrun sync