Skip to content
Snippets Groups Projects
Commit da09a8fb authored by Markus Gothe's avatar Markus Gothe :ok_hand: Committed by Andreas Gnau
Browse files

iopsys-brcm63xx-arm/base-files/lib/upgrade: add loader version logic

Add logic to decide when to upgrade the loader area and when to not
upgrade the loader area. This logic can be overridden by a bundle
script which modifies the 'skip_bootloader' variable.
parent ae4abab6
Branches
Tags
1 merge request!282iopsys-brcm63xx-arm/base-files/lib/upgrade: add loader version logic
......@@ -2,14 +2,63 @@ platform_check_image() {
iopsys_check_image $1
}
platform_compare_bootloader_version() {
# FIT image has newer bootloader than on flash => bootlaoder will be updated
# FIT image has same version or older version than on flash => bootloader will not be updated
# Bootloader does not have a version => version is 0 will get updated by new FIT image with a bootloader version
# FIT image does not have a bootloader in it or is old and does not have bootloader version => fit version is 0 and bootloader will not get updated.
# Bootloader does not have version and neither has the FIT-image => will not get updated (0 == 0)
local iopsys_bootloader_version="0"
local fit_iopsys_bootloader_version="0"
local image images
[ -z "$1" ] && return 1
[ "$(get_root_device_type())" != "nand" ] && return 1
json_init
json_load "$(strings /dev/mtd1 | awk '/938f0820-2ffb-11e7-bbc9-2f21351ee6fb:/ {$1=""; print $0}' 2> /dev/null | head -n1 | awk '{$1=$1; print}')"
json_get_vars iopsys_bootloader_version
iopsys_bootloader_version=$((iopsys_bootloader_version))
images="$(fdtextract -l "$1" 2> /dev/null | awk '{print $2}' | xargs)"
for image in $images; do
if fdtextract -i "$image" -a iopsys_bootloader_version "$1" > /dev/null 2>&1; then
fit_iopsys_bootloader_version="$(fdtextract -i "$image" -a iopsys_bootloader_version "$1" 2> /dev/null)"
break
fi
done
fit_iopsys_bootloader_version=$((fit_iopsys_bootloader_version))
if [ "$fit_iopsys_bootloader_version" -gt "$iopsys_bootloader_version" ]; then
return 1
else
return 0
fi
}
platform_do_upgrade() {
local image="$1"
local status=0
local skip_bootloader=""
if ! platform_compare_bootloader_version "$1"; then
UPGRADE_OPT_FORCE_LOADER_UPGRADE=1
log "sysupgrade" "Bootloader with newer version is available in FIT-image. Enabling bootloader upgrade."
fi
[ -z "$UPGRADE_OPT_FORCE_LOADER_UPGRADE" ] && UPGRADE_OPT_FORCE_LOADER_UPGRADE=1
if [ "$UPGRADE_OPT_FORCE_LOADER_UPGRADE" = "0" ]; then
skip_bootloader="-s"
log "sysupgrade" "Bootloader upgrade is disabled."
else
log "sysupgrade" "Bootloader upgrade is enabled."
fi
iopsys_process_upgrade_bundle "$image" pre_upgrade || status=1
set -o pipefail
[ $status -eq 0 ] && bcm_flasher "$image" 2>&1 | log "sysupgrade" || status=$?
[ $status -eq 0 ] && bcm_flasher $skip_bootloader "$image" 2>&1 | log "sysupgrade" || status=$?
log "sysupgrade" "bcm_flasher returned $status."
set +o pipefail
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment