summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2018-05-04 10:24:29 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-05-24 00:23:13 -0700
commit336be875915c5aa0ae285401c0f60d0c93a563ac (patch)
treec26f76d5ce200a37c0cd24e3f29c984deb153140
parent895b8a903205ac9a3856e6c1ed20b20f1a798361 (diff)
downloadchrome-ec-336be875915c5aa0ae285401c0f60d0c93a563ac.tar.gz
grunt: Add support for flashing via Suzy-Q and servo
When grunt is connected via a Suzy-Q cable, it can only be flashed using npcx_uut. Also when grunt is connected via a servo it shouldn't try to use npcx_uut, but instead use npcx_spi. This change allows a board to show up in multiple BOARDS_XXX lists. If there are multiples, it will either look at the --chips flag, or it will check the VALID_CHIP_COMBO array to see if chip is valid for the servo type. BUG=b:77927814 BRANCH=none TEST=Tested each leg of the logic by changing parameters and variables. Tested using Suzy-Q: ./util/flash_ec --board=grunt Also tested using ServoV2: ./util/flash_ec --board=grunt Change-Id: I7068b5bab0cf20bd2d9ffdd3842a58df1f2f8810 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1044499 Commit-Ready: Martin Roth <martinroth@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
-rwxr-xr-xutil/flash_ec125
1 files changed, 97 insertions, 28 deletions
diff --git a/util/flash_ec b/util/flash_ec
index c14911ed90..d78dc3f142 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -143,6 +143,7 @@ BOARDS_NPCX_INT_SPI=(
BOARDS_NPCX_UUT=(
cheza
+ grunt
)
BOARDS_NRF51=(
@@ -176,6 +177,14 @@ BOARDS_RAIDEN=(
soraka
)
+# A map of supported board + chip + servo permutations.
+# The value is a regex that will be checked against $SERVO_TYPE.
+# i.e., If a board needs to use one CHIP when connected via a Suzy-Q and another
+# chip when connected via a Servo.
+declare -A VALID_CHIP_COMBO
+VALID_CHIP_COMBO["grunt.npcx_uut"]="ccd_cr50"
+VALID_CHIP_COMBO["grunt.npcx_spi"]="servo"
+
# Flags
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to run debugger on."
@@ -240,36 +249,97 @@ in_array() {
return 1
}
+declare -a SUPPORTED_CHIPS
+
if $(in_array "${BOARDS_LM4[@]}" "${BOARD}"); then
- CHIP="lm4"
-elif $(in_array "${BOARDS_STM32[@]}" "${BOARD}"); then
- CHIP="stm32"
-elif $(in_array "${BOARDS_STM32_DFU[@]}" "${BOARD}"); then
- CHIP="stm32_dfu"
-elif $(in_array "${BOARDS_NPCX_5M5G_JTAG[@]}" "${BOARD}"); then
- CHIP="npcx_5m5g_jtag"
-elif $(in_array "${BOARDS_NPCX_5M6G_JTAG[@]}" "${BOARD}"); then
- CHIP="npcx_5m6g_jtag"
-elif $(in_array "${BOARDS_NPCX_7M6X_JTAG[@]}" "${BOARD}"); then
- CHIP="npcx_7m6x_jtag"
-elif $(in_array "${BOARDS_NPCX_7M7X_JTAG[@]}" "${BOARD}"); then
- CHIP="npcx_7m7x_jtag"
-elif $(in_array "${BOARDS_NPCX_SPI[@]}" "${BOARD}"); then
- CHIP="npcx_spi"
-elif $(in_array "${BOARDS_NPCX_INT_SPI[@]}" "${BOARD}"); then
- CHIP="npcx_spi"
-elif $(in_array "${BOARDS_NPCX_UUT[@]}" "${BOARD}"); then
- CHIP="npcx_uut"
-elif $(in_array "${BOARDS_NRF51[@]}" "${BOARD}"); then
- CHIP="nrf51"
-elif $(in_array "${BOARDS_MEC1322[@]}" "${BOARD}"); then
- CHIP="mec1322"
-elif $(in_array "${BOARDS_IT83XX[@]}" "${BOARD}"); then
- CHIP="it83xx"
+ SUPPORTED_CHIPS+=("lm4")
+fi
+
+if $(in_array "${BOARDS_STM32[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("stm32")
+fi
+
+if $(in_array "${BOARDS_STM32_DFU[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("stm32_dfu")
+fi
+
+if $(in_array "${BOARDS_NPCX_5M5G_JTAG[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("npcx_5m5g_jtag")
+fi
+
+if $(in_array "${BOARDS_NPCX_5M6G_JTAG[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("npcx_5m6g_jtag")
+fi
+
+if $(in_array "${BOARDS_NPCX_7M6X_JTAG[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("npcx_7m6x_jtag")
+fi
+
+if $(in_array "${BOARDS_NPCX_7M7X_JTAG[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("npcx_7m7x_jtag")
+fi
+
+if $(in_array "${BOARDS_NPCX_SPI[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("npcx_spi")
+fi
+
+if $(in_array "${BOARDS_NPCX_INT_SPI[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("npcx_spi")
+fi
+
+if $(in_array "${BOARDS_NPCX_UUT[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("npcx_uut")
+fi
+
+if $(in_array "${BOARDS_NRF51[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("nrf51")
+fi
+
+if $(in_array "${BOARDS_MEC1322[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("mec1322")
+fi
+
+if $(in_array "${BOARDS_IT83XX[@]}" "${BOARD}"); then
+ SUPPORTED_CHIPS+=("it83xx")
+fi
+
+if [[ ${#SUPPORTED_CHIPS[@]} -eq 0 && -n "${FLAGS_chip}" ]]; then
+ SUPPORTED_CHIPS+="${FLAGS_chip}"
+fi
+
+SERVO_TYPE="$(get_servo_type)"
+
+if [[ ${#SUPPORTED_CHIPS[@]} -eq 0 ]]; then
+ die "board '${BOARD}' not supported. Please manually specify --chip="
+elif [[ ${#SUPPORTED_CHIPS[@]} -eq 1 ]]; then
+ CHIP="${SUPPORTED_CHIPS[0]}"
elif [ -n "${FLAGS_chip}" ]; then
- CHIP="${FLAGS_chip}"
+ if $(in_array "${SUPPORTED_CHIPS[@]}" "${FLAGS_chip}"); then
+ CHIP="${FLAGS_chip}"
+ else
+ die "board ${BOARD} only supports (${SUPPORTED_CHIPS[@]})," \
+ "not ${FLAGS_chip}."
+ fi
else
- die "board ${BOARD} not supported"
+ declare -a FILTERED_CHIPS
+
+ for i in "${SUPPORTED_CHIPS[@]}"; do
+ SUPPORTED_SERVO="${VALID_CHIP_COMBO["${BOARD}.${i}"]}"
+ if [[ -z "$SUPPORTED_SERVO" || \
+ "$SERVO_TYPE" =~ "$SUPPORTED_SERVO" ]]; then
+ FILTERED_CHIPS+=("$i")
+ fi
+
+ done
+
+ if [[ ${#FILTERED_CHIPS[@]} -eq 0 ]]; then
+ die "servo ${SERVO_TYPE} is unsupported for board ${BOARD}."
+ elif [[ ${#FILTERED_CHIPS[@]} -eq 1 ]]; then
+ CHIP="${FILTERED_CHIPS[0]}"
+ else
+ die "board ${BOARD} supports multiple chips" \
+ "(${FILTERED_CHIPS[@]}). Use --chip= to choose one."
+ fi
fi
if [ -n "${FLAGS_chip}" -a "${CHIP}" != "${FLAGS_chip}" ]; then
@@ -1022,7 +1092,6 @@ function flash_mec1322() {
flash_flashrom
}
-SERVO_TYPE="$(get_servo_type)"
if dut_control boot_mode 2>/dev/null ; then
if [[ "${MCU}" != "ec" ]] ; then
die "Toad cable can't support non-ec UARTs"