sw-update: add possibility to update u-boot/spl
This commit is contained in:
parent
f57220c50e
commit
b3a13040d1
|
|
@ -179,27 +179,92 @@ cleanup()
|
||||||
rm $EXTRACTED_IMAGE
|
rm $EXTRACTED_IMAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
############################ Start of script ###################################
|
check_file()
|
||||||
if [ ! -e "$1" ]
|
{
|
||||||
then
|
if [ ! -e "$1" ]
|
||||||
|
then
|
||||||
log ERROR "Please provide a valid update image"
|
log ERROR "Please provide a valid update image"
|
||||||
exit -1
|
exit -1
|
||||||
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
|
||||||
# extract_image
|
# extract_image
|
||||||
# Don't use the header stuff for now, move the file instead
|
# Don't use the header stuff for now, move the file instead
|
||||||
EXTRACTED_IMAGE=$IMAGE_LOCATION
|
EXTRACTED_IMAGE=$IMAGE_LOCATION
|
||||||
# Also don't check the md5 sum
|
# Also don't check the md5 sum
|
||||||
# check_image_md5
|
# check_image_md5
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue