mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-07-23 21:16:30 +00:00
Implement A/B switch when moving back to Barebox (#1794)
* Implement manual boot switch when downgrading to Barebox When installing OS 7 or older from a OS 8 installation, the bootloader is changed back to Barebox. However, in this case Barebox does not know which boot slot is correct (and rauc won't update Barebox' state as it is configured to work with GRUB in OS 8+). This implements a poor mans version to switch the boot partition. It clears Barebox state and deploys one of the two pre-configured default states, booting either boot slot A or B.
This commit is contained in:
parent
bd8c6cad40
commit
aaa55848de
@ -9,6 +9,8 @@ function hassos_pre_image() {
|
|||||||
|
|
||||||
cp "${BINARIES_DIR}/barebox.bin" "${BOOT_DATA}/EFI/BOOT/BOOTx64.EFI"
|
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 "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi.dtb" "${BOOT_DATA}/EFI/barebox/state.dtb"
|
||||||
|
cp "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi-A.dtb" "${BOOT_DATA}/EFI/barebox/state-A.dtb"
|
||||||
|
cp "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi-B.dtb" "${BOOT_DATA}/EFI/barebox/state-B.dtb"
|
||||||
cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt"
|
cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ function hassos_pre_image() {
|
|||||||
|
|
||||||
cp "${BINARIES_DIR}/barebox.bin" "${BOOT_DATA}/EFI/BOOT/BOOTx64.EFI"
|
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 "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi.dtb" "${BOOT_DATA}/EFI/barebox/state.dtb"
|
||||||
|
cp "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi-A.dtb" "${BOOT_DATA}/EFI/barebox/state-A.dtb"
|
||||||
|
cp "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/barebox-state-efi-B.dtb" "${BOOT_DATA}/EFI/barebox/state-B.dtb"
|
||||||
cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt"
|
cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
buildroot-external/bootloader/barebox-state-efi-A.dtb
Normal file
BIN
buildroot-external/bootloader/barebox-state-efi-A.dtb
Normal file
Binary file not shown.
76
buildroot-external/bootloader/barebox-state-efi-A.dts
Normal file
76
buildroot-external/bootloader/barebox-state-efi-A.dts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
BIN
buildroot-external/bootloader/barebox-state-efi-B.dtb
Normal file
BIN
buildroot-external/bootloader/barebox-state-efi-B.dtb
Normal file
Binary file not shown.
76
buildroot-external/bootloader/barebox-state-efi-B.dts
Normal file
76
buildroot-external/bootloader/barebox-state-efi-B.dts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/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 = <10>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
B {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
remaining_attempts@8 {
|
||||||
|
reg = <0x8 0x4>;
|
||||||
|
type = "uint32";
|
||||||
|
default = <3>;
|
||||||
|
};
|
||||||
|
priority@c {
|
||||||
|
reg = <0xc 0x4>;
|
||||||
|
type = "uint32";
|
||||||
|
default = <20>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -28,6 +28,25 @@ case "$1" in
|
|||||||
slot-install)
|
slot-install)
|
||||||
# Use install handlers below
|
# Use install handlers below
|
||||||
;;
|
;;
|
||||||
|
slot-post-install)
|
||||||
|
# Handle main slot only
|
||||||
|
test "${RAUC_SLOT_CLASS}" = "kernel" || exit 0
|
||||||
|
|
||||||
|
BOOT_MNT=/mnt/boot
|
||||||
|
|
||||||
|
if ! systemctl -q is-active mnt-boot.mount; then
|
||||||
|
systemctl start mnt-boot.mount
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OS 8+ to 7 and lower downgrade path
|
||||||
|
if ! command -v barebox-state > /dev/null; then
|
||||||
|
cp -f "${BOOT_MNT}/EFI/barebox/state-${RAUC_SLOT_BOOTNAME}.dtb" "${BOOT_MNT}"/EFI/barebox/state.dtb
|
||||||
|
blkdiscard /dev/disk/by-partuuid/33236519-7f32-4dff-8002-3390b62c309d
|
||||||
|
echo "Cleared state and copied default state-${RAUC_SLOT_BOOTNAME}.dtb to state.dtb."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -38,6 +38,9 @@ function create_ota_update() {
|
|||||||
echo "hooks=install"
|
echo "hooks=install"
|
||||||
echo "[image.kernel]"
|
echo "[image.kernel]"
|
||||||
echo "filename=kernel.img"
|
echo "filename=kernel.img"
|
||||||
|
if [ "${BOOTLOADER}" == "barebox" ]; then
|
||||||
|
echo "hooks=post-install"
|
||||||
|
fi
|
||||||
echo "[image.rootfs]"
|
echo "[image.rootfs]"
|
||||||
echo "filename=rootfs.img"
|
echo "filename=rootfs.img"
|
||||||
) > "${rauc_folder}/manifest.raucm"
|
) > "${rauc_folder}/manifest.raucm"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user