summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Luo <aluo@google.com>2022-01-13 14:00:45 -0800
committerCommit Bot <commit-bot@chromium.org>2022-01-14 23:20:01 +0000
commitd746307808af0151293ce63c08f03237519866cc (patch)
treef4f891b3dac1925c2b696f31321065005a0177fe
parent6e04673962dc439f796f8421edb403d8a4e3b45f (diff)
downloadchrome-ec-d746307808af0151293ce63c08f03237519866cc.tar.gz
Add rescue path and early options for brescue.sh
BUG=b:214266426 TEST=RESCUE=../cr50-utils/software/tools/SPI/rescue EARLY=1 \ TEST= util/brescue.sh ti50.bin /dev/ttyUSB5 TEST=util/brescue.sh ti50.bin /dev/ttyUSB5 Change-Id: I427b9c16896ddf9f12cf78f185e7718e23786648 Signed-off-by: Andrew Luo <aluo@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3388229 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Andrew Luo <aluo@chromium.org> Tested-by: Andrew Luo <aluo@chromium.org>
-rwxr-xr-xutil/brescue.sh21
1 files changed, 17 insertions, 4 deletions
diff --git a/util/brescue.sh b/util/brescue.sh
index 163f6ed6b8..16bf9cfbec 100755
--- a/util/brescue.sh
+++ b/util/brescue.sh
@@ -13,13 +13,18 @@
# and starts the rescue utility to send the RW to the chip. The user is
# supposed to reset the chip to trigger the rescue session.
#
-# In invoked with nonempty NOCLEAN environment variable the script preserves
+# If invoked with RESCUE environment variable set to a path, the script will try
+# to use the rescue binary at that path.
+#
+# If invoked with nonempty NOCLEAN environment variable, the script preserves
# the hex RW image it creates.
+#
+# If invoked with nonempty EARLY environment variable, the script passes the
+# --early option to rescue.
TMPD="$(mktemp -d "/tmp/$(basename "$0").XXXXX")"
-RESCUE=
-for r in rescue cr50-rescue; do
+for r in ${RESCUE} rescue cr50-rescue; do
if type "${r}" > /dev/null 2>&1; then
RESCUE="${r}"
break
@@ -34,6 +39,12 @@ if [[ -z "${NOCLEAN}" ]]; then
trap 'rm -rf "${TMPD}"' EXIT
fi
+# --early could help to improve success rate depending on setup.
+early=''
+if [[ -n "${EARLY}" ]]; then
+ early='--early'
+fi
+
dest_hex="${TMPD}/rw.hex"
dest_bin="${TMPD}/rw.bin"
errorf="${TMPD}/error"
@@ -118,4 +129,6 @@ if ! objcopy -I binary -O ihex --change-addresses "${addr}" \
fi
echo "converted to ${dest_hex}, waiting for target reset"
-"${RESCUE}" "${chip_extension}" -d "${device}" -v -i "${dest_hex}"
+echo "${RESCUE}" "${chip_extension}" -d "${device}" "${early}" -v -i \
+ "${dest_hex}"
+"${RESCUE}" "${chip_extension}" -d "${device}" "${early}" -v -i "${dest_hex}"