diff --git a/scripts/_ch341a.sh b/scripts/_ch341a.sh new file mode 100644 index 0000000..86d8ca6 --- /dev/null +++ b/scripts/_ch341a.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if [ ! -d "models/${MODEL}" ] +then + echo "model '${MODEL}' not found" >&2 + exit 1 +fi +MODEL_DIR="$(realpath "models/${MODEL}")" + +if [ ! -f "${MODEL_DIR}/chip.txt" ] +then + echo "model '${MODEL}' does not have chip.txt" >&2 + exit 1 +fi +CHIP="$(cat "${MODEL_DIR}/chip.txt")" diff --git a/scripts/ch341a-dump.sh b/scripts/ch341a-dump.sh new file mode 100755 index 0000000..4582ab8 --- /dev/null +++ b/scripts/ch341a-dump.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +if [ -z "$1" ] +then + echo "$0 [model]" >&2 + exit 1 +fi +MODEL="$1" + +source scripts/_ch341a.sh + +flashrom -p ch341a_spi -c "${CHIP}" -r build/dump.rom + +./coreboot/build/cbfstool build/dump.rom read -r CONSOLE -f build/dump.log + +less build/dump.log diff --git a/scripts/ch341a-flash.sh b/scripts/ch341a-flash.sh new file mode 100755 index 0000000..ff44274 --- /dev/null +++ b/scripts/ch341a-flash.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +if [ -z "$1" ] +then + echo "$0 [model]" >&2 + exit 1 +fi +MODEL="$1" + +source scripts/_ch341a.sh + +flashrom -p ch341a_spi -c "${CHIP}" -w "build/${MODEL}/firmware.rom"