firmware-open/scripts/flash.sh

45 lines
898 B
Bash
Raw Normal View History

2019-06-26 15:39:14 -06:00
#!/usr/bin/env bash
set -e
if [ -z "$1" ]
then
2020-04-07 12:19:03 -06:00
echo "$0 <model> [--without-ec]" >&2
2019-06-26 15:39:14 -06:00
exit 1
fi
MODEL="$1"
2020-04-07 12:19:03 -06:00
WITH_EC=true
if [ "$2" = "--without-ec" ]
then
WITH_EC=false
fi
2019-10-10 09:27:59 -06:00
if [ ! -d "models/${MODEL}" ]
2019-06-26 15:39:14 -06:00
then
2019-10-10 09:27:59 -06:00
echo "model '${MODEL}' not found" >&2
2019-06-26 15:39:14 -06:00
exit 1
fi
MODEL_DIR="$(realpath "models/${MODEL}")"
2019-10-10 09:27:59 -06:00
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
2019-06-26 15:39:14 -06:00
cargo build --release --manifest-path libs/intel-spi/Cargo.toml
sudo libs/intel-spi/target/release/intel-spi "build/${MODEL}/coreboot.rom"
2020-04-07 12:19:03 -06:00
if [ "$WITH_EC" = true ]
then
if [ -e "build/${MODEL}/ec.rom" ]
then
cargo build --release --manifest-path ec/tool/Cargo.toml
sudo ec/tool/target/release/system76_ectool flash "build/${MODEL}/ec.rom"
fi
else
echo "Skipping EC flash"
fi