Add some safety to flash script

This commit is contained in:
Jeremy Soller
2019-10-10 09:27:59 -06:00
parent 813873bf29
commit 9e4d06333c

View File

@@ -9,12 +9,19 @@ then
fi
MODEL="$1"
if [ ! -d "models/$1" ]
if [ ! -d "models/${MODEL}" ]
then
echo "model '$1' not found" >&2
echo "model '${MODEL}' not found" >&2
exit 1
fi
MODEL_DIR="$(realpath "models/${MODEL}")"
DMI_MODEL="$(cat /sys/class/dmi/id/product_version)"
if [ "${DMI_MODEL}" != "${MODEL}" ]
then
echo "Refusing to flash model '${MODEL}' to model '${DMI_MODEL}'" >&2
exit 1
fi
cargo build --release --manifest-path libs/intel-spi/Cargo.toml
sudo libs/intel-spi/target/release/intel-spi "build/${MODEL}/coreboot.rom"