diff --git a/buildroot-external/board/arm-uefi/generic-aarch64/cmdline.txt b/buildroot-external/board/arm-uefi/generic-aarch64/cmdline.txt index 5f4472675..d2ae94d79 100644 --- a/buildroot-external/board/arm-uefi/generic-aarch64/cmdline.txt +++ b/buildroot-external/board/arm-uefi/generic-aarch64/cmdline.txt @@ -1 +1 @@ -cmdline="" +console=tty1 console=ttyS0 diff --git a/buildroot-external/board/arm-uefi/generic-aarch64/grub.cfg b/buildroot-external/board/arm-uefi/generic-aarch64/grub.cfg index bf92b1bfe..525cf8293 100644 --- a/buildroot-external/board/arm-uefi/generic-aarch64/grub.cfg +++ b/buildroot-external/board/arm-uefi/generic-aarch64/grub.cfg @@ -43,7 +43,7 @@ fi save_env A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID default_cmdline="rootwait zram.enabled=1 zram.num_devices=3 apparmor=1 security=apparmor systemd.machine_id=$MACHINE_ID cgroup_enable=memory fsck.repair=yes" -source ($root)/cmdline.txt +file_env -f ($root)/cmdline.txt cmdline # root is a full HDD/partition definition in GRUB format like hd0,gpt1 # We extract the part before the comma to then append our own partition index diff --git a/buildroot-external/board/pc/barebox.config b/buildroot-external/board/pc/barebox.config deleted file mode 100644 index 115f5b805..000000000 --- a/buildroot-external/board/pc/barebox.config +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG_MMU=y -CONFIG_MALLOC_SIZE=0x0 -CONFIG_MALLOC_TLSF=y -CONFIG_DRIVER_SERIAL_EFI=y -CONFIG_DRIVER_SERIAL_EFI_STDIO=y -# CONFIG_SPI is not set -CONFIG_DISK=y -CONFIG_DISK_WRITE=y -CONFIG_FS_EFI=y -CONFIG_FS_EFIVARFS=y diff --git a/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh b/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh index f64466167..2e73af0bd 100755 --- a/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh +++ b/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh @@ -3,13 +3,15 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" + local EFIPART_DATA="${BINARIES_DIR}/efi-part" mkdir -p "${BOOT_DATA}/EFI/BOOT" - mkdir -p "${BOOT_DATA}/EFI/barebox" - cp "${BINARIES_DIR}/barebox.bin" "${BOOT_DATA}/EFI/BOOT/BOOTx64.EFI" - cp "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi.dtb" "${BOOT_DATA}/EFI/barebox/state.dtb" - cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" + cp "${BOARD_DIR}/../grub.cfg" "${EFIPART_DATA}/EFI/BOOT/grub.cfg" + cp "${BOARD_DIR}/cmdline.txt" "${EFIPART_DATA}/cmdline.txt" + grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv" create + + cp -r "${EFIPART_DATA}/"* "${BOOT_DATA}/" } diff --git a/buildroot-external/board/pc/generic-x86-64/meta b/buildroot-external/board/pc/generic-x86-64/meta index c7c3cdfae..bd5cd1a5d 100644 --- a/buildroot-external/board/pc/generic-x86-64/meta +++ b/buildroot-external/board/pc/generic-x86-64/meta @@ -1,7 +1,7 @@ BOARD_ID=generic-x86-64 BOARD_NAME="Generic x86-64" CHASSIS=embedded -BOOTLOADER=barebox +BOOTLOADER=grub KERNEL_FILE=bzImage BOOT_SYS=efi BOOT_SPL=false diff --git a/buildroot-external/board/pc/grub.cfg b/buildroot-external/board/pc/grub.cfg new file mode 100644 index 000000000..b731be436 --- /dev/null +++ b/buildroot-external/board/pc/grub.cfg @@ -0,0 +1,59 @@ +set default=99 +set timeout=5 + +set ORDER="A B" +set A_OK=0 +set B_OK=0 +set A_TRY=0 +set B_TRY=0 +set MACHINE_ID="" +load_env + +# select bootable slot +for SLOT in $ORDER; do + if [ "$SLOT" == "A" ]; then + INDEX=0 + OK=$A_OK + TRY=$A_TRY + A_TRY=1 + fi + if [ "$SLOT" == "B" ]; then + INDEX=1 + OK=$B_OK + TRY=$B_TRY + B_TRY=1 + fi + if [ "$OK" -eq 1 -a "$TRY" -eq 0 ]; then + default=$INDEX + break + fi +done + +# reset booted flags +if [ "$default" -eq 99 ]; then + if [ "$A_OK" -eq 1 -a "$A_TRY" -eq 1 ]; then + A_TRY=0 + fi + if [ "$B_OK" -eq 1 -a "$B_TRY" -eq 1 ]; then + B_TRY=0 + fi + default=0 +fi + +save_env A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID + +default_cmdline="rootwait zram.enabled=1 zram.num_devices=3 apparmor=1 security=apparmor systemd.machine_id=$MACHINE_ID cgroup_enable=memory fsck.repair=yes" +file_env -f ($root)/cmdline.txt cmdline + +# root is a full HDD/partition definition in GRUB format like hd0,gpt1 +# We extract the part before the comma to then append our own partition index +# at the end. This is hacky but the best way I found +regexp --set 1:boothd (.+),.+ ${root} + +menuentry "Slot A (OK=$A_OK TRY=$A_TRY)" { + linux (${boothd},gpt2)/bzImage root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd $default_cmdline $cmdline rauc.slot=A +} + +menuentry "Slot B (OK=$B_OK TRY=$B_TRY)" { + linux (${boothd},gpt4)/bzImage root=PARTUUID=a3ec664e-32ce-4665-95ea-7ae90ce9aa20 $default_cmdline $cmdline rauc.slot=B +} diff --git a/buildroot-external/board/pc/ova/hassos-hook.sh b/buildroot-external/board/pc/ova/hassos-hook.sh index 24fe6e923..119a7fe3b 100755 --- a/buildroot-external/board/pc/ova/hassos-hook.sh +++ b/buildroot-external/board/pc/ova/hassos-hook.sh @@ -3,13 +3,15 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" + local EFIPART_DATA="${BINARIES_DIR}/efi-part" mkdir -p "${BOOT_DATA}/EFI/BOOT" - mkdir -p "${BOOT_DATA}/EFI/barebox" - cp "${BINARIES_DIR}/barebox.bin" "${BOOT_DATA}/EFI/BOOT/BOOTx64.EFI" - cp "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi.dtb" "${BOOT_DATA}/EFI/barebox/state.dtb" - cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" + cp "${BOARD_DIR}/../grub.cfg" "${EFIPART_DATA}/EFI/BOOT/grub.cfg" + cp "${BOARD_DIR}/cmdline.txt" "${EFIPART_DATA}/cmdline.txt" + grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv" create + + cp -r "${EFIPART_DATA}/"* "${BOOT_DATA}/" } diff --git a/buildroot-external/board/pc/ova/meta b/buildroot-external/board/pc/ova/meta index ed5c962a5..1b55573eb 100644 --- a/buildroot-external/board/pc/ova/meta +++ b/buildroot-external/board/pc/ova/meta @@ -1,7 +1,7 @@ BOARD_ID=ova BOARD_NAME="Open Virtual Appliance" CHASSIS=vm -BOOTLOADER=barebox +BOOTLOADER=grub KERNEL_FILE=bzImage BOOT_SYS=efi BOOT_SPL=false diff --git a/buildroot-external/board/pc/patches/rauc/0001-add-i-argument-to.patch b/buildroot-external/board/pc/patches/rauc/0001-add-i-argument-to.patch deleted file mode 100644 index 6ab580a7c..000000000 --- a/buildroot-external/board/pc/patches/rauc/0001-add-i-argument-to.patch +++ /dev/null @@ -1,36 +0,0 @@ -From c9d56ea8fccf72e1c5d1f224f965e1a8e84d1b7f Mon Sep 17 00:00:00 2001 -From: Pascal Vizeli -Date: Wed, 9 May 2018 21:54:58 +0200 -Subject: [PATCH 1/1] add -i argument to barebox-state call - ---- - src/bootchooser.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/src/bootchooser.c b/src/bootchooser.c -index d5efc0c..c57c2f7 100644 ---- a/src/bootchooser.c -+++ b/src/bootchooser.c -@@ -77,6 +77,9 @@ static gboolean barebox_state_get(const gchar* bootname, BareboxSlotState *bb_st - g_ptr_array_add(args, g_strdup_printf(BOOTSTATE_PREFIX ".%s.priority", bootname)); - g_ptr_array_add(args, g_strdup("-g")); - g_ptr_array_add(args, g_strdup_printf(BOOTSTATE_PREFIX ".%s.remaining_attempts", bootname)); -+ -+ g_ptr_array_add(args, g_strdup("-i")); -+ g_ptr_array_add(args, g_strdup("/etc/barebox-state.dtb")); - g_ptr_array_add(args, NULL); - - sub = g_subprocess_newv((const gchar * const *)args->pdata, -@@ -170,6 +173,9 @@ static gboolean barebox_state_set(GPtrArray *pairs, GError **error) - g_ptr_array_add(args, g_strdup("-s")); - g_ptr_array_add(args, g_strdup(pairs->pdata[i])); - } -+ -+ g_ptr_array_add(args, g_strdup("-i")); -+ g_ptr_array_add(args, g_strdup("/etc/barebox-state.dtb")); - g_ptr_array_add(args, NULL); - - sub = g_subprocess_newv((const gchar * const *)args->pdata, --- -2.7.4 - diff --git a/buildroot-external/bootloader/barebox-state-efi.dtb b/buildroot-external/bootloader/barebox-state-efi.dtb deleted file mode 100644 index 58d2cf9ec..000000000 Binary files a/buildroot-external/bootloader/barebox-state-efi.dtb and /dev/null differ diff --git a/buildroot-external/bootloader/barebox-state-efi.dts b/buildroot-external/bootloader/barebox-state-efi.dts deleted file mode 100644 index 8d2705f8e..000000000 --- a/buildroot-external/bootloader/barebox-state-efi.dts +++ /dev/null @@ -1,76 +0,0 @@ -/dts-v1/; -/ { - - aliases { - state = &state; - }; - - state: state { - #address-cells = <1>; - #size-cells = <1>; - - magic = <0xef98423f>; - compatible = "barebox,state"; - backend = <&backend_state>; - backend-type = "raw"; - backend-stridesize = <4048>; - - bootstate { - #address-cells = <1>; - #size-cells = <1>; - - A { - #address-cells = <1>; - #size-cells = <1>; - remaining_attempts@0 { - reg = <0x0 0x4>; - type = "uint32"; - default = <3>; - }; - priority@4 { - reg = <0x4 0x4>; - type = "uint32"; - default = <20>; - }; - }; - - B { - #address-cells = <1>; - #size-cells = <1>; - remaining_attempts@8 { - reg = <0x8 0x4>; - type = "uint32"; - default = <0>; - }; - priority@c { - reg = <0xc 0x4>; - type = "uint32"; - default = <10>; - }; - }; - - last_chosen@10 { - reg = <0x10 0x4>; - type = "uint32"; - }; - }; - - machine_id@14 { - reg = <0x14 0x24>; - type = "string"; - default = ""; - }; - }; - - partitions { - #address-cells = <1>; - #size-cells = <1>; - compatible = "fixed-partitions"; - - backend_state: state { - partuuid = "33236519-7f32-4dff-8002-3390b62c309d"; - }; - }; - -}; - diff --git a/buildroot-external/bootloader/barebox.config b/buildroot-external/bootloader/barebox.config deleted file mode 100644 index 86467bdb7..000000000 --- a/buildroot-external/bootloader/barebox.config +++ /dev/null @@ -1,54 +0,0 @@ -# CONFIG_LOCALVERSION_AUTO is not set -# CONFIG_CMD_VERSION is not set -# CONFIG_TIMESTAMP is not set - -CONFIG_PROMPT="HAOS-boot:" -CONFIG_CMDLINE_EDITING=y -CONFIG_AUTO_COMPLETE=y -CONFIG_MENU=y -CONFIG_BOOTM_SHOW_TYPE=y -CONFIG_BOOTM_OFTREE=y -CONFIG_FLEXIBLE_BOOTARGS=y -CONFIG_DEFAULT_COMPRESSION_LZ4=y - -# CONFIG_PARTITION_DISK_DOS is not set -CONFIG_PARTITION_DISK_EFI=y -# CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE is not set -# CONFIG_PARTITION_DISK_EFI_GPT_COMPARE is not set - -CONFIG_STATE=y -CONFIG_STATE_DRV=y -CONFIG_BOOTCHOOSER=y -CONFIG_RESET_SOURCE=y -CONFIG_CMD_BOOT=y -CONFIG_CMD_RESET=y -CONFIG_CMD_BOOTCHOOSER=y -CONFIG_CMD_NV=y -CONFIG_CMD_EXPORT=y -CONFIG_CMD_GLOBAL=y -CONFIG_CMD_BASENAME=y -CONFIG_CMD_DIRNAME=y -CONFIG_CMD_READLINK=y -CONFIG_CMD_GETOPT=y -CONFIG_CMD_READF=y -CONFIG_CMD_ECHO_E=y -CONFIG_CMD_EDIT=y -CONFIG_CMD_MENUTREE=y -CONFIG_CMD_TIMEOUT=y -CONFIG_CMD_OFTREE=y -CONFIG_CMD_STATE=y - -CONFIG_OFTREE=y -CONFIG_OFTREE_OVERLAY=y - -CONFIG_DISK=y -CONFIG_DISK_WRITE=y -CONFIG_FS_EXT4=y -CONFIG_FS_FAT=y -CONFIG_FS_FAT_WRITE=y -CONFIG_FS_FAT_LFN=y -CONFIG_FS_SQUASHFS=y -CONFIG_SQUASHFS_LZ4=y -CONFIG_SQUASHFS_LZO=y -CONFIG_LZ4_DECOMPRESS=y -CONFIG_LZO_DECOMPRESS=y diff --git a/buildroot-external/bootloader/barebox/bin/init b/buildroot-external/bootloader/barebox/bin/init deleted file mode 100644 index 67a802edb..000000000 --- a/buildroot-external/bootloader/barebox/bin/init +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -export PATH=/env/bin - -# Autostart -for i in /env/init/*; do - . $i -done - -echo "- Hit m for menu or wait for autoboot -" -timeout -a 1 -s -v key - -# Run menu -if [ "${key}" != "m" ]; then - boot -fi - -menutree diff --git a/buildroot-external/bootloader/barebox/boot/system0 b/buildroot-external/bootloader/barebox/boot/system0 deleted file mode 100644 index 7d46681b7..000000000 --- a/buildroot-external/bootloader/barebox/boot/system0 +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -global linux.bootargs.dyn.root="root=PARTUUID=8d3d53e3-6d49-4c38-8349-aff6859e82fd rootfstype=squashfs ro" - -mkdir -p /mnt/system -mount /dev/*disk*.hassos-kernel0 /mnt/system - -global bootm.image="/mnt/system/bzImage" diff --git a/buildroot-external/bootloader/barebox/boot/system1 b/buildroot-external/bootloader/barebox/boot/system1 deleted file mode 100644 index 11519be84..000000000 --- a/buildroot-external/bootloader/barebox/boot/system1 +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -global linux.bootargs.dyn.root="root=PARTUUID=a3ec664e-32ce-4665-95ea-7ae90ce9aa20 rootfstype=squashfs ro" - -mkdir -p /mnt/system -mount /dev/*disk*.hassos-kernel1 /mnt/system - -global bootm.image="/mnt/system/bzImage" diff --git a/buildroot-external/bootloader/barebox/init/bootchooser b/buildroot-external/bootloader/barebox/init/bootchooser deleted file mode 100644 index 39dd9ab03..000000000 --- a/buildroot-external/bootloader/barebox/init/bootchooser +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -global bootchooser.targets -global bootchooser.system0.boot -global bootchooser.system1.boot - -[ -z "${global.bootchooser.targets}" ] && global.bootchooser.targets="system0 system1" -[ -z "${global.bootchooser.system0.boot}" ] && global.bootchooser.system0.boot="system0" -[ -z "${global.bootchooser.system1.boot}" ] && global.bootchooser.system1.boot="system1" diff --git a/buildroot-external/bootloader/barebox/init/cmdline b/buildroot-external/bootloader/barebox/init/cmdline deleted file mode 100644 index b9f43f2bd..000000000 --- a/buildroot-external/bootloader/barebox/init/cmdline +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -global linux.bootargs.base="" -if [ -f /boot/cmdline.txt ]; then - readf /boot/cmdline.txt global.linux.bootargs.base -fi diff --git a/buildroot-external/bootloader/barebox/init/global_bootargs b/buildroot-external/bootloader/barebox/init/global_bootargs deleted file mode 100644 index 183814bb7..000000000 --- a/buildroot-external/bootloader/barebox/init/global_bootargs +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -global linux.bootargs.zram="zram.enabled=1 zram.num_devices=3" -global linux.bootargs.apparmor="apparmor=1 security=apparmor" -global linux.bootargs.misc="rootwait" -global linux.bootargs.systemd="systemd.machine_id=${state.machine_id}" diff --git a/buildroot-external/bootloader/barebox/menu/00-boot-auto/action b/buildroot-external/bootloader/barebox/menu/00-boot-auto/action deleted file mode 100644 index f640fce9d..000000000 --- a/buildroot-external/bootloader/barebox/menu/00-boot-auto/action +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -boot diff --git a/buildroot-external/bootloader/barebox/menu/00-boot-auto/title b/buildroot-external/bootloader/barebox/menu/00-boot-auto/title deleted file mode 100644 index 115f326f8..000000000 --- a/buildroot-external/bootloader/barebox/menu/00-boot-auto/title +++ /dev/null @@ -1 +0,0 @@ -Autoboot diff --git a/buildroot-external/bootloader/barebox/menu/10-boot-A/action b/buildroot-external/bootloader/barebox/menu/10-boot-A/action deleted file mode 100644 index 653da133a..000000000 --- a/buildroot-external/bootloader/barebox/menu/10-boot-A/action +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -global linux.bootargs.bootchooser="bootchooser.active=A" - -boot system0 diff --git a/buildroot-external/bootloader/barebox/menu/10-boot-A/title b/buildroot-external/bootloader/barebox/menu/10-boot-A/title deleted file mode 100644 index f3e92d424..000000000 --- a/buildroot-external/bootloader/barebox/menu/10-boot-A/title +++ /dev/null @@ -1 +0,0 @@ -Boot System 0 diff --git a/buildroot-external/bootloader/barebox/menu/20-boot-B/action b/buildroot-external/bootloader/barebox/menu/20-boot-B/action deleted file mode 100644 index c712352b6..000000000 --- a/buildroot-external/bootloader/barebox/menu/20-boot-B/action +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -global linux.bootargs.bootchooser="bootchooser.active=B" - -boot system1 diff --git a/buildroot-external/bootloader/barebox/menu/20-boot-B/title b/buildroot-external/bootloader/barebox/menu/20-boot-B/title deleted file mode 100644 index 746b6d21e..000000000 --- a/buildroot-external/bootloader/barebox/menu/20-boot-B/title +++ /dev/null @@ -1 +0,0 @@ -Boot System 1 diff --git a/buildroot-external/bootloader/barebox/menu/30-shell/action b/buildroot-external/bootloader/barebox/menu/30-shell/action deleted file mode 100644 index fd5bc2b0c..000000000 --- a/buildroot-external/bootloader/barebox/menu/30-shell/action +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -echo "Enter 'exit' to get back to the menu" - -sh diff --git a/buildroot-external/bootloader/barebox/menu/30-shell/title b/buildroot-external/bootloader/barebox/menu/30-shell/title deleted file mode 100644 index 6567bb2d9..000000000 --- a/buildroot-external/bootloader/barebox/menu/30-shell/title +++ /dev/null @@ -1 +0,0 @@ -Shell diff --git a/buildroot-external/bootloader/barebox/menu/title b/buildroot-external/bootloader/barebox/menu/title deleted file mode 100644 index 2f52daf70..000000000 --- a/buildroot-external/bootloader/barebox/menu/title +++ /dev/null @@ -1 +0,0 @@ -Home Assistant OS boot menu: diff --git a/buildroot-external/bootloader/barebox/nv/boot.default b/buildroot-external/bootloader/barebox/nv/boot.default deleted file mode 100644 index fe1a363da..000000000 --- a/buildroot-external/bootloader/barebox/nv/boot.default +++ /dev/null @@ -1 +0,0 @@ -bootchooser diff --git a/buildroot-external/bootloader/barebox/nv/bootchooser.A.boot b/buildroot-external/bootloader/barebox/nv/bootchooser.A.boot deleted file mode 100644 index cf27226bd..000000000 --- a/buildroot-external/bootloader/barebox/nv/bootchooser.A.boot +++ /dev/null @@ -1 +0,0 @@ -system0 diff --git a/buildroot-external/bootloader/barebox/nv/bootchooser.B.boot b/buildroot-external/bootloader/barebox/nv/bootchooser.B.boot deleted file mode 100644 index 3c81949c4..000000000 --- a/buildroot-external/bootloader/barebox/nv/bootchooser.B.boot +++ /dev/null @@ -1 +0,0 @@ -system1 diff --git a/buildroot-external/bootloader/barebox/nv/bootchooser.state_prefix b/buildroot-external/bootloader/barebox/nv/bootchooser.state_prefix deleted file mode 100644 index 6246412a5..000000000 --- a/buildroot-external/bootloader/barebox/nv/bootchooser.state_prefix +++ /dev/null @@ -1 +0,0 @@ -state.bootstate diff --git a/buildroot-external/bootloader/barebox/nv/bootchooser.targets b/buildroot-external/bootloader/barebox/nv/bootchooser.targets deleted file mode 100644 index 5decc2b6a..000000000 --- a/buildroot-external/bootloader/barebox/nv/bootchooser.targets +++ /dev/null @@ -1 +0,0 @@ -A B diff --git a/buildroot-external/bootloader/barebox/nv/editcmd b/buildroot-external/bootloader/barebox/nv/editcmd deleted file mode 100644 index 50fc2e706..000000000 --- a/buildroot-external/bootloader/barebox/nv/editcmd +++ /dev/null @@ -1 +0,0 @@ -sedit diff --git a/buildroot-external/configs/generic_aarch64_defconfig b/buildroot-external/configs/generic_aarch64_defconfig index f92ca769f..c2dead5b0 100644 --- a/buildroot-external/configs/generic_aarch64_defconfig +++ b/buildroot-external/configs/generic_aarch64_defconfig @@ -137,4 +137,5 @@ BR2_TARGET_GRUB2_INSTALL_TOOLS=y # Filesystem image BR2_TARGET_ROOTFS_SQUASHFS=y +BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y # BR2_TARGET_ROOTFS_TAR is not set diff --git a/buildroot-external/configs/generic_x86_64_defconfig b/buildroot-external/configs/generic_x86_64_defconfig index d7c264ba4..d65b58e1f 100644 --- a/buildroot-external/configs/generic_x86_64_defconfig +++ b/buildroot-external/configs/generic_x86_64_defconfig @@ -104,13 +104,6 @@ BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_TARGET_ROOTFS_SQUASHFS=y BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y # BR2_TARGET_ROOTFS_TAR is not set -BR2_TARGET_BAREBOX=y -BR2_TARGET_BAREBOX_CUSTOM_VERSION=y -BR2_TARGET_BAREBOX_CUSTOM_VERSION_VALUE="2021.05.0" -BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG=y -BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_HASSOS_PATH)/board/pc/barebox.config" -BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/barebox.config" -BR2_TARGET_BAREBOX_CUSTOM_EMBEDDED_ENV_PATH="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/barebox" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_GPTFDISK=y @@ -127,3 +120,9 @@ BR2_PACKAGE_DOSFSTOOLS=y BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y BR2_PACKAGE_RPI_RF_MOD=y BR2_PACKAGE_RTL88X2BU=y + +# Bootloader +BR2_TARGET_GRUB2=y +BR2_TARGET_GRUB2_X86_64_EFI=y +BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat squash4 part_msdos part_gpt normal efi_gop regexp loadenv echo cat test configfile" +BR2_TARGET_GRUB2_INSTALL_TOOLS=y diff --git a/buildroot-external/configs/ova_defconfig b/buildroot-external/configs/ova_defconfig index e7da5d955..cbed8dd6c 100644 --- a/buildroot-external/configs/ova_defconfig +++ b/buildroot-external/configs/ova_defconfig @@ -107,13 +107,6 @@ BR2_PACKAGE_USB_MODESWITCH_DATA=y BR2_TARGET_ROOTFS_SQUASHFS=y BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y # BR2_TARGET_ROOTFS_TAR is not set -BR2_TARGET_BAREBOX=y -BR2_TARGET_BAREBOX_CUSTOM_VERSION=y -BR2_TARGET_BAREBOX_CUSTOM_VERSION_VALUE="2021.05.0" -BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG=y -BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_HASSOS_PATH)/board/pc/barebox.config" -BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/barebox.config" -BR2_TARGET_BAREBOX_CUSTOM_EMBEDDED_ENV_PATH="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/barebox" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y BR2_PACKAGE_HOST_GPTFDISK=y @@ -128,3 +121,9 @@ BR2_PACKAGE_LIBCURL_CURL=y BR2_PACKAGE_DOSFSTOOLS=y BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y BR2_PACKAGE_RPI_RF_MOD=y + +# Bootloader +BR2_TARGET_GRUB2=y +BR2_TARGET_GRUB2_X86_64_EFI=y +BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat squash4 part_msdos part_gpt normal efi_gop regexp loadenv echo cat test configfile" +BR2_TARGET_GRUB2_INSTALL_TOOLS=y diff --git a/buildroot-external/patches/grub2/0001-loadenv-add-file_env-to-load-var-from-file.patch b/buildroot-external/patches/grub2/0001-loadenv-add-file_env-to-load-var-from-file.patch new file mode 100644 index 000000000..83b3819ea --- /dev/null +++ b/buildroot-external/patches/grub2/0001-loadenv-add-file_env-to-load-var-from-file.patch @@ -0,0 +1,119 @@ +From ee4adaa04e3ac1a5d20ad713a0133382c35da5a1 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Stefan Agner +Date: Thu, 24 Feb 2022 12:38:48 +0100 +Subject: [PATCH] loadenv: add file_env to load var from file + +Introduce file_env which allows to load the value of a variable from a +file. The variable value is terminated at the first non-printable +character. +--- + grub-core/commands/loadenv.c | 73 +++++++++++++++++++++++++++++++++++- + 1 file changed, 72 insertions(+), 1 deletion(-) + +diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c +index 3fd664aac..7e7b18139 100644 +--- a/grub-core/commands/loadenv.c ++++ b/grub-core/commands/loadenv.c +@@ -40,6 +40,14 @@ static const struct grub_arg_option options[] = + {0, 0, 0, 0, 0, 0} + }; + ++static const struct grub_arg_option options_file_env[] = ++ { ++ /* TRANSLATORS: This option is used to override default filename ++ for loading and storing environment. */ ++ {"file", 'f', 0, N_("Specify filename."), 0, ARG_TYPE_PATHNAME}, ++ {0, 0, 0, 0, 0, 0} ++ }; ++ + /* Opens 'filename' with compression filters disabled. Optionally disables the + PUBKEY filter (that insists upon properly signed files) as well. PUBKEY + filter is restored before the function returns. */ +@@ -442,7 +450,64 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args) + return grub_errno; + } + +-static grub_extcmd_t cmd_load, cmd_list, cmd_save; ++static grub_err_t ++grub_cmd_file_env (grub_extcmd_context_t ctxt, int argc, char **args) ++{ ++ grub_off_t offset = 0; ++ struct grub_arg_list *state = ctxt->state; ++ grub_file_t file; ++ grub_size_t size; ++ char *buf; ++ ++ if (argc != 1) ++ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable name expected")); ++ ++ /* state[0] is the -f flag; state[1] is the --skip-sig flag */ ++ file = open_envblk_file ((state[0].set) ? state[0].arg : 0, ++ GRUB_FILE_TYPE_CAT); ++ if (! file) ++ return grub_errno; ++ ++ size = grub_file_size (file); ++ buf = grub_malloc (size + 1); ++ if (! buf) ++ goto fail; ++ ++ /* make sure buffer is terminated in any case */ ++ buf[size] = '\0'; ++ while (size > 0) ++ { ++ grub_ssize_t ret; ++ ++ ret = grub_file_read (file, buf + offset, size); ++ if (ret <= 0) ++ goto fail; ++ ++ /* terminate at the first non-printable character */ ++ while (ret) ++ { ++ if (!grub_isprint(buf[offset])) ++ { ++ buf[offset] = '\0'; ++ size = 0; ++ break; ++ } ++ ++ ret--; ++ size--; ++ offset++; ++ } ++ } ++ ++ grub_env_set (args[0], buf); ++ ++ fail: ++ grub_free (buf); ++ grub_file_close (file); ++ return grub_errno; ++} ++ ++static grub_extcmd_t cmd_load, cmd_list, cmd_save, cmd_file; + + GRUB_MOD_INIT(loadenv) + { +@@ -460,6 +525,11 @@ GRUB_MOD_INIT(loadenv) + N_("[-f FILE] variable_name [...]"), + N_("Save variables to environment block file."), + options); ++ cmd_file = ++ grub_register_extcmd ("file_env", grub_cmd_file_env, 0, ++ N_("[-f FILE] variable_name"), ++ N_("Set variable to content of a file."), ++ options_file_env); + } + + GRUB_MOD_FINI(loadenv) +@@ -467,4 +537,5 @@ GRUB_MOD_FINI(loadenv) + grub_unregister_extcmd (cmd_load); + grub_unregister_extcmd (cmd_list); + grub_unregister_extcmd (cmd_save); ++ grub_unregister_extcmd (cmd_file); + } +-- +2.35.1 + diff --git a/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists b/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists index df8dbe62b..925e58c2c 100755 --- a/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists +++ b/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists @@ -27,16 +27,4 @@ elif [ -e /usr/bin/grub-editenv ]; then echo "[INFO] machine-id is okay" fi -### -# Barebox -else - - # machine-id - if [ "$(barebox-state -g state.machine_id -i /etc/barebox-state.dtb)" != "${MACHINE_ID}" ]; then - echo "[INFO] set machine-id to ${MACHINE_ID}" - barebox-state -s "state.machine_id=${MACHINE_ID}" -i /etc/barebox-state.dtb - else - echo "[INFO] machine-id is okay" - fi - fi diff --git a/buildroot-external/scripts/rauc.sh b/buildroot-external/scripts/rauc.sh index dd9b8ca33..7924f58d3 100755 --- a/buildroot-external/scripts/rauc.sh +++ b/buildroot-external/scripts/rauc.sh @@ -84,8 +84,6 @@ function install_bootloader_config() { if [ "${BOOTLOADER}" == "uboot" ]; then # shellcheck disable=SC1117 echo -e "/dev/disk/by-partlabel/hassos-bootstate\t0x0000\t${BOOT_ENV_SIZE}" > "${TARGET_DIR}/etc/fw_env.config" - elif [ "${BOOTLOADER}" == "barebox" ]; then - cp -f "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi.dtb" "${TARGET_DIR}/etc/barebox-state.dtb" fi # Fix MBR