0062-scripts-om-fwupgradecfg-gen.sh-Fix-u-boot-image-md5sum-check.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From: Sven Eckelmann <sven.eckelmann@open-mesh.com>
  2. Date: Mon, 14 Sep 2015 20:10:10 +0000
  3. Subject: scripts/om-fwupgradecfg-gen.sh: Fix u-boot image md5sum check
  4. The u-boot on Open Mesh devices checks the whole transfered image against a
  5. md5sum. This is stored inside the option filemd5sum inside the
  6. fwupgrade.cfg. The bootloader will not check it when this setting is
  7. missing and could therefore write invalid images to the flash.
  8. Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
  9. Backport of r46925
  10. Forwarded: https://patchwork.ozlabs.org/patch/624189/
  11. diff --git a/scripts/om-fwupgradecfg-gen.sh b/scripts/om-fwupgradecfg-gen.sh
  12. index c790214..fab1582 100644
  13. --- a/scripts/om-fwupgradecfg-gen.sh
  14. +++ b/scripts/om-fwupgradecfg-gen.sh
  15. @@ -48,6 +48,7 @@ ROOTFS_FLASH_ADDR=$(addr=$(($KERNEL_FLASH_ADDR + ($KERNEL_PART_SIZE * 1024))); p
  16. ROOTFS_SIZE=$(stat -c%s "$ROOTFS_PATH")
  17. ROOTFS_CHECK_BLOCKS=$((($ROOTFS_SIZE / $CHECK_BS) - $MD5_SKIP_BLOCKS))
  18. ROOTFS_MD5=$(md5=$(dd if=$ROOTFS_PATH bs=$CHECK_BS count=$ROOTFS_CHECK_BLOCKS 2>&- | md5sum); echo ${md5%% *})
  19. +ROOTFS_MD5_FULL=$(md5=$(md5sum $ROOTFS_PATH); echo ${md5%% *})
  20. ROOTFS_CHECK_SIZE=$(printf '0x%x' $(($ROOTFS_CHECK_BLOCKS * $CHECK_BS)))
  21. ROOTFS_PART_SIZE=$(($MAX_PART_SIZE - $KERNEL_PART_SIZE))
  22. @@ -55,6 +56,7 @@ cat << EOF > $CFG_OUT
  23. [vmlinux]
  24. filename=kernel
  25. md5sum=$KERNEL_MD5
  26. +filemd5sum=$KERNEL_MD5
  27. flashaddr=$KERNEL_FLASH_ADDR
  28. checksize=0x0
  29. cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; saveenv
  30. @@ -63,6 +65,7 @@ cmd_fail=reset
  31. [rootfs]
  32. filename=rootfs
  33. md5sum=$ROOTFS_MD5
  34. +filemd5sum=$ROOTFS_MD5_FULL
  35. flashaddr=$ROOTFS_FLASH_ADDR
  36. checksize=$ROOTFS_CHECK_SIZE
  37. cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; setenv rootfs_size_1 $ROOTFS_PART_SIZE; saveenv