Skip to content

Commit

Permalink
Use GRUB bootloader for all UEFI platforms (#1762)
Browse files Browse the repository at this point in the history
* Use GRUB bootloader for all UEFI platforms
* Introduce and use file_env command
* Compress squashfs for aarch64 as well
  • Loading branch information
agners committed Feb 24, 2022
1 parent b0bbe70 commit d1cc739
Show file tree
Hide file tree
Showing 39 changed files with 207 additions and 300 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cmdline=""
console=tty1 console=ttyS0
2 changes: 1 addition & 1 deletion buildroot-external/board/arm-uefi/generic-aarch64/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions buildroot-external/board/pc/barebox.config

This file was deleted.

10 changes: 6 additions & 4 deletions buildroot-external/board/pc/generic-x86-64/hassos-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"
}


Expand Down
2 changes: 1 addition & 1 deletion buildroot-external/board/pc/generic-x86-64/meta
Original file line number Diff line number Diff line change
@@ -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
Expand Down
59 changes: 59 additions & 0 deletions buildroot-external/board/pc/grub.cfg
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 6 additions & 4 deletions buildroot-external/board/pc/ova/hassos-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"
}


Expand Down
2 changes: 1 addition & 1 deletion buildroot-external/board/pc/ova/meta
Original file line number Diff line number Diff line change
@@ -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
Expand Down

This file was deleted.

Binary file removed buildroot-external/bootloader/barebox-state-efi.dtb
Binary file not shown.
76 changes: 0 additions & 76 deletions buildroot-external/bootloader/barebox-state-efi.dts

This file was deleted.

54 changes: 0 additions & 54 deletions buildroot-external/bootloader/barebox.config

This file was deleted.

18 changes: 0 additions & 18 deletions buildroot-external/bootloader/barebox/bin/init

This file was deleted.

8 changes: 0 additions & 8 deletions buildroot-external/bootloader/barebox/boot/system0

This file was deleted.

8 changes: 0 additions & 8 deletions buildroot-external/bootloader/barebox/boot/system1

This file was deleted.

9 changes: 0 additions & 9 deletions buildroot-external/bootloader/barebox/init/bootchooser

This file was deleted.

6 changes: 0 additions & 6 deletions buildroot-external/bootloader/barebox/init/cmdline

This file was deleted.

6 changes: 0 additions & 6 deletions buildroot-external/bootloader/barebox/init/global_bootargs

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions buildroot-external/bootloader/barebox/menu/10-boot-A/action

This file was deleted.

1 change: 0 additions & 1 deletion buildroot-external/bootloader/barebox/menu/10-boot-A/title

This file was deleted.

5 changes: 0 additions & 5 deletions buildroot-external/bootloader/barebox/menu/20-boot-B/action

This file was deleted.

1 change: 0 additions & 1 deletion buildroot-external/bootloader/barebox/menu/20-boot-B/title

This file was deleted.

5 changes: 0 additions & 5 deletions buildroot-external/bootloader/barebox/menu/30-shell/action

This file was deleted.

Loading

0 comments on commit d1cc739

Please sign in to comment.