sw-update: add possibility to update u-boot/spl

This commit is contained in:
Stefan Eichenberger 2016-07-05 14:56:58 +02:00
parent f57220c50e
commit b3a13040d1
1 changed files with 85 additions and 20 deletions

View File

@ -179,7 +179,8 @@ cleanup()
rm $EXTRACTED_IMAGE rm $EXTRACTED_IMAGE
} }
############################ Start of script ################################### check_file()
{
if [ ! -e "$1" ] if [ ! -e "$1" ]
then then
log ERROR "Please provide a valid update image" log ERROR "Please provide a valid update image"
@ -187,8 +188,12 @@ then
else else
IMAGE_LOCATION=$1 IMAGE_LOCATION=$1
fi fi
}
log INFO "Starting update ..." update_linux()
{
log INFO "Starting linux update ..."
check_file $1
#extract_header_infos #extract_header_infos
#check_image_compatibility #check_image_compatibility
@ -200,6 +205,66 @@ EXTRACTED_IMAGE=$IMAGE_LOCATION
flash_firmware flash_firmware
cleanup cleanup
log INFO "Software update succeed!" log INFO "Linux update succeed!"
}
update_uboot()
{
log INFO "Starting u-boot update ..."
check_file $1
head_should=$(echo -e "\x27\x05\x19\x56")
head_is=$(dd if=$1 bs=1 count=4 2>/dev/null)
if [ "$head_is" != "$head_should" ]; then
log ERROR "Header of the input image seems invalid, abort update"
return
fi
dd if=$1 of=/dev/mmcblk0 bs=512 seek=768 &> /dev/null
if [ $? -ne 0 ]; then
log ERROR "Failed to write u-boot to mmcblk0"
return
fi
log INFO "u-boot update succeed!"
}
update_spl()
{
log INFO "Starting spl update ..."
check_file $1
head_should=$(echo -e "\x40\x00\x00\x00")
head_is=$(dd if=$1 bs=1 count=4 2>/dev/null)
if [ "$head_is" != "$head_should" ]; then
log ERROR "Header of the input image seems invalid, abort update"
return
fi
dd if=$1 of=/dev/mmcblk0 bs=512 seek=256 &> /dev/null
if [ $? -ne 0 ]; then
log ERROR "Failed to write spl to mmcblk0"
return
fi
log INFO "spl update succeed!"
}
############################ Start of script ###################################
while getopts ":l:u:s:h" opt; do
case $opt in
l)
update_linux $OPTARG
;;
u)
update_uboot $OPTARG
;;
s)
update_spl $OPTARG
;;
h)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
exit 0 exit 0