diff options
author | Namyoon Woo <namyoon@chromium.org> | 2019-02-27 10:37:12 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-01 23:41:38 -0800 |
commit | 5bc9bd321c07175ebfa0166df4d207428e1c276e (patch) | |
tree | c644030eee52397b1e27555fab3557f5500fc875 /util/flash_ec | |
parent | cfcb655fdc5e230f0255d9721c0ea4b0f9b4c51c (diff) | |
download | chrome-ec-5bc9bd321c07175ebfa0166df4d207428e1c276e.tar.gz |
flash_ec: get ec_chip from servod
Get ec_chip info from servod, and use it in case ec chip is not
listed in the board-to-chip conversion array, and if --chip is
not given in the command line.
CQ-DEPEND=CL:1491936
BUG=b:125837387
BRANCH=none
TEST=manually ran flash_ec.
$ ./util/flash_ec --board=samus --image ${IMG}
$ ./util/flash_ec --board=coral --image ${IMG}
$ ./util/flash_ec --board=grunt --image ${IMG}
$ ./util/flash_ec --board=bip --image ${IMG}
Change-Id: I68e7bcd38510c4d01f4427e1d8be3df50d6e65e0
Signed-off-by: Namyoon Woo <namyoon@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1493037
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'util/flash_ec')
-rwxr-xr-x | util/flash_ec | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/util/flash_ec b/util/flash_ec index 7dc745fcd8..7e761d78e1 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -46,6 +46,9 @@ die() { } +# Include a board name to the BOARDS_${EC_CHIP} array below ONLY IF servod is +# not aware of its 'ec_chip'. If servod becomes able to answer 'ec_chip' +# for the board, remove it from BOARDS_XXXX array below. BOARDS_IT83XX=( ampton bip @@ -251,10 +254,6 @@ fi set -e -if [ -z "${FLAGS_board}" -a -z "${FLAGS_chip}" ]; then - die "should specify a board or a chip." -fi - DUT_CONTROL_CMD="dut-control --port=${FLAGS_port}" function dut_control() { @@ -271,6 +270,17 @@ function get_servo_type() { fi } +SERVO_EC_CHIP="$(($DUT_CONTROL_CMD ec_chip) | sed -e s/ec_chip://)" +SERVO_EC_CHIP="${SERVO_EC_CHIP,,}" +if [[ "${SERVO_EC_CHIP}" =~ "unknown" ]]; then + SERVO_EC_CHIP="" +fi + +if [[ -z "${FLAGS_board}" && -z "${FLAGS_chip}" && \ + -z "${SERVO_EC_CHIP}" ]]; then + die "should specify a board or a chip." +fi + BOARD=${FLAGS_board} in_array() { @@ -343,9 +353,16 @@ if [[ ${#SUPPORTED_CHIPS[@]} -eq 0 && -n "${FLAGS_chip}" ]]; then SUPPORTED_CHIPS+="${FLAGS_chip}" fi +if [[ ${#SUPPORTED_CHIPS[@]} -eq 0 && -n "${SERVO_EC_CHIP}" ]]; then + SUPPORTED_CHIPS+=("${SERVO_EC_CHIP}") +fi + SERVO_TYPE="$(get_servo_type)" if [[ ${#SUPPORTED_CHIPS[@]} -eq 0 ]]; then + # This happens if ${FLAGS_board} is not known in this flash_ec yet, + # ${FLAGS_chip} is not given, and servod doesn't know ec_chip. + # In this case, '--chip' should be specified in the command line. die "board '${BOARD}' not supported. Please manually specify --chip=" elif [[ ${#SUPPORTED_CHIPS[@]} -eq 1 ]]; then CHIP="${SUPPORTED_CHIPS[0]}" |