u-boot-dey: boot: update all boot scripts to synchronize boot variables for dualboot systems

Until now, for dualboot systems, all boot variables were calculated on each boot depending on the value of the
'active_system'. These variables are used to boot the device but were not saved, which could lead to a missmatch
between their value in the environment and their required values to correctly boot the system. This commit
simplifies a bit the variables calculation and adds a block to synchronize their value in the environment.

Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
David Escalona 2023-09-04 14:05:08 +02:00
parent 3c9384a99c
commit 910ee4ab44
11 changed files with 187 additions and 118 deletions

View File

@ -13,23 +13,26 @@ if test "${dualboot}" = "yes"; then
echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" echo "Update detected; Booting new system in ${active_system} (try ${bootcount})"
else else
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A" echo "Booting from system A (try ${bootcount})"
part number mmc ${mmcbootdev} linux_a pi part number mmc ${mmcbootdev} linux_a tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
# 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 else
echo "Booting from system B" echo "Booting from system B (try ${bootcount})"
part number mmc ${mmcbootdev} linux_b pi part number mmc ${mmcbootdev} linux_b tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
# Save the partition index on variable rootfs_b_index fi
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot
# Save the rootfs_b UUID into mmcroot_b if test "${mmcpart}" -ne "${tmp_mmcpart}"; then
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b setexpr mmcpart ${tmp_mmcpart}
setenv mmcroot PARTUUID=${mmcroot_b} env_save_needed="1"
fi
if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then
setenv mmcroot PARTUUID=${tmp_mmcroot}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot
env save
fi fi
fi fi
else else

View File

@ -13,23 +13,26 @@ if test "${dualboot}" = "yes"; then
echo "Update detected; Booting new system in ${active_system} (try ${bootcount})" echo "Update detected; Booting new system in ${active_system} (try ${bootcount})"
else else
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A" echo "Booting from system A (try ${bootcount})"
part number mmc ${mmcbootdev} linux_a pi part number mmc ${mmcbootdev} linux_a tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
# 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 else
echo "Booting from system B" echo "Booting from system B (try ${bootcount})"
part number mmc ${mmcbootdev} linux_b pi part number mmc ${mmcbootdev} linux_b tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
# Save the partition index on variable rootfs_b_index fi
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot
# Save the rootfs_b UUID into mmcroot_b if test "${mmcpart}" -ne "${tmp_mmcpart}"; then
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b setexpr mmcpart ${tmp_mmcpart}
setenv mmcroot PARTUUID=${mmcroot_b} env_save_needed="1"
fi
if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then
setenv mmcroot PARTUUID=${tmp_mmcroot}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot
env save
fi fi
fi fi
else else

View File

@ -10,14 +10,28 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
setenv mtdbootpart ${active_system} setenv tmp_mtdrootfspart ${rootfsvol_a}
setenv mtdrootfspart ${rootfsvol_a} setenv tmp_rootfsvol ${rootfsvol_a}
setenv rootfsvol ${rootfsvol_a}
else else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
setenv tmp_mtdrootfspart ${rootfsvol_b}
setenv tmp_rootfsvol ${rootfsvol_b}
fi
if test "${mtdbootpart}" != "${active_system}"; then
setenv mtdbootpart ${active_system} setenv mtdbootpart ${active_system}
setenv mtdrootfspart ${rootfsvol_b} env_save_needed="1"
setenv rootfsvol ${rootfsvol_b} fi
if test "${mtdrootfspart}" != "${tmp_mtdrootfspart}"; then
setenv mtdrootfspart ${tmp_mtdrootfspart}
env_save_needed="1"
fi
if test "${rootfsvol}" != "${tmp_rootfsvol}"; then
setenv rootfsvol ${tmp_rootfsvol}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_rootfsvol tmp_mtdrootfspart
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -10,14 +10,28 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
setenv mtdbootpart ${active_system} setenv tmp_mtdrootfspart ${rootfsvol_a}
setenv mtdrootfspart ${rootfsvol_a} setenv tmp_rootfsvol ${rootfsvol_a}
setenv rootfsvol ${rootfsvol_a}
else else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
setenv tmp_mtdrootfspart ${rootfsvol_b}
setenv tmp_rootfsvol ${rootfsvol_b}
fi
if test "${mtdbootpart}" != "${active_system}"; then
setenv mtdbootpart ${active_system} setenv mtdbootpart ${active_system}
setenv mtdrootfspart ${rootfsvol_b} env_save_needed="1"
setenv rootfsvol ${rootfsvol_b} fi
if test "${mtdrootfspart}" != "${tmp_mtdrootfspart}"; then
setenv mtdrootfspart ${tmp_mtdrootfspart}
env_save_needed="1"
fi
if test "${rootfsvol}" != "${tmp_rootfsvol}"; then
setenv rootfsvol ${tmp_rootfsvol}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_rootfsvol tmp_mtdrootfspart
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -10,22 +10,25 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
part number mmc ${mmcbootdev} linux_a pi part number mmc ${mmcbootdev} linux_a tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
# 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 else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
part number mmc ${mmcbootdev} linux_b pi part number mmc ${mmcbootdev} linux_b tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
# Save the partition index on variable rootfs_b_index fi
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot
# Save the rootfs_b UUID into mmcroot_b if test "${mmcpart}" -ne "${tmp_mmcpart}"; then
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b setexpr mmcpart ${tmp_mmcpart}
setenv mmcroot PARTUUID=${mmcroot_b} env_save_needed="1"
fi
if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then
setenv mmcroot PARTUUID=${tmp_mmcroot}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -10,22 +10,25 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
part number mmc ${mmcbootdev} linux_a pi part number mmc ${mmcbootdev} linux_a tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
# 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 else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
part number mmc ${mmcbootdev} linux_b pi part number mmc ${mmcbootdev} linux_b tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
# Save the partition index on variable rootfs_b_index fi
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot
# Save the rootfs_b UUID into mmcroot_b if test "${mmcpart}" -ne "${tmp_mmcpart}"; then
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b setexpr mmcpart ${tmp_mmcpart}
setenv mmcroot PARTUUID=${mmcroot_b} env_save_needed="1"
fi
if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then
setenv mmcroot PARTUUID=${tmp_mmcroot}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -10,22 +10,25 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
part number mmc ${mmcbootdev} linux_a pi part number mmc ${mmcbootdev} linux_a tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
# 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 else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
part number mmc ${mmcbootdev} linux_b pi part number mmc ${mmcbootdev} linux_b tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
# Save the partition index on variable rootfs_b_index fi
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot
# Save the rootfs_b UUID into mmcroot_b if test "${mmcpart}" -ne "${tmp_mmcpart}"; then
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b setexpr mmcpart ${tmp_mmcpart}
setenv mmcroot PARTUUID=${mmcroot_b} env_save_needed="1"
fi
if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then
setenv mmcroot PARTUUID=${tmp_mmcroot}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -10,22 +10,25 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
part number mmc ${mmcbootdev} linux_a pi part number mmc ${mmcbootdev} linux_a tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
# 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 else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
part number mmc ${mmcbootdev} linux_b pi part number mmc ${mmcbootdev} linux_b tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
# Save the partition index on variable rootfs_b_index fi
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot
# Save the rootfs_b UUID into mmcroot_b if test "${mmcpart}" -ne "${tmp_mmcpart}"; then
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b setexpr mmcpart ${tmp_mmcpart}
setenv mmcroot PARTUUID=${mmcroot_b} env_save_needed="1"
fi
if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then
setenv mmcroot PARTUUID=${tmp_mmcroot}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -13,22 +13,25 @@ if test "${mmcbootdev}" = "1"; then
elif test "${dualboot}" = "yes"; then elif test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
part number mmc ${mmcbootdev} linux_a pi part number mmc ${mmcbootdev} linux_a tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
# 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 else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
part number mmc ${mmcbootdev} linux_b pi part number mmc ${mmcbootdev} linux_b tmp_mmcpart
setenv mmcpart ${pi} part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
# Save the partition index on variable rootfs_b_index fi
part number mmc ${mmcbootdev} rootfs_b rootfs_b_index part uuid mmc ${mmcbootdev}:${tmp_rootfs_index} tmp_mmcroot
# Save the rootfs_b UUID into mmcroot_b if test "${mmcpart}" -ne "${tmp_mmcpart}"; then
part uuid mmc ${mmcbootdev}:${rootfs_b_index} mmcroot_b setexpr mmcpart ${tmp_mmcpart}
setenv mmcroot PARTUUID=${mmcroot_b} env_save_needed="1"
fi
if test "${mmcroot}" != "PARTUUID=${tmp_mmcroot}"; then
setenv mmcroot PARTUUID=${tmp_mmcroot}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_mmcpart tmp_rootfs_index tmp_mmcroot
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -10,12 +10,22 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
setenv mtdbootpart ${active_system} setenv tmp_rootfsvol ${rootfsvol_a}
setenv rootfsvol ${rootfsvol_a}
else else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
setenv tmp_rootfsvol ${rootfsvol_b}
fi
if test "${mtdbootpart}" != "${active_system}"; then
setenv mtdbootpart ${active_system} setenv mtdbootpart ${active_system}
setenv rootfsvol ${rootfsvol_b} env_save_needed="1"
fi
if test "${rootfsvol}" != "${tmp_rootfsvol}"; then
setenv rootfsvol ${tmp_rootfsvol}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_rootfsvol
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"

View File

@ -10,12 +10,22 @@
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})" echo "Booting from system A (try ${bootcount})"
setenv mtdbootpart ${active_system} setenv tmp_rootfsvol ${rootfsvol_a}
setenv rootfsvol ${rootfsvol_a}
else else
echo "Booting from system B (try ${bootcount})" echo "Booting from system B (try ${bootcount})"
setenv tmp_rootfsvol ${rootfsvol_b}
fi
if test "${mtdbootpart}" != "${active_system}"; then
setenv mtdbootpart ${active_system} setenv mtdbootpart ${active_system}
setenv rootfsvol ${rootfsvol_b} env_save_needed="1"
fi
if test "${rootfsvol}" != "${tmp_rootfsvol}"; then
setenv rootfsvol ${tmp_rootfsvol}
env_save_needed="1"
fi
if test "${env_save_needed}" = "1"; then
env delete tmp_rootfsvol
env save
fi fi
else else
echo "Booting system (try ${bootcount})" echo "Booting system (try ${bootcount})"