# So the kernel check is for the loader, the rootfs check is for kernel + rootfs
platform_do_upgrade_failsafe_datachk() {
- local setenv_script="/tmp/fw_env_upgrade"
-
local flash_base=0x9f000000
local kernel_mtd=$(find_mtd_index ${KERNEL_PART:-kernel})
local rootfs_md5=$($IMAGE_CMD $ROOTFS_FILE | dd bs=4k count=$rootfs_blocks iflag=fullblock | md5sum | cut -d ' ' -f1)
# prepare new u-boot-env vars
- printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $setenv_script
- printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $setenv_script
- printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script
+ printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $ENV_SCRIPT
+ printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $ENV_SCRIPT
+ printf "vmlinux_checksum %s\n" ${kernel_md5} >> $ENV_SCRIPT
- printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $setenv_script
- printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $setenv_script
- printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script
+ printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $ENV_SCRIPT
+ printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $ENV_SCRIPT
+ printf "rootfs_checksum %s\n" ${rootfs_md5} >> $ENV_SCRIPT
# store u-boot-env
mkdir -p /var/lock
- fw_setenv -s $setenv_script || {
+ [ -n "$SKIP_HASH" ] || fw_setenv -s $ENV_SCRIPT || {
echo 'failed to update U-Boot environment'
exit 1
}
# sysupgrade
- sleep 2
- sync
- echo 3 > /proc/sys/vm/drop_caches
+ sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches
+
$IMAGE_CMD $KERNEL_FILE | mtd $MTD_ARGS write - ${KERNEL_PART:-kernel}
- sleep 2
- sync
+
+ sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches
+
if [ -n "$UPGRADE_BACKUP" ]; then
$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs}
else
$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs}
fi
+
+ sync
}
# So the kernel check is for the loader, the rootfs check is for kernel + rootfs
platform_do_upgrade_failsafe_datachk() {
- local setenv_script="/tmp/fw_env_upgrade"
-
local flash_base=0x9f000000
local kernel_mtd=$(find_mtd_index ${KERNEL_PART:-kernel})
local rootfs_md5=$($IMAGE_CMD $ROOTFS_FILE | dd bs=4k count=$rootfs_blocks iflag=fullblock | md5sum | cut -d ' ' -f1)
# prepare new u-boot-env vars
- printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $setenv_script
- printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $setenv_script
- printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script
+ printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $ENV_SCRIPT
+ printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $ENV_SCRIPT
+ printf "vmlinux_checksum %s\n" ${kernel_md5} >> $ENV_SCRIPT
- printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $setenv_script
- printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $setenv_script
- printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script
+ printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $ENV_SCRIPT
+ printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $ENV_SCRIPT
+ printf "rootfs_checksum %s\n" ${rootfs_md5} >> $ENV_SCRIPT
# store u-boot-env
mkdir -p /var/lock
- fw_setenv -s $setenv_script || {
+ [ -n "$SKIP_HASH" ] || fw_setenv -s $ENV_SCRIPT || {
echo 'failed to update U-Boot environment'
exit 1
}
# sysupgrade
- sleep 2
- sync
- echo 3 > /proc/sys/vm/drop_caches
+ sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches
+
$IMAGE_CMD $KERNEL_FILE | mtd $MTD_ARGS write - ${KERNEL_PART:-kernel}
- sleep 2
- sync
+
+ sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches
+
if [ -n "$UPGRADE_BACKUP" ]; then
$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs}
else
$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs}
fi
+
+ sync
}