[OpenWrt-Devel] [PATCH] scripts/om-fwupgradecfg-gen.sh: Fix u-boot image md5sum check
Sven Eckelmann
sven at open-mesh.com
Thu Sep 3 13:19:03 EDT 2015
The u-boot on Open Mesh devices checks the whole transfered image against a
md5sum. This is stored inside the option filemd5sum inside the
fwupgrade.cfg. The bootloader will not check it when this setting is
missing and could therefore write invalid images to the flash.
Signed-off-by: Sven Eckelmann <sven at open-mesh.com>
Cc: Marek Lindner <marek at open-mesh.com>
---
scripts/om-fwupgradecfg-gen.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/om-fwupgradecfg-gen.sh b/scripts/om-fwupgradecfg-gen.sh
index 1f899c9..ba6f9a09 100644
--- a/scripts/om-fwupgradecfg-gen.sh
+++ b/scripts/om-fwupgradecfg-gen.sh
@@ -54,6 +54,7 @@ ROOTFS_FLASH_ADDR=$(addr=$(($KERNEL_FLASH_ADDR + ($KERNEL_PART_SIZE * 1024))); p
ROOTFS_SIZE=$(stat -c%s "$ROOTFS_PATH")
ROOTFS_CHECK_BLOCKS=$((($ROOTFS_SIZE / $CHECK_BS) - $MD5_SKIP_BLOCKS))
ROOTFS_MD5=$(md5=$(dd if=$ROOTFS_PATH bs=$CHECK_BS count=$ROOTFS_CHECK_BLOCKS 2>&- | md5sum); echo ${md5%% *})
+ROOTFS_MD5_FULL=$(md5=$(md5sum $ROOTFS_PATH); echo ${md5%% *})
ROOTFS_CHECK_SIZE=$(printf '0x%x' $(($ROOTFS_CHECK_BLOCKS * $CHECK_BS)))
ROOTFS_PART_SIZE=$(($MAX_PART_SIZE - $KERNEL_PART_SIZE))
@@ -61,6 +62,7 @@ cat << EOF > $CFG_OUT
[vmlinux]
filename=kernel
md5sum=$KERNEL_MD5
+filemd5sum=$KERNEL_MD5
flashaddr=$KERNEL_FLASH_ADDR
checksize=0x0
cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; saveenv
@@ -69,6 +71,7 @@ cmd_fail=reset
[rootfs]
filename=rootfs
md5sum=$ROOTFS_MD5
+filemd5sum=$ROOTFS_MD5_FULL
flashaddr=$ROOTFS_FLASH_ADDR
checksize=$ROOTFS_CHECK_SIZE
cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; setenv rootfs_size_1 $ROOTFS_PART_SIZE; saveenv
--
2.5.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list