From bc1a6ca25b3895fb326f6230e7edf27e129ee154 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Fri, 19 Jun 2020 14:52:36 -0600 Subject: [PATCH] scripts: Add script to automate new board bringup --- scripts/generate.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 scripts/generate.sh diff --git a/scripts/generate.sh b/scripts/generate.sh new file mode 100755 index 0000000..616f928 --- /dev/null +++ b/scripts/generate.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# +# Copyright 2020 System76 + +set -e + +SCRIPT_DIR=$(dirname "$0") + +if [ -z "$1" ] || [ -z "$2" ] +then + echo "$0 [ec.rom]" >&2 + exit 1 +fi +MODEL="$1" + +if [ ! -f "$2" ] +then + echo "Could not find BIOS image '$2'" >&2 + exit 1 +fi +BIOS_IMAGE=$(realpath "$2") + +EC_ROM= +if [ -n "$3" ] +then + if [ ! -f "$3" ] + then + echo "Could not find EC ROM '$3'" >&2 + exit 1 + fi + + EC_ROM=$(realpath "$3") +fi + +if [ ! -d "models/${MODEL}" ] +then + echo "Generating for new model '${MODEL}'" + mkdir "models/${MODEL}" + read -rp "Manufacturer: " _mfr + read -rp "Produce name: " _name + read -rp "Product version: " _version + echo "# ${_mfr} ${_name} (${_version})" > "models/${MODEL}/README.md.in" +fi +MODEL_DIR=$(realpath "models/${MODEL}") + +echo "Generating data for coreboot..." + +cargo build --release --manifest-path=tools/coreboot-collector/Cargo.toml +sudo ./tools/coreboot-collector/target/release/coreboot-collector > "${MODEL_DIR}/coreboot-collector.txt" + +${SCRIPT_DIR}/coreboot-gpio.sh "${MODEL_DIR}/coreboot-collector.txt" > "${MODEL_DIR}/gpio.h" +${SCRIPT_DIR}/coreboot-hda.sh "${MODEL_DIR}/coreboot-collector.txt" > "${MODEL_DIR}/hda.h" + +# Get the flash descriptor and Intel ME blobs +make -C coreboot/util/ifdtool +coreboot/util/ifdtool/ifdtool -x "${BIOS_IMAGE}" +# TODO: Don't hardcode flash region index +mv flashregion_0_flashdescriptor.bin "${MODEL_DIR}/fd.rom" +mv flashregion_2_intel_me.bin "${MODEL_DIR}/me.rom" +rm -f flashregion_*.bin + +# XXX: More reliable way to determine if system has an EC? +DMI_CHASSIS_TYPE=$(cat /sys/class/dmi/id/chassis_type) +if [ "${DMI_CHASSIS_TYPE}" = "9" ] || [ "${DMI_CHASSIS_TYPE}" = "10" ] +then + if [ -n "${EC_ROM}" ] + then + echo "Using proprietary EC ROM file" + cp "${EC_ROM}" "${MODEL_DIR}/ec.rom" + else + echo "Generating output for System76 EC firmware" + cargo build --release --manifest-path=ec/ecspy/Cargo.toml + # TODO: Set backlights and fans to max and restore after + sudo ./ec/ecspy/target/release/ecspy > "${MODEL_DIR}/ecspy.txt" + # Strip EC RAM entries from output + sed -i '/^0x/d' "${MODEL_DIR}/ecspy.txt" + fi +fi + +${SCRIPT_DIR}/readmes.sh