Easily collecting state after rollback

8 views
Skip to first unread message

Jan Kiszka

unread,
Feb 21, 2023, 1:59:27 AM2/21/23
to efibootguard-dev, Christian Storm, Adler, Michael (CT RDA IOT SES-DE)
Hi,

Christian and I discussed if we should simplify the state extraction
after a failed update, i.e. when we booted the previous version again.
bg_printenv will then report something like this:


----------------------------
Config Partition #0 Values:
in_progress: no
revision: 2
kernel: C:BOOT0:linux.efi
kernelargs:
watchdog timeout: 0 seconds
ustate: 0 (OK)

user variables:



----------------------------
Config Partition #1 Values:
in_progress: no
revision: 0
kernel: C:BOOT1:linux.efi
kernelargs:
watchdog timeout: 0 seconds
ustate: 3 (FAILED)

user variables:


But there is no simple command to find out that we are not OK but rather
back from a failed update. There is bg_printenv -o ustate -r -c, but
that will only report USTATE=0. We don't have a nice way to query the
"FAILED" state of the other env, only "bg_printenv | grep FAILED".

Any ideas how to address that best?

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux

Christian Storm

unread,
Feb 21, 2023, 3:46:49 PM2/21/23
to efibootguard-dev
In addition to $ bg_printenv -o ustate -r -c, there's also the
environment selector so that you can use something like this in
shell scripts, at least getting rid of the | grep:

for env in 0 1; do
eval "$(bg_printenv -o ustate -p $env --raw)"
case $USTATE in
0)
echo "OK"
;;
... whatever ...
esac
done

However, it's still (too much) pluming IMO. What about one bg_printenv
call that returns the values from *all* environments, e.g., [mockup]
$ bg_printenv -o ustate -p all --raw
ENV_COUNT=2
USTATE_0=0
USTATE_1=3

where the _<NUM> suffix is the config partition number and ENV_COUNT
gives the total config partition count? Otherwise, you have to know
or probe for the config partition count...


Kind regards,
Christian

--
Dr. Christian Storm
Siemens AG, Technology, T CED SES-DE
Otto-Hahn-Ring 6, 81739 München, Germany
Reply all
Reply to author
Forward
0 new messages