[openwrt/openwrt] scripts/om-fwupgradecfg-gen.sh: Generate checksum over whole squashfs

LEDE Commits lede-commits at lists.infradead.org
Tue Dec 22 13:13:36 EST 2020


ynezz pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/a4c30d9399bdd7f5c42409b959d52230a97600c9

commit a4c30d9399bdd7f5c42409b959d52230a97600c9
Author: Sven Eckelmann <sven at narfation.org>
AuthorDate: Wed Nov 25 10:48:57 2020 +0100

    scripts/om-fwupgradecfg-gen.sh: Generate checksum over whole squashfs
    
    The rootfs is padded to the full block size by padjffs2 and a 4 byte magic
    value ("deadc0de") is added to the end. On first boot, the JFFS2 is
    replacing the "deadc0de" marker when the rootfs_data is initialized.
    
    The static part of the rootfs is therefore $rootfs_size - 4 and not
    $rootfs_size - 262144 - 4.
    
    Signed-off-by: Sven Eckelmann <sven at narfation.org>
---
 scripts/om-fwupgradecfg-gen.sh | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/scripts/om-fwupgradecfg-gen.sh b/scripts/om-fwupgradecfg-gen.sh
index 915fbd05ab..ce33454a24 100755
--- a/scripts/om-fwupgradecfg-gen.sh
+++ b/scripts/om-fwupgradecfg-gen.sh
@@ -23,28 +23,24 @@ case $CE_TYPE in
 	OM2P)
 		MAX_PART_SIZE=7168
 		KERNEL_FLASH_ADDR=0x1c0000
-		MD5_SKIP_BLOCKS=4
 		SIZE_FACTOR=1
 		SIZE_FORMAT="%d"
 		;;
 	OM5P|OM5PAC|MR600|MR900|MR1750|A60)
 		MAX_PART_SIZE=7808
 		KERNEL_FLASH_ADDR=0xb0000
-		MD5_SKIP_BLOCKS=4
 		SIZE_FACTOR=1
 		SIZE_FORMAT="%d"
 		;;
 	A42)
 		MAX_PART_SIZE=15616
 		KERNEL_FLASH_ADDR=0x180000
-		MD5_SKIP_BLOCKS=4
 		SIZE_FACTOR=1024
 		SIZE_FORMAT="0x%08x"
 		;;
 	A62)
 		MAX_PART_SIZE=15552
 		KERNEL_FLASH_ADDR=0x1a0000
-		MD5_SKIP_BLOCKS=4
 		SIZE_FACTOR=1024
 		SIZE_FORMAT="0x%08x"
 		;;
@@ -64,11 +60,12 @@ KERNEL_PART_SIZE=$(printf $SIZE_FORMAT $(($KERNEL_PART_SIZE_KB * $SIZE_FACTOR)))
 
 ROOTFS_FLASH_ADDR=$(addr=$(($KERNEL_FLASH_ADDR + ($KERNEL_PART_SIZE_KB * 1024))); printf "0x%x" $addr)
 ROOTFS_SIZE=$(stat -c%s "$ROOTFS_PATH")
-ROOTFS_CHECK_BLOCKS=$((($ROOTFS_SIZE / $CHECK_BS) - $MD5_SKIP_BLOCKS))
+ROOTFS_SQUASHFS_SIZE=$((ROOTFS_SIZE-4))
+ROOTFS_CHECK_BLOCKS=$((ROOTFS_SQUASHFS_SIZE / CHECK_BS))
 ROOTFS_MD5=$(dd if=$ROOTFS_PATH bs=$CHECK_BS count=$ROOTFS_CHECK_BLOCKS 2>&- | mkhash md5)
 ROOTFS_MD5_FULL=$(mkhash md5 $ROOTFS_PATH)
 ROOTFS_SHA256_FULL=$(mkhash sha256 $ROOTFS_PATH)
-ROOTFS_CHECK_SIZE=$(printf '0x%x' $(($ROOTFS_CHECK_BLOCKS * $CHECK_BS)))
+ROOTFS_CHECK_SIZE=$(printf '0x%x' $ROOTFS_SQUASHFS_SIZE)
 ROOTFS_PART_SIZE_KB=$(($MAX_PART_SIZE - $KERNEL_PART_SIZE_KB))
 ROOTFS_PART_SIZE=$(printf $SIZE_FORMAT $(($ROOTFS_PART_SIZE_KB * $SIZE_FACTOR)))
 



More information about the lede-commits mailing list