Browse Source

flashrom_rpi_write: add size check before flashing

flashrom might do it anyways, but we have the read image and can
make sure the user didn't by accident provide the other image, for
example.
pull/35/head
Martin Kepplinger 6 years ago
parent
commit
27a187ed12
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      flashrom_rpi_write.sh

+ 6
- 0
flashrom_rpi_write.sh View File

@ -70,6 +70,7 @@ if [ ! "$have_chipname" -gt 0 ] ; then
fi fi
INPUT_IMAGE_NAME=$(basename ${INPUT_IMAGE_PATH}) INPUT_IMAGE_NAME=$(basename ${INPUT_IMAGE_PATH})
INPUT_IMAGE_SIZE=$(wc -c <"$INPUT_IMAGE_PATH")
echo "verifying SPI connection by reading" echo "verifying SPI connection by reading"
TEMP_DIR=`mktemp -d` TEMP_DIR=`mktemp -d`
@ -84,6 +85,11 @@ if [ "$have_backupname" -gt 0 ] ; then
mv ${TEMP_DIR}/test1.rom ${BACKUPNAME} mv ${TEMP_DIR}/test1.rom ${BACKUPNAME}
echo "current image saved as ${BACKUPIMAGE}" echo "current image saved as ${BACKUPIMAGE}"
fi fi
TEMP_SIZE=$(wc -c <"$TEMP_DIR/test1.rom")
if [ ! "$INPUT_IMAGE_SIZE" -eq "$TEMP_SIZE" ] ; then
echo "Error: read image (${TEMP_SIZE}) has different size that new image $INPUT_IMAGE_NAME (${INPUT_IMAGE_SIZE})"
exit 1
fi
rm -rf ${TEMP_DIR} rm -rf ${TEMP_DIR}
echo -e "connection ok. flashing ${GREEN}${INPUT_IMAGE_NAME}${NC}" echo -e "connection ok. flashing ${GREEN}${INPUT_IMAGE_NAME}${NC}"


Loading…
Cancel
Save