0063-scripts-om-fwupgradecfg-gen.sh-Generate-sha256sum-for-uboot-verification.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From: Sven Eckelmann <sven.eckelmann@open-mesh.com>
  2. Date: Sat, 9 Apr 2016 10:25:42 +0000
  3. Subject: scripts/om-fwupgradecfg-gen.sh: Generate sha256sum for uboot verification
  4. Future Open Mesh u-boot versions are changing the check of the image files
  5. (vmlinux, rootfs) from md5 to sha256. Having both in them should be enough
  6. to ensure backward and forward compatibility.
  7. Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
  8. Backport of r49140
  9. Forwarded: https://patchwork.ozlabs.org/patch/624190/
  10. diff --git a/scripts/om-fwupgradecfg-gen.sh b/scripts/om-fwupgradecfg-gen.sh
  11. index fab1582..e208e6d 100644
  12. --- a/scripts/om-fwupgradecfg-gen.sh
  13. +++ b/scripts/om-fwupgradecfg-gen.sh
  14. @@ -42,6 +42,7 @@ CHECK_BS=65536
  15. KERNEL_SIZE=$(stat -c%s "$KERNEL_PATH")
  16. KERNEL_MD5=$(md5=$(md5sum $KERNEL_PATH); echo ${md5%% *})
  17. +KERNEL_SHA256=$(openssl dgst -sha256 $KERNEL_PATH | awk '{print $2}')
  18. KERNEL_PART_SIZE=$(size=$(($KERNEL_SIZE / $FLASH_BS)); [ $(($size * $FLASH_BS)) -lt $KERNEL_SIZE ] && size=$(($size + 1)); echo $(($size * $FLASH_BS / 1024)))
  19. ROOTFS_FLASH_ADDR=$(addr=$(($KERNEL_FLASH_ADDR + ($KERNEL_PART_SIZE * 1024))); printf "0x%x" $addr)
  20. @@ -49,6 +50,7 @@ ROOTFS_SIZE=$(stat -c%s "$ROOTFS_PATH")
  21. ROOTFS_CHECK_BLOCKS=$((($ROOTFS_SIZE / $CHECK_BS) - $MD5_SKIP_BLOCKS))
  22. ROOTFS_MD5=$(md5=$(dd if=$ROOTFS_PATH bs=$CHECK_BS count=$ROOTFS_CHECK_BLOCKS 2>&- | md5sum); echo ${md5%% *})
  23. ROOTFS_MD5_FULL=$(md5=$(md5sum $ROOTFS_PATH); echo ${md5%% *})
  24. +ROOTFS_SHA256_FULL=$(openssl dgst -sha256 $ROOTFS_PATH | awk '{print $2}')
  25. ROOTFS_CHECK_SIZE=$(printf '0x%x' $(($ROOTFS_CHECK_BLOCKS * $CHECK_BS)))
  26. ROOTFS_PART_SIZE=$(($MAX_PART_SIZE - $KERNEL_PART_SIZE))
  27. @@ -57,6 +59,7 @@ cat << EOF > $CFG_OUT
  28. filename=kernel
  29. md5sum=$KERNEL_MD5
  30. filemd5sum=$KERNEL_MD5
  31. +filesha256sum=$KERNEL_SHA256
  32. flashaddr=$KERNEL_FLASH_ADDR
  33. checksize=0x0
  34. cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; saveenv
  35. @@ -66,6 +69,7 @@ cmd_fail=reset
  36. filename=rootfs
  37. md5sum=$ROOTFS_MD5
  38. filemd5sum=$ROOTFS_MD5_FULL
  39. +filesha256sum=$ROOTFS_SHA256_FULL
  40. flashaddr=$ROOTFS_FLASH_ADDR
  41. checksize=$ROOTFS_CHECK_SIZE
  42. cmd_success=setenv bootseq 1,2; setenv kernel_size_1 $KERNEL_PART_SIZE; setenv rootfs_size_1 $ROOTFS_PART_SIZE; saveenv