firmware-open/scripts/flash.sh

52 lines
1.1 KiB
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
2020-04-08 13:32:25 -06:00
sudo libs/intel-spi/target/release/intel-spi "build/${MODEL}/firmware.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
ECTOOL=ec/tool/target/release/system76_ectool
if sudo $ECTOOL info &> /dev/null
then
sudo $ECTOOL flash "build/${MODEL}/ec.rom"
else
echo "WARNING: Skipping EC flash: Could not get System76 EC info"
fi
2020-04-07 12:19:03 -06:00
fi
else
echo "Skipping EC flash"
fi