From f00ce5ca9b118df6fb318f63112a078dd671ea41 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Mon, 23 Aug 2021 13:26:24 +0200 Subject: [PATCH] u-boot-dey: add support for dualboot to boot scripts The support for dualboot was integrated on meta-digi-dualboot layer, but it really depends only on environment variable 'dualboot' so we'd better integrate the support on the scripts in meta-digi, to avoid synchonization problems between both layers. This also allows to be able to easily enable dualboot in U-Boot with the variable, without needing to update the script on the linux partition. Signed-off-by: Hector Palacios --- .../u-boot/u-boot-dey/ccimx6qpsbc/boot.txt | 75 +++++++++++++--- .../u-boot/u-boot-dey/ccimx6sbc/boot.txt | 75 +++++++++++++--- .../u-boot/u-boot-dey/ccimx6ulsbc/boot.txt | 42 ++++++++- .../u-boot-dey/ccimx6ulstarter/boot.txt | 42 ++++++++- .../u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt | 88 ++++++++++++++++--- .../u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 88 ++++++++++++++++--- .../u-boot-dey/ccimx8x-sbc-express/boot.txt | 83 ++++++++++++++--- .../u-boot-dey/ccimx8x-sbc-pro/boot.txt | 83 ++++++++++++++--- 8 files changed, 496 insertions(+), 80 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index 2ae28ea4a..5dedaa36d 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -25,19 +25,70 @@ else fi fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index e15593d2c..12b927abd 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -53,19 +53,70 @@ else fi fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index 03b3f7929..b3ddefaf9 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -37,11 +37,45 @@ else fi fi -if test "${mtdbootpart}" = "recovery"; then - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${mtdbootpart}" = "linux_a"; then + setenv mtdbootpart linux_b + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + else + setenv mtdbootpart linux_a + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + fi + setenv active_system ${mtdbootpart} + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + else + echo "Booting from system B" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + fi + fi else - true + if test "${mtdbootpart}" = "recovery"; then + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + true + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux nand ${mtdbootpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index 31825889d..84da4dfde 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -37,11 +37,45 @@ else fi fi -if test "${mtdbootpart}" = "recovery"; then - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${mtdbootpart}" = "linux_a"; then + setenv mtdbootpart linux_b + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + else + setenv mtdbootpart linux_a + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + fi + setenv active_system ${mtdbootpart} + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_a_index} + setenv mtdrootfsindex ${mtdrootfs_a_index} + else + echo "Booting from system B" + setenv mtdbootpart ${active_system} + setenv mtdlinuxindex ${mtdlinux_b_index} + setenv mtdrootfsindex ${mtdrootfs_b_index} + fi + fi else - true + if test "${mtdbootpart}" = "recovery"; then + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + true + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux nand ${mtdbootpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt index ff9e9e163..1513df9e9 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -6,6 +6,19 @@ setenv ORIG_overlays ${overlays} setenv ORIG_extra_bootargs ${extra_bootargs} +# Set SOC type to "imx8mm" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mm" +fi + +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -28,19 +41,70 @@ if test -n "${module_ram}"; then fi fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index 38530dcaf..7b7df5917 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -6,6 +6,19 @@ setenv ORIG_overlays ${overlays} setenv ORIG_extra_bootargs ${extra_bootargs} +# Set SOC type to "imx8mn" if not already defined by U-Boot +if test ! -n "${soc_type}"; then + setenv soc_type "imx8mn" +fi + +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -37,19 +50,70 @@ if test "${board_version}" -lt "3"; then setenv overlays _ov_board_v1-v2_ccimx8mn-dvk.dtbo,${overlays} fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt index 278914bcd..b99b3378b 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt @@ -11,6 +11,14 @@ if test ! -n "${soc_type}"; then setenv soc_type "imx8qxp" fi +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -45,19 +53,70 @@ if test "${soc_type}" = "imx8qxp"; then setenv overlays _ov_som_quad_ccimx8x.dtbo,${overlays} fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt index 481c8cc2d..759308337 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt @@ -11,6 +11,14 @@ if test ! -n "${soc_type}"; then setenv soc_type "imx8qxp" fi +# Reset overlays when using dualboot mode, because we need to +# save the environment in case of an installation fall back. +if test "${dual_boot}" = "yes"; then + if test -n "${overlays}"; then + setenv overlays + fi +fi + # # Determine overlays to apply depending on the hardware capabilities # described by the HWID, SOM version, and carrier board version. @@ -50,19 +58,70 @@ if test "${board_version}" -le "3"; then setenv overlays _ov_board_v1-v3_ccimx8x-sbc-pro.dtbo,${overlays} fi -# Get the UUID of the configured boot partition. -part uuid mmc ${mmcbootdev}:${mmcpart} bootpart -# Check the boot source. -if test "${bootpart}" = "${part1_uuid}"; then - # We are booting from the eMMC using 'linux'. - true -elif test "${bootpart}" = "${part2_uuid}"; then - # We are booting from the eMMC using 'recovery'. - setenv boot_initrd true - setenv initrd_file uramdisk-recovery.img +# Dual boot update verification +if test "${dualboot}" = "yes"; then + if test "${upgrade_available}" = "1"; then + echo "Update detected; Booting new system (try ${bootcount})" + if test "${bootcount}" = "${bootlimit}"; then + echo "## Update failed; Rolling back to previous version." + if test "${active_system}" = "linux_a"; then + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + setenv active_system linux_b + else + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + setenv active_system linux_a + fi + setenv upgrade_available + saveenv + fi + else + if test "${active_system}" = "linux_a"; then + echo "Booting from system A" + part number mmc ${mmcbootdev} linux_a pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_a_index + part number mmc ${mmcbootdev} rootfs_a rootfs_a_index + # Save the rootfs_a UUID into mmcroot_a + part uuid mmc ${mmcbootdev}:${rootfs_a_index} mmcroot_a + setenv mmcroot PARTUUID=${mmcroot_a} + else + echo "Booting from system B" + part number mmc ${mmcbootdev} linux_b pi + setenv mmcpart ${pi} + # Save the partition index on variable rootfs_b_index + part number mmc ${mmcbootdev} rootfs_b rootfs_b_index + # Save the rootfs_b UUID into mmcroot_b + part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b + setenv mmcroot PARTUUID=${mmcroot_b} + fi + fi else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # Get the UUID of the configured boot partition. + part uuid mmc ${mmcbootdev}:${mmcpart} bootpart + # Check the boot source. + if test "${bootpart}" = "${part1_uuid}"; then + # We are booting from the eMMC using 'linux'. + true + elif test "${bootpart}" = "${part2_uuid}"; then + # We are booting from the eMMC using 'recovery'. + setenv boot_initrd true + setenv initrd_file uramdisk-recovery.img + else + # We are booting from the SD card. + setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + fi fi setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs} dboot linux mmc ${mmcbootdev}:${mmcpart}