summaryrefslogtreecommitdiff
path: root/util/flash_ec
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2019-08-15 14:21:47 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-22 03:31:10 +0000
commitae9f43b355f44174450d02c7922cadb8d691aa54 (patch)
treed49646629550ba6427fcb40b00f4a8d547c157b8 /util/flash_ec
parentb5cbdf78a66802e7e9aec6a365d9e5135f2b8e48 (diff)
downloadchrome-ec-ae9f43b355f44174450d02c7922cadb8d691aa54.tar.gz
flash_ec: use active_v4_device
Servo may be using ccd and servo micro. Update the flash_ec servo type to reflect which device actually has control of the DUT, so flash_ec can make the correct decisions about how to flash the device. Add the device prefix to all dut-control commands. If servo is using ccd and servo_micro, ccd controls will be prefixed with 'ccd_cr50.'. Add this prefix to all dut-control commands. BUG=b:35579416 BRANCH=none TEST=flash phaser ec ec using servo_v4_with_servo_micro_and_ccd_cr50, servo_v4_with_servo_micro, and servo_v4_with_ccd_cr50 Change-Id: I3d561ceb3c0ef0d95678c8346fb9922fd44378bf Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1757272 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
Diffstat (limited to 'util/flash_ec')
-rwxr-xr-xutil/flash_ec35
1 files changed, 31 insertions, 4 deletions
diff --git a/util/flash_ec b/util/flash_ec
index f847eb020a..684642532e 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -184,10 +184,18 @@ MSG_VERIFY_FAIL="Failed to verify EC firmware image."
set -e
DUT_CONTROL_CMD=( "dut-control" "--port=${FLAGS_port}" )
+DUT_CTRL_PREFIX=""
function dut_control() {
local DUT_CTRL_CML=( "${DUT_CONTROL_CMD[@]}" )
- DUT_CTRL_CML+=( "$@" )
+
+ for p in $@ ; do
+ # Only add the prefix if the arg is a control name.
+ if [[ ${p} != -* ]] ; then
+ p="${DUT_CTRL_PREFIX}${p}"
+ fi
+ DUT_CTRL_CML+=( "$p" )
+ done
if [ "${FLAGS_verbose}" = ${FLAGS_TRUE} ]; then
echo "${DUT_CTRL_CML[*]}" 1>&2
@@ -207,7 +215,7 @@ function dut_control_get() {
fi
local ARGS DUT_GETVAL RETVAL
- ARGS=( "${DUT_CONTROL_CMD[@]}" "-o" "$1" )
+ ARGS=( "${DUT_CONTROL_CMD[@]}" "-o" "${DUT_CTRL_PREFIX}$1" )
RETVAL=0
# || statement is attached to avoid an exit if error exit is enabled.
DUT_GETVAL=$( "${ARGS[@]}" ) || RETVAL="$?"
@@ -339,6 +347,21 @@ case "${CHIP}" in
esac
SERVO_TYPE="$(dut_control_get servo_type || :)"
+if [[ ${SERVO_TYPE} =~ servo_v4_with_.*_and_.* ]] ; then
+ # If there are two devices, servo v4 type will show both devices. The
+ # default device is first. The other device is second.
+ # servo_type:servo_v4_with_servo_micro_and_ccd_cr50
+ SECOND_DEVICE="${SERVO_TYPE#*_and_}"
+ ACTIVE_DEVICE="$(dut_control_get active_v4_device || :)"
+ SERVO_TYPE="servo_v4_with_${ACTIVE_DEVICE}"
+ # Controls sent through the default device don't have a prefix. The
+ # second device controls do. If the default device isn't active, we
+ # need to use the second device controls to send commands. Use the
+ # prefix for all dut control commands.
+ if [[ "${SECOND_DEVICE}" = "${ACTIVE_DEVICE}" ]] ; then
+ DUT_CTRL_PREFIX="${ACTIVE_DEVICE}."
+ fi
+fi
servo_has_warm_reset() {
dut_control -i warm_reset >/dev/null 2>&1
@@ -636,9 +659,13 @@ declare -a save
function servo_save_add() {
local CTRL_RESULT=
case $# in
- 1) CTRL_RESULT="$( "${DUT_CONTROL_CMD[@]}" "$@" )"
+ 1) CTRL_RESULT="$( "${DUT_CONTROL_CMD[@]}" \
+ "${DUT_CTRL_PREFIX}$@" )"
if [[ -n "${CTRL_RESULT}" ]]; then
- save+=( "${CTRL_RESULT}" )
+ # Don't save the control with the prefix, because
+ # dut_control will add the prefix again when we restore
+ # the settings.
+ save+=( "${CTRL_RESULT#$DUT_CTRL_PREFIX}" )
fi
;;
2) save+=( "$1:$2" )