user/u-boot-rm: new aport

This commit is contained in:
Antoine Martin 2023-04-23 02:30:23 -04:00 committed by Antoine Martin
parent 11475a1789
commit cbca51c7aa
6 changed files with 512 additions and 0 deletions

143
user/u-boot-rm/APKBUILD Normal file
View file

@ -0,0 +1,143 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=u-boot-rm
pkgver=2020.09
_rm1tag=97b35fdddf0077abd2e0f0409b94ef20adbe8565
_rm2tag=47c91918aa7724c16b6eaf87cf5dfbf4548eafc1
pkgrel=0
pkgdesc="u-boot bootloader common files"
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
"
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"
#rm2:zero-sugar broken
case "$CARCH" in
arm*) board_configs="
rm1:zero-gravitas
";;
esac
for board_config in $board_configs; do
_allboards="$_allboards $pkgname-${board_config%%:*}"
done
subpackages="$pkgname-all:_all $_allboards"
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() {
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"
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
make O="$BUILD_DIR" all
done
done
}
package() {
mkdir -p "$pkgdir"/usr/share/$pkgname "$pkgdir"/usr/sbin
install "$srcdir"/README.txt "$pkgdir"/usr/share/$pkgname/README.txt
install "$srcdir"/update-u-boot "$pkgdir"/usr/sbin
}
_all() {
pkgdesc="u-boot for all boards (meta package)"
depends="$_allboards"
mkdir -p "$subpkgdir"/
}
_split_boards() {
cd "$builddir"/build
pkgdesc="u-boot for $1"
depends="u-boot"
shift
local board
for board; do
msg "Including board $board"
mkdir -p "$subpkgdir"/usr/share/$pkgname/$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 $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
ok=yes
fi
done
[ "$ok" = yes ] || return
done
}
for board_config in $board_configs; do
_board="${board_config%%:*}"
_configs="${board_config#*:}"
eval "$_board() { _split_boards $_board ${_configs//,/ }; }"
done
sha512sums="
7cc8d513cac1d63ee5119529caa056164ee3bc3633da5d880fbfb344b770c7c53c41475d42dd129b505390dcd5449e14524afc06f7cdba9354af7e70a7035ef9 u-boot-rm1-97b35fdddf0077abd2e0f0409b94ef20adbe8565.tar.gz
d0d18b123c4281285a8b3c1afd9ef623b48a33506399c8e0dbc393f22d967ee3e5df7030aab26c4fe8cad614f3f22f1ea5d6b5bb4ef5cc46fffe56b7ac7c3c28 u-boot-rm2-47c91918aa7724c16b6eaf87cf5dfbf4548eafc1.tar.gz
49a7325bf0df5661c33b043d314eea382c348d2862b807991e151d9ef34ecd01d5c4b3c602c171e66c63c881631ccd610f81bc696b00025d4ae0926b82896731 update-u-boot
f8c9bb6e84d6f0620c976ac7ad5dd7ec7ff9dfdd4b1d03d2bf6653e7beccf80bdf2debfc92fb1f696dba92fb40287d3c45897e0078951451d0835cb61a5f16d1 README.txt
673cb917cc565ae245d4a7d659227bc240473112bc9c73ae184a64ce74be7994273d6dc4db17194d348941f83a42b3b67d3140f6f23c37c13d6dc93f7d76cc39 rm1-uboot-config-patch.diff
0e98404ca6d20eb01bd9c129b05e2eb10c60a692a56adc221ea283b4bfe7b0bcc2851121d4c3fe51e07a9784c339f7ccb221e0cc3f3603144fec46be66d0cbcc rm2-uboot-config-patch.diff
"

32
user/u-boot-rm/README.txt Normal file
View file

@ -0,0 +1,32 @@
WandBoard
---------
- ROM loads boot loader from raw MMC sectors at fixed address
- NOTE: 1st partition needs to start after boot loader
- Install u-boot with:
dd if=wandboard/SPL of=/dev/mmcblk0 bs=1k seek=1
dd if=wandboard/u-boot.img of=/dev/mmcblk0 bs=1k seek=69
sync
(Note - the SD card node may vary, so adjust this as needed).
- Insert the SD card into the slot located in the bottom of the board
(same side as the mx6 processor)
BeagleBoard
-----------
- ROM looks for 1st partition with FAT, and loads MLO from it
- NOTE: MLO needs to be the first file created on this partition
- Install u-boot with:
cp am335x_boneblack/{MLO,u-boot.img} /media/mmcblk0p1/
Sunxi (Cubie* etc)
------------------
- ROM loads boot loader from SD-CARD sectors at fixed address
- Install u-boot with:
sudo dd if=<board>/u-boot-sunxi-with-spl.bin of=/dev/sda bs=1024 seek=8

View file

@ -0,0 +1,52 @@
From 58772283210e15f8d803db4aa67c877d668db867 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/u-boot/u-boot/commit/58772283210e15f8d803db4aa67c877d668db867
From: Alistair Delva <adelva@google.com>
Date: Wed, 20 Oct 2021 21:31:33 +0000
Subject: [PATCH] x86: Fix linking u-boot with ld.lld
When linking the final u-boot binary with LLD, the following link errors
are seen:
ld.lld: error: can't create dynamic relocation R_386_32 against local
symbol in readonly segment; recompile object files with
-fPIC or pass '-Wl,-z,notext' to allow text relocations
in the output
>>> defined in arch/x86/cpu/start.o
>>> referenced by arch/x86/cpu/start.o:(.text.start+0x32)
[...]
>>> defined in arch/x86/cpu/start16.o
>>> referenced by arch/x86/cpu/start16.o:(.start16+0x1C)
According to Nick Desaulniers:
"This is a known difference between GNU and LLVM linkers; the GNU
linkers permit relocations in readonly segments (making them not read
only), LLVM does not (by default)."
Since U-Boot apparently seems to use relocations in readonly segments,
change the global linker flags to permit them when linking with LLD by
specifying '-z notext'.
Signed-off-by: Alistair Delva <adelva@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Makefile b/Makefile
index c0ea933cb636..286757986c02 100644
--- a/Makefile
+++ b/Makefile
@@ -776,6 +776,9 @@ ifneq ($(CONFIG_SYS_TEXT_BASE),)
LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
endif
+# ld.lld support
+LDFLAGS_u-boot += -z notext
+
# Normally we fill empty space with 0xff
quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \

View file

@ -0,0 +1,83 @@
diff --git a/include/configs/zero-gravitas.h b/include/configs/zero-gravitas.h
index 074f171422..818ed56892 100644
--- a/include/configs/zero-gravitas.h
+++ b/include/configs/zero-gravitas.h
@@ -71,12 +71,10 @@
"splashimage=0x80000000\0" \
"splashpos=m,m\0" \
"active_partition=2\0" \
- "fallback_partition=3\0" \
"bootlimit=1\0" \
"por=undefined\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
- "systemd.crash_reboot=true memtest " \
- "root=/dev/mmcblk1p${active_partition} rootwait rootfstype=ext4 quiet rw por=${por};\0" \
+ "root=/dev/mmcblk1p2 rootwait rootfstype=ext4 rw por=${por};\0" \
"loadimage=ext4load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
"loadfdt=ext4load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
"mmcboot=echo Booting from mmc ...; " \
@@ -89,41 +87,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/mmcblk1p${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 1: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; "
#ifdef CONFIG_BOOTDELAY
#undef CONFIG_BOOTDELAY
@@ -157,18 +127,8 @@
/* Environment organization */
#define CONFIG_ENV_SIZE SZ_8K
-#define CONFIG_ENV_IS_IN_FAT
-/*#define CONFIG_ENV_IS_NOWHERE*/
-
-#ifdef CONFIG_ENV_IS_IN_FAT
-#define CONFIG_BOOTCOUNT_LIMIT
-#define CONFIG_BOOTCOUNT_ENV
-
-#define FAT_ENV_INTERFACE "mmc"
-#define FAT_ENV_DEVICE_AND_PART "1:1"
-#define CONFIG_FAT_WRITE
-#define FAT_ENV_FILE "uboot.env"
-#endif
+/*#define CONFIG_ENV_IS_IN_FAT*/
+#define CONFIG_ENV_IS_NOWHERE
#ifdef CONFIG_CMD_SF
#define CONFIG_MXC_SPI

View file

@ -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

127
user/u-boot-rm/update-u-boot Executable file
View file

@ -0,0 +1,127 @@
#!/bin/sh
verbose=
board=
device=
dryrun=
imagedir=
get_defaults() {
if [ -z "$board" -a -e /sys/firmware/devicetree/base/compatible ]; then
case "$(cat /sys/firmware/devicetree/base/compatible 2>/dev/null)" in
wand,*) board=wand ;;
esac
fi
if [ -z "$device" ]; then
case "$board" in
wand|cubie|cubie2) device=/dev/mmcblk0p0 ;;
esac
fi
if [ -z "$imagedir" ]; then
imagedir="$(realpath $(dirname $0))"
[ -f "$imagedir/README.txt" ] || imagedir="/usr/share/u-boot-rm"
fi
}
die() {
echo "ERROR: $@"
exit 1
}
usage() {
get_defaults
cat <<EOF
usage: $0 [-b|--board <board-type>] [-d|--device <device>]
options:
-b,--board <board> Specify the board type: wand, cubie, cubie2
(current default: ${board:-none})
-d,--device <device> Specify the device where to install u-boot
(current default: ${device:-none})
-i,--imagedir <imagedir> Specify u-boot image directory
(current default: ${imagedir:-none})
-n,--dry-run Print commands but don't execute them
EOF
}
while [ $# -gt 0 ]; do
opt="$1"
shift
case "$opt" in
-b|--board)
case "$1" in
wand|wandboard) board="wand" ;;
cubie|cubieboard) board="cubie" ;;
rm1) board="zero-gravitas" ;;
rm2) board="zero-sugar" ;;
*) usage; exit 1;;
esac
shift
;;
-d|--device)
device="$1"
shift
;;
-i|--imagedir)
imagedir="$1"
shift
;;
-n|--dry-run)
dryrun="echo"
;;
--)
break
;;
-*)
usage
exit 1
;;
esac
done
get_defaults
if [ -z "$board" -o -z "$device" -o -z "$imagedir" -o ! -e "$imagedir" ]; then
usage
exit 1
fi
if [ -z "$dryrun" ]; then
echo "Updating $board u-boot in $device in 3 seconds..."
sleep 3
fi
(
set -e
case "$board" in
wand)
[ -e "$imagedir/wandboard" ] || die "wandboard images not installed, apk add u-boot-wandboard"
$dryrun dd if=$imagedir/wandboard/SPL of=$device bs=1k seek=1 status=none
$dryrun dd if=$imagedir/wandboard/u-boot.img of=$device bs=1k seek=69 status=none
;;
cubie|cubie2)
[ -e "$imagedir/Cubieboard${board#cubie}" ] || die "Cubieboard images not installed, apk add u-boot-cubieboard"
$dryrun dd if=$imagedir/Cubieboard${board#cubie}/u-boot-sunxi-with-spl.bin of=/dev/sda bs=1024 seek=8 status=none
;;
zero-gravitas)
[ -e "$imagedir/zero-gravitas" ] || die "rM1 images not installed, apk add u-boot-rm1"
$drurun dd if=/dev/zero of=/dev/mmcblk1 bs=512 seek=1536 count=16
$dryrun echo 0 > /sys/block/mmcblk1boot0/force_ro
$dryrun dd if=$imagedir/zero-gravitas/u-boot.bin of=/dev/mmcblk1boot0 bs=512 seek=2
$dryrun echo 1 > /sys/block/mmcblk1boot0/force_ro
;;
zero-sugar)
die "rM2 not yet tested"
;;
esac
$dryrun sync
) || die "U-Boot installation in $device failed"
[ -z "$dryrun" ] && echo "Completed successfully."