Skip to content
Snippets Groups Projects
Commit 93739185 authored by Denis Pynkin's avatar Denis Pynkin
Browse files

lib: rework check_bootcounter to support legacy


New `uboot.cnt` file format appears in u-boot 2019.01+dfsg-7co7.
Allow to read legacy format.
If "magic" and "version" are not requested explicitly the function
accept any supported `uboot.cnt` format.

Signed-off-by: default avatarDenis Pynkin <denis.pynkin@collabora.com>
parent 81fde04c
No related branches found
No related tags found
3 merge requests!24Apply all changes from v2021pre,!23Backport refactoring ostree upgrade tests 2022dev1 -> v2021pre,!22Refactoring ostree upgrade tests
......@@ -51,7 +51,7 @@ phase_check_update()
# Check the bootcounter state
# It may have different boot count on different boards due LAVA
check_bootcounter bd 01 "" 01
check_bootcounter "" "" "" 01
# Emulate the ugrade state -- set the upgrade flag and bootcounter to any value above the limit
# This should to trigger the U-Boot to boot previous version after reboot
......@@ -81,7 +81,7 @@ phase_check_rollback()
# after the rollback, the apertis update manager resets the bootcount
# Ensure to have non-upgrade state
check_bootcounter bd 01 00 00
check_bootcounter "" "" 00 00
# Must exists and contain "failed" upgrade
cat /var/aum_blacklist.conf
......
......@@ -19,7 +19,7 @@ phase_boot()
ostree admin status
# Ensure to have upgrade state
check_bootcounter bd 01 00 01
check_bootcounter "" "" 00 01
}
phase_check_update()
......@@ -43,7 +43,7 @@ phase_check_update()
# Check the bootcounter state
# It may have different boot count on different boards due LAVA
check_bootcounter bd 01 "" 01
check_bootcounter "" "" "" 01
# Emulate the ugrade state -- set the upgrade flag and bootcounter to any value above the limit
# This should to trigger the U-Boot to boot previous version after reboot
......@@ -73,7 +73,7 @@ phase_check_rollback()
# after the rollback, the apertis update manager resets the bootcount
# Ensure to have non-upgrade state
check_bootcounter bd 01 00 00
check_bootcounter "" "" 00 00
cat /var/aum_blacklist.conf
}
......
......@@ -316,6 +316,17 @@ check_bootcounter()
od -t x1 -An /boot/uboot.cnt | (
read -r m ver cnt uflag
# Special case for old format
if [ "$m" = "bc" ]; then
cnt="$ver"
ver="00"
# NB: due the bug in legacy U-Boot -- it always create the uboot.cnt and
# increase the counter, so it is not possible to detect the upgrade
# state properly. Hence set the upgrade state for the legacy into
# requested value to avoid failures.
uflag="${4:-1}"
fi
local ret=0
local magic="${1:-$m}"
local version="${2:-$ver}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment