summaryrefslogtreecommitdiff
path: root/util/flash_fp_mcu
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2021-02-10 11:22:57 -0800
committerCommit Bot <commit-bot@chromium.org>2021-04-29 00:17:24 +0000
commit502845b84b190a965d1968c894326a71bf9a27a9 (patch)
treef4053d52397a5d37b0b19869f4e8566b577257b4 /util/flash_fp_mcu
parent4710b10f75d51e38725df5da00814a5a167a133b (diff)
downloadchrome-ec-502845b84b190a965d1968c894326a71bf9a27a9.tar.gz
flash_fp_mcu: Fix gpio get error propagation issue
BRANCH=none BUG=none TEST=# Verified on initial version of CoachZ TEST=scp util/flash_fp_mcu dut1:/usr/local/bin/flash_fp_mcu ssh dut1 flash_fp_mcu --hello Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I4c8d95234862b6b4b4a344586ab373e9bf17a5e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2688155
Diffstat (limited to 'util/flash_fp_mcu')
-rw-r--r--util/flash_fp_mcu28
1 files changed, 22 insertions, 6 deletions
diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu
index 552606adef..468b832d5b 100644
--- a/util/flash_fp_mcu
+++ b/util/flash_fp_mcu
@@ -111,6 +111,24 @@ gpio() {
done
}
+# Usage: warn_gpio <signal> <expected_value> <msg>
+warn_gpio() {
+ local signal=$1
+ local expected_value=$2
+ local msg=$3
+
+ local value
+ if ! value="$(gpio get "${signal}")"; then
+ echo "Error fetching gpio value ${signal}" >&2
+ exit 1
+ fi
+
+ if [[ "${value}" != "${expected_value}" ]]; then
+ echo "${msg}" >&2
+ return 1
+ fi
+}
+
# Taken verbatim from
# https://chromium.googlesource.com/chromiumos/docs/+/master/lsb-release.md#shell
# This should not be used by anything except get_platform_name.
@@ -268,12 +286,10 @@ flash_fp_mcu_stm32() {
# We do not expect the drivers to change the pin state when binding.
# If you receive this warning, the driver needs to be fixed on this board
# and this flash attempt will probably fail.
- if [[ $(gpio get "${gpio_boot0}") -ne 1 ]]; then
- echo "WARNING: One of the drivers changed BOOT0 pin state on bind attempt."
- fi
- if [[ $(gpio get "${gpio_nrst}") -ne 0 ]]; then
- echo "WARNING: One of the drivers changed NRST pin state on bind attempt."
- fi
+ warn_gpio "${gpio_boot0}" 1 \
+ "WARNING: One of the drivers changed BOOT0 pin state on bind attempt."
+ warn_gpio "${gpio_nrst}" 0 \
+ "WARNING: One of the drivers changed NRST pin state on bind attempt."
# TODO(b/179530529): Remove this hack when the drivers on strongbad stop
# setting the gpio states.