boot scripts: print boot attempts only when bootcount mechanism active

Improve boot attempts message showing not only the current boot attempt
but also the limit:
	(boot attempt 1/3)

Print the message only when the bootcount mechanism is active, i.e. when
the bootlimit is defined (not zero), and when bootcount is > 0.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://onedigi.atlassian.net/browse/DUB-1056
This commit is contained in:
Hector Palacios 2023-10-10 09:43:04 +02:00
parent db271b8c77
commit 918a9caf1d
11 changed files with 94 additions and 33 deletions

View File

@ -7,17 +7,22 @@
# and save them, while the rest of the script changes variables only temporarily
# without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot update verification
if test "${dualboot}" = "yes"; then
if test "${upgrade_available}" = "1"; then
echo "Update detected; Booting new system in ${active_system} (try ${bootcount})"
echo "Update detected; Booting new system in ${active_system} ${bootattempt}"
else
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A"
part number mmc ${mmcbootdev} linux_a tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B"
part number mmc ${mmcbootdev} linux_b tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
fi
@ -50,6 +55,9 @@ else
# We are booting from the SD card.
setenv mmcroot /dev/mmcblk${mmcbootdev}p2
fi
if test "${upgrade_available}" = "1"; then
echo "Update detected; Booting new system ${bootattempt}"
fi
fi

View File

@ -7,17 +7,22 @@
# and save them, while the rest of the script changes variables only temporarily
# without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot update verification
if test "${dualboot}" = "yes"; then
if test "${upgrade_available}" = "1"; then
echo "Update detected; Booting new system in ${active_system} (try ${bootcount})"
echo "Update detected; Booting new system in ${active_system} ${bootattempt}"
else
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A"
part number mmc ${mmcbootdev} linux_a tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B"
part number mmc ${mmcbootdev} linux_b tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
fi
@ -50,6 +55,9 @@ else
# We are booting from the SD card.
setenv mmcroot /dev/mmcblk${mmcbootdev}p2
fi
if test "${upgrade_available}" = "1"; then
echo "Update detected; Booting new system ${bootattempt}"
fi
fi

View File

@ -6,14 +6,19 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
setenv tmp_mtdrootfspart ${rootfsvol_a}
setenv tmp_rootfsvol ${rootfsvol_a}
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
setenv tmp_mtdrootfspart ${rootfsvol_b}
setenv tmp_rootfsvol ${rootfsvol_b}
fi
@ -34,7 +39,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
if test "${mtdbootpart}" = "recovery"; then
setenv boot_initrd true
setenv initrd_file uramdisk-recovery.img

View File

@ -6,14 +6,19 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
setenv tmp_mtdrootfspart ${rootfsvol_a}
setenv tmp_rootfsvol ${rootfsvol_a}
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
setenv tmp_mtdrootfspart ${rootfsvol_b}
setenv tmp_rootfsvol ${rootfsvol_b}
fi
@ -34,7 +39,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
if test "${mtdbootpart}" = "recovery"; then
setenv boot_initrd true
setenv initrd_file uramdisk-recovery.img

View File

@ -6,14 +6,19 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
part number mmc ${mmcbootdev} linux_a tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
part number mmc ${mmcbootdev} linux_b tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
fi
@ -31,7 +36,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
# Get the UUID of the configured boot partition.
part uuid mmc ${mmcbootdev}:${mmcpart} bootpart
# Check the boot source.

View File

@ -6,14 +6,19 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
part number mmc ${mmcbootdev} linux_a tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
part number mmc ${mmcbootdev} linux_b tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
fi
@ -31,7 +36,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
# Get the UUID of the configured boot partition.
part uuid mmc ${mmcbootdev}:${mmcpart} bootpart
# Check the boot source.

View File

@ -6,14 +6,19 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
part number mmc ${mmcbootdev} linux_a tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
part number mmc ${mmcbootdev} linux_b tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
fi
@ -31,7 +36,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
# Get the UUID of the configured boot partition.
part uuid mmc ${mmcbootdev}:${mmcpart} bootpart
# Check the boot source.

View File

@ -6,14 +6,19 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
part number mmc ${mmcbootdev} linux_a tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
part number mmc ${mmcbootdev} linux_b tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
fi
@ -31,7 +36,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
# Get the UUID of the configured boot partition.
part uuid mmc ${mmcbootdev}:${mmcpart} bootpart
# Check the boot source.

View File

@ -6,17 +6,22 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Pre step: check if we boot from uSD.
if test "${mmcbootdev}" = "1"; then
# We are booting from the SD card.
setenv mmcroot /dev/mmcblk${mmcbootdev}p2
elif test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
part number mmc ${mmcbootdev} linux_a tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_a tmp_rootfs_index
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
part number mmc ${mmcbootdev} linux_b tmp_mmcpart
part number mmc ${mmcbootdev} rootfs_b tmp_rootfs_index
fi
@ -34,7 +39,7 @@ elif test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
# Get the UUID of the configured boot partition.
part uuid mmc ${mmcbootdev}:${mmcpart} bootpart
# Check the boot source.

View File

@ -6,13 +6,18 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
setenv tmp_rootfsvol ${rootfsvol_a}
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
setenv tmp_rootfsvol ${rootfsvol_b}
fi
if test "${mtdbootpart}" != "${active_system}"; then
@ -28,7 +33,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
# Check the boot source.
if test "${mtdbootpart}" = "linux"; then
# We are booting from the NAND using 'linux'.

View File

@ -6,13 +6,18 @@
# requires the script to change some variables and save them, while the rest
# of the script changes variables only temporarily without saving them.
# Build boot attempt message string
if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then
bootattempt="(boot attempt ${bootcount}/${bootlimit})"
fi
# Dual boot verification
if test "${dualboot}" = "yes"; then
if test "${active_system}" = "linux_a"; then
echo "Booting from system A (try ${bootcount})"
echo "Booting from system A ${bootattempt}"
setenv tmp_rootfsvol ${rootfsvol_a}
else
echo "Booting from system B (try ${bootcount})"
echo "Booting from system B ${bootattempt}"
setenv tmp_rootfsvol ${rootfsvol_b}
fi
if test "${mtdbootpart}" != "${active_system}"; then
@ -28,7 +33,7 @@ if test "${dualboot}" = "yes"; then
env save
fi
else
echo "Booting system (try ${bootcount})"
echo "Booting system ${bootattempt}"
# Check the boot source.
if test "${mtdbootpart}" = "linux"; then
# We are booting from the NAND using 'linux'.