Skip to content
Snippets Groups Projects
Commit 05e7c806 authored by Andreas Gnau's avatar Andreas Gnau :speech_balloon:
Browse files

brcm63xx: upgrade: Work around bcm_bootstate limitation

Store the bank that we set in a file, because the bcm_bootstate command
cannot be relied to return correct data, when the system has been
powered on after the power was cut.
parent ec087d42
No related branches found
No related tags found
1 merge request!268brcm63xx: upgrade: Work around bcm_bootstate limitation
......@@ -44,13 +44,42 @@ platform_set_bootbank() {
esac;
status=$?
set +o pipefail
[ $status -eq 0 ] && return 0 || return 1
# We store the value that we SET here, because bcm_bootstate does not return
# the correct value when the system has been powered off and on.
# It only works when there has been a reset_reason like normal reboot for example.
# The bcm_bootstate utility uses /proc/bootstate (bcm_bootstate module).
# The way that this works is that each bank has a commit-flag, in the metadata-volume.
# This determines which bank is the one to boot.
# To facilitate booting another bank once, a flag will be set using
# the bcm_bootstate-driver in HW.
# Retrieving this flag does not work if the reset_reason was PWR_ON.
# Writing to reset_reason works, but in case of power off/on, the driver
# always returns the hardcoded value of 0xffffffff.
# This seems to be by design, but right now it is not clear,
# whether there is some limitation behind it or whether it is a design miss.
#
# Note that this workaround here does not catch someone (a developer) setting
# the bank manually using the bcm_bootstate command outside of this function,
# if set_bootbank has at least been called once.
if [ $status -eq 0 ]; then
echo -n "$1" > /var/run/bcm_bootbank || return 1
return 0
else
return 1
fi
}
#--------------------------------------------------------------
# Return what "bank" the bootloader will select next time.
platform_get_bootbank() {
# See comment in platform_set_bootbank for the reason for
# this file existing
stored_bcm_bootbank="$(cat /var/run/bcm_bootbank 2>/dev/null)"
if [ -n "$stored_bcm_bootbank" ]; then
echo -n "$stored_bcm_bootbank"
return 0
fi
# Call bcm_bootstate only once.
bootstate_output=$(bcm_bootstate | grep "Reboot Partition")
if echo "$bootstate_output" | grep -q First; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment