mirror of
https://github.com/gtxaspec/wz_mini_hacks.git
synced 2024-11-09 15:08:21 +00:00
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:
parent
df3a8945bd
commit
46ec7dd02b
1
v2_install/.gitignore
vendored
1
v2_install/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
demo.bin
|
demo.bin
|
||||||
|
demo*.zip
|
||||||
|
@ -12,6 +12,16 @@ command -v unzip >/dev/null 2>&1 || { echo >&2 "unzip is not installed. Abortin
|
|||||||
echo "tools OK"
|
echo "tools OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
local version="${1:-firmware}"
|
||||||
|
|
||||||
|
echo "saving original firmware"
|
||||||
|
mv ./v2_ro/demo*.zip "./demo_${version// /_}-orig.zip"
|
||||||
|
|
||||||
|
echo "removing temporary work directory"
|
||||||
|
rm -rf v2_ro
|
||||||
|
}
|
||||||
|
|
||||||
download(){
|
download(){
|
||||||
rm -f demo.bin
|
rm -f demo.bin
|
||||||
|
|
||||||
@ -32,18 +42,20 @@ else
|
|||||||
echo "build for v2"
|
echo "build for v2"
|
||||||
wget $DL_URL -O ./v2_ro/demo.zip
|
wget $DL_URL -O ./v2_ro/demo.zip
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(md5sum ./v2_ro/demo.zip) == *"a69b6d5ffdbce89463fa83f7f06ec10b"* ]]; then
|
|
||||||
echo "v2 4.9.8.1002"
|
|
||||||
elif [[ $(md5sum ./v2_ro/demo.zip) == *"91793d32fd797a10df572f4f5d72bc55"* ]]; then
|
|
||||||
echo "pan v1 4.10.8.1002"
|
|
||||||
else
|
|
||||||
echo "md5sum failed check, please manually supply file"
|
|
||||||
rm -rf v2_ro
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check the firmware to see if it's supported
|
||||||
|
local version_found=""
|
||||||
|
if [[ $(md5sum ./v2_ro/demo*.zip) == *"a69b6d5ffdbce89463fa83f7f06ec10b"* ]]; then
|
||||||
|
version_found="v2 4.9.8.1002"
|
||||||
|
elif [[ $(md5sum ./v2_ro/demo*.zip) == *"91793d32fd797a10df572f4f5d72bc55"* ]]; then
|
||||||
|
version_found="pan v1 4.10.8.1002"
|
||||||
|
else
|
||||||
|
cleanup
|
||||||
|
echo "md5sum failed check, please supply a supported demo.zip file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "$version_found"
|
||||||
|
|
||||||
echo "extracting firmware to temporary work directory"
|
echo "extracting firmware to temporary work directory"
|
||||||
unzip v2_ro/demo*.zip -d ./v2_ro/
|
unzip v2_ro/demo*.zip -d ./v2_ro/
|
||||||
@ -60,10 +72,16 @@ cp v2_kernel.bin v2_ro/fw_dir/kernel.bin
|
|||||||
echo "pack firmware image with new kernel"
|
echo "pack firmware image with new kernel"
|
||||||
./fw_tool.sh pack v2_ro/fw_dir demo.bin
|
./fw_tool.sh pack v2_ro/fw_dir demo.bin
|
||||||
|
|
||||||
echo "remove temporary work directory"
|
cleanup "$version_found"
|
||||||
rm -rf v2_ro
|
|
||||||
|
# check to see if the modified demo.bin has been created
|
||||||
|
if [ ! -f "demo.bin" ]; then
|
||||||
|
echo "demo.bin was not created. Aborting."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "demo.bin ready for $version_found. Please copy demo.bin to your memory card"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "demo.bin ready. Please copy demo.bin to your memory card"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,8 @@ elif [ "$ACTION" = "pack" ]; then
|
|||||||
#need to pad kernel is its smaller than the stock kernel size, 2097152 bytes
|
#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
|
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
|
mkimage -A MIPS -O linux -T firmware -C none -a 0 -e 0 -n jz_fw -d $TMP_DIR/flash.bin $DEMO_OUT
|
||||||
|
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user