Use GRUB bootloader for all UEFI platforms (#1762)

* Use GRUB bootloader for all UEFI platforms
* Introduce and use file_env command
* Compress squashfs for aarch64 as well
This commit is contained in:
Stefan Agner
2022-02-24 13:42:17 +01:00
committed by GitHub
parent b0bbe70315
commit d1cc7394b5
39 changed files with 207 additions and 300 deletions

View File

@@ -1 +1 @@
cmdline=""
console=tty1 console=ttyS0

View File

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

View File

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

View File

@@ -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}/"
}

View File

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

View File

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

View File

@@ -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}/"
}

View File

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

View File

@@ -1,36 +0,0 @@
From c9d56ea8fccf72e1c5d1f224f965e1a8e84d1b7f Mon Sep 17 00:00:00 2001
From: Pascal Vizeli <pvizeli@syshack.ch>
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