Skip to content
Snippets Groups Projects
Commit 177d26fb authored by Jani Juvan's avatar Jani Juvan
Browse files

brcm63xx-arm: Use generic function for checking bootloader upgrade

parent 0bfd58a1
No related branches found
No related tags found
No related merge requests found
......@@ -2,51 +2,18 @@ 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
case "$(get_root_device_type)" in
nand) local loader_part=/dev/mtd1 ;;
emmc) local loader_part=/dev/mmcblk0boot0 ;;
*) return 1 ;;
esac
json_init
json_load "$(strings "$loader_part" | 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
case "$(get_root_device_type)" in
nand) local loader_part=/dev/mtd1 ;;
emmc) local loader_part=/dev/mmcblk0boot0 ;;
*) return 1 ;;
esac
if iopsys_is_bootloader_update_needed "$image" "$loader_part"; then
UPGRADE_OPT_FORCE_LOADER_UPGRADE=1
log "sysupgrade" "Bootloader with newer version is available in FIT-image. Enabling bootloader upgrade."
fi
......
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