Improve v2 firmware validation and error checks (#449)

To reduce the chance that a bad firmware image is created and used, the
following functionality has been implemented:

1. Check md5 sums of local files in addition to downloaded files
2. Copy a backup of the original firmware, instead of removing it
3. Do not make an image unless all parts are present
4. Only output success message if the image file exists

The above fixes an issue where if a provided firmware zipfile is unable to
be read, the script continues on, generates a bad demo.bin file, and suggests
the file is good for loading into the camera. The above updates help prevent
this from occurring
This commit is contained in:
John Elkins
2023-07-11 21:21:13 -05:00
committed by GitHub
parent df3a8945bd
commit 46ec7dd02b
3 changed files with 34 additions and 14 deletions

View File

@@ -40,7 +40,8 @@ elif [ "$ACTION" = "pack" ]; then
#need to pad kernel is its smaller than the stock kernel size, 2097152 bytes
dd if=/dev/zero of=$TMP_DIR/kernel.bin bs=1 count=1 seek=2097151
cat $TMP_DIR/kernel.bin $TMP_DIR/rootfs.bin $TMP_DIR/driver.bin $TMP_DIR/appfs.bin > $TMP_DIR/flash.bin
#only run mkimage if cat succeeds, otherwise it's possible that a bad image is created
cat $TMP_DIR/kernel.bin $TMP_DIR/rootfs.bin $TMP_DIR/driver.bin $TMP_DIR/appfs.bin > $TMP_DIR/flash.bin && \
mkimage -A MIPS -O linux -T firmware -C none -a 0 -e 0 -n jz_fw -d $TMP_DIR/flash.bin $DEMO_OUT
else