scripts/om-fwupgradecfg-gen.sh: Generate checksum over whole squashfs
authorSven Eckelmann <sven@narfation.org>
Wed, 25 Nov 2020 09:48:57 +0000 (10:48 +0100)
committerPetr Štetiar <ynezz@true.cz>
Tue, 22 Dec 2020 18:11:50 +0000 (19:11 +0100)
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@narfation.org>
scripts/om-fwupgradecfg-gen.sh

index 915fbd05ab48a701b6abcf30891e8ebcdf4fec55..ce33454a24657b48b44dcf133b2ff4c0d3ce121b 100755 (executable)
@@ -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)))