From cc548863e256b932236091ba840b740360683f5c Mon Sep 17 00:00:00 2001 From: "build@apk-groulx" Date: Sun, 23 Apr 2023 01:02:50 +0000 Subject: [PATCH] uboot: refactor for future build of rm2 --- user/u-boot-rm/APKBUILD | 124 ++++++++++++------ ...atch.patch => rm1-uboot-config-patch.diff} | 0 user/u-boot-rm/rm2-uboot-config-patch.diff | 75 +++++++++++ user/u-boot-rm/update-u-boot | 2 +- 4 files changed, 159 insertions(+), 42 deletions(-) rename user/u-boot-rm/{uboot-config-patch.patch => rm1-uboot-config-patch.diff} (100%) create mode 100644 user/u-boot-rm/rm2-uboot-config-patch.diff diff --git a/user/u-boot-rm/APKBUILD b/user/u-boot-rm/APKBUILD index 59666f9..b418f34 100644 --- a/user/u-boot-rm/APKBUILD +++ b/user/u-boot-rm/APKBUILD @@ -1,64 +1,97 @@ -# Contributor: William Pitcock -# Contributor: Timo Teras -# Maintainer: Leonardo Arena +# Maintainer: Antoine Martin (ayakael) +# Contributor: Antoine Martin (ayakael) + pkgname=u-boot-rm -pkgver=2016.05 -_gittag=97b35fdddf0077abd2e0f0409b94ef20adbe8565 +pkgver=2020.09 +_rm1tag=97b35fdddf0077abd2e0f0409b94ef20adbe8565 +_rm2tag=47c91918aa7724c16b6eaf87cf5dfbf4548eafc1 pkgrel=0 [ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" pkgdesc="u-boot bootloader common files" -url="http://www.denx.de/wiki/U-Boot/" -arch="armv7" -license="GPL2" -depends="" -depends_dev="" -makedepends="$depends_dev bc dtc gcc$_cross" -install="" -source="https://github.com/reMarkable/uboot/archive/$_gittag.tar.gz - README.txt - uboot-config-patch.patch - update-u-boot +url="https://www.denx.de/wiki/U-Boot/" +arch="armv7 armhf" +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" +options="!check" # no tests +makedepends=" + bc + bison + dtc + flex + gnutls-dev + linux-headers + openssl-dev>3 + py3-elftools + py3-setuptools + python3-dev + swig + util-linux-dev + gcc$_cross " +source=" + u-boot-rm1-$_rm1tag.tar.gz::https://github.com/reMarkable/uboot/archive/$_rm1tag.tar.gz + u-boot-rm2-$_rm2tag.tar.gz::https://github.com/reMarkable/uboot/archive/$_rm2tag.tar.gz + update-u-boot + README.txt + rm1-uboot-config-patch.diff + rm2-uboot-config-patch.diff + " +builddir="$srcdir" -builddir="$srcdir"/uboot-$_gittag - +#rm2:zero-sugar broken case "$CARCH" in -armv7) board_configs=" +arm*) board_configs=" rm1:zero-gravitas ";; esac -_allboards="" for board_config in $board_configs; do _allboards="$_allboards $pkgname-${board_config%%:*}" done -subpackages="$pkgname-all:_all $_allboards" + +subpackages="$pkgname-all:_all $_allboards $pkgname-dev" +prepare() { + default_prepare + + cd "$builddir"/uboot-$_rm1tag + patch -p1 -i "$srcdir"/rm1-uboot-config-patch.diff + cd "$builddir"/uboot-$_rm2tag + patch -p1 -i "$srcdir"/rm2-uboot-config-patch.diff +} 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 - local board_config board for board_config in $board_configs; do local configs="${board_config#*:}" for board in ${configs//,/ }; do msg "Building u-boot for $board" - export BUILD_DIR="$builddir"/$board + case $board in + zero-gravitas) cd "$builddir"/uboot-$_rm1tag;; + zero-sugar) cd "$builddir"/uboot-$_rm2tag;; + esac + + 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 + + export BUILD_DIR="$builddir"/build/$board mkdir -p "$BUILD_DIR" - make O="$BUILD_DIR" ${board}_config || return 1 - make O="$BUILD_DIR" all || return 1 + make O="$BUILD_DIR" ${board}_config + make O="$BUILD_DIR" all done done } package() { - cd "$builddir" mkdir -p "$pkgdir"/usr/share/$pkgname "$pkgdir"/usr/sbin - install "$srcdir"/README.txt "$pkgdir"/usr/share/$pkgname/README.txt || return 1 - install "$srcdir"/update-u-boot "$pkgdir"/usr/sbin || return 1 + install "$srcdir"/README.txt "$pkgdir"/usr/share/$pkgname/README.txt + install "$srcdir"/update-u-boot "$pkgdir"/usr/sbin + + cd "$srcdir"/uboot-$_rm1tag + mkdir -p "$pkgdir"/usr/include/$pkgname + find -type f -name '*.h' -exec cp -iv --parents -t "$pkgdir"/usr/include/$pkgname {} \; } _all() { @@ -69,7 +102,7 @@ _all() { } _split_boards() { - cd "$builddir" + cd "$builddir"/build pkgdesc="u-boot for $1" depends="u-boot" shift @@ -77,32 +110,41 @@ _split_boards() { for board; do msg "Including board $board" mkdir -p "$subpkgdir"/usr/share/$pkgname/$board - export BUILD_DIR="$builddir"/$board + export BUILD_DIR="$builddir"/build/$board + + local board_images="" + case "$board" in + "sifive_unleashed") board_images="u-boot.itb spl/u-boot-spl.bin --" ;; + "sifive_unmatched") board_images="u-boot.itb spl/u-boot-spl.bin --" ;; + "rockpro64-rk3399"|"roc-pc-rk3399"|"roc-cc-rk3328") board_images="u-boot.img u-boot.itb idbloader.img --" ;; + esac + local ok=no - for image in u-boot-sunxi-with-spl.bin -- MLO SPL u-boot.img -- u-boot.bin; do + for image in $board_images u-boot-sunxi-with-spl.bin -- MLO SPL u-boot.img -- u-boot.bin; do if [ "$image" = "--" ]; then [ "$ok" = yes ] && break continue fi if [ -e "$BUILD_DIR"/$image ]; then - cp "$BUILD_DIR"/$image "$subpkgdir"/usr/share/$pkgname/$board \ - || return 1 + cp "$BUILD_DIR"/$image "$subpkgdir"/usr/share/$pkgname/$board ok=yes fi done - [ "$ok" = yes ] || return 1 + [ "$ok" = yes ] || return done } for board_config in $board_configs; do _board="${board_config%%:*}" _configs="${board_config#*:}" - eval "${_board}() { _split_boards $_board ${_configs//,/ }; }" + eval "$_board() { _split_boards $_board ${_configs//,/ }; }" done sha512sums=" -7cc8d513cac1d63ee5119529caa056164ee3bc3633da5d880fbfb344b770c7c53c41475d42dd129b505390dcd5449e14524afc06f7cdba9354af7e70a7035ef9 97b35fdddf0077abd2e0f0409b94ef20adbe8565.tar.gz +7cc8d513cac1d63ee5119529caa056164ee3bc3633da5d880fbfb344b770c7c53c41475d42dd129b505390dcd5449e14524afc06f7cdba9354af7e70a7035ef9 u-boot-rm1-97b35fdddf0077abd2e0f0409b94ef20adbe8565.tar.gz +d0d18b123c4281285a8b3c1afd9ef623b48a33506399c8e0dbc393f22d967ee3e5df7030aab26c4fe8cad614f3f22f1ea5d6b5bb4ef5cc46fffe56b7ac7c3c28 u-boot-rm2-47c91918aa7724c16b6eaf87cf5dfbf4548eafc1.tar.gz +84974430d68321d3dd109d52ecd18ecf4e99c9576e2aa85b99057ecf369ac9a60c7c6cb68f4fabcd88f3a421f359fbabe0b9ca2fccb91053c5f4e9cd30944657 update-u-boot f8c9bb6e84d6f0620c976ac7ad5dd7ec7ff9dfdd4b1d03d2bf6653e7beccf80bdf2debfc92fb1f696dba92fb40287d3c45897e0078951451d0835cb61a5f16d1 README.txt -673cb917cc565ae245d4a7d659227bc240473112bc9c73ae184a64ce74be7994273d6dc4db17194d348941f83a42b3b67d3140f6f23c37c13d6dc93f7d76cc39 uboot-config-patch.patch -d57796ce018afa15e12521a90761ab1ae6411acf1fc0c1ce95f0d48630e0949568d8a7e577ba52d91c56918a9d414951c608aa49389ac7f8b50cb8aba5da9697 update-u-boot +673cb917cc565ae245d4a7d659227bc240473112bc9c73ae184a64ce74be7994273d6dc4db17194d348941f83a42b3b67d3140f6f23c37c13d6dc93f7d76cc39 rm1-uboot-config-patch.diff +0e98404ca6d20eb01bd9c129b05e2eb10c60a692a56adc221ea283b4bfe7b0bcc2851121d4c3fe51e07a9784c339f7ccb221e0cc3f3603144fec46be66d0cbcc rm2-uboot-config-patch.diff " diff --git a/user/u-boot-rm/uboot-config-patch.patch b/user/u-boot-rm/rm1-uboot-config-patch.diff similarity index 100% rename from user/u-boot-rm/uboot-config-patch.patch rename to user/u-boot-rm/rm1-uboot-config-patch.diff diff --git a/user/u-boot-rm/rm2-uboot-config-patch.diff b/user/u-boot-rm/rm2-uboot-config-patch.diff new file mode 100644 index 0000000..4aa04bc --- /dev/null +++ b/user/u-boot-rm/rm2-uboot-config-patch.diff @@ -0,0 +1,75 @@ +diff --git a/include/configs/zero-sugar.h.orig b/include/configs/zero-sugar.h +index 6b5450a..dd6da5c 100644 +--- a/include/configs/zero-sugar.h.orig ++++ b/include/configs/zero-sugar.h +@@ -122,12 +122,10 @@ + "panel=EPD\0" \ + "mmcdev=0\0" \ + "active_partition=2\0" \ +- "fallback_partition=3\0 " \ + "bootlimit=1\0 " \ + "mmcautodetect=yes\0" \ + "mmcargs=setenv bootargs console=${console},${baudrate} " \ +- "root=/dev/mmcblk2p${active_partition} rootwait rootfstype=ext4 rw " \ +- "quiet panic=20 systemd.crash_reboot\0" \ ++ "root=/dev/mmcblk2p2 rootwait rootfstype=ext4 rw " \ + "loadimage=ext4load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \ + "loadfdt=ext4load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \ + "mmcboot=echo Booting from mmc ...; " \ +@@ -140,41 +138,13 @@ + "echo WARN: Cannot load the DT; " \ + "fi; " \ + "fi; " \ +- "fi;\0" \ +- "memboot=echo Booting from memory...; " \ +- "setenv bootargs console=${console},${baudrate} " \ +- "g_mass_storage.stall=0 g_mass_storage.removable=1 " \ +- "g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF "\ +- "g_mass_storage.iSerialNumber=\"\" rdinit=/linuxrc; "\ +- "bootz ${loadaddr} ${initrd} ${fdt_addr};\0" \ +- "altbootcmd=echo Running from fallback root...; " \ +- "run memboot; " \ +- "if test ${bootcount} -gt 10; then " \ +- "echo WARN: Failed too much, resetting bootcount and turning off; " \ +- "setenv bootcount 0; " \ +- "saveenv; " \ +- "poweroff; " \ +- "fi; " \ +- "setenv mmcpart ${fallback_partition}; " \ +- "setenv bootargs console=${console},${baudrate} " \ +- "root=/dev/mmcblk2p${fallback_partition} rootwait rootfstype=ext4 quiet rw " \ +- "systemd.log_level=debug systemd.log_target=kmsg memtest " \ +- "log_buf_len=1M printk.devkmsg systemd.journald.forward_to_console=1; " \ +- "run mmcboot;\0" \ ++ "fi;\0" + + /* Always try to boot from memory first, in case of USB download mode */ + #define CONFIG_BOOTCOMMAND \ +- "if test ! -e mmc 0:1 uboot.env; then " \ +- "saveenv; " \ +- "fi; " \ +- "run memboot; " \ + "run mmcargs; " \ + "setenv mmcpart ${active_partition}; " \ +- "run mmcboot; " \ +- "echo WARN: unable to boot from either RAM or eMMC; " \ +- "setenv upgrade_available 1; " \ +- "saveenv; " \ +- "reset; " ++ "run mmcboot; " + + #define CONFIG_SYS_MEMTEST_START 0x80000000 + #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x20000000) +@@ -198,10 +168,8 @@ + /* Environment organization */ + #define CONFIG_ENV_SIZE SZ_8K + +-#ifdef CONFIG_ENV_IS_IN_FAT +-#define CONFIG_BOOTCOUNT_LIMIT +-#define CONFIG_BOOTCOUNT_ENV +-#endif ++/*#define CONFIG_ENV_IS_IN_FAT*/ ++#define CONFIG_ENV_IS_NOWHERE + + #define CONFIG_SYS_FSL_USDHC_NUM 2 + diff --git a/user/u-boot-rm/update-u-boot b/user/u-boot-rm/update-u-boot index 069d654..cae43df 100755 --- a/user/u-boot-rm/update-u-boot +++ b/user/u-boot-rm/update-u-boot @@ -21,7 +21,7 @@ get_defaults() { if [ -z "$imagedir" ]; then imagedir="$(realpath $(dirname $0))" - [ -f "$imagedir/README.txt" ] || imagedir="/usr/share/u-boot" + [ -f "$imagedir/README.txt" ] || imagedir="/usr/share/u-boot-rm" fi }