From e5f7583cc67ff5ef86ceef94dbb595828410a333 Mon Sep 17 00:00:00 2001 From: Tom Wai-Hong Tam Date: Thu, 23 Jul 2015 01:01:16 +0800 Subject: [PATCH] flash_ec: Add a chip argument The flash_ec uses the given board name to select a proper flashing method. It keeps a mapping from board name to chip name. This approach is not scalable if we want this script to work on all supported board variants, like the pinky family which has many boards: jerry, minnie, speedy, etc. This change adds a new argument of chip name, such that we can only keep the mapping of major boards. Other boards not listed can use the chip argument to select a proper flashing method. BRANCH=none BUG=chromium:505003 TEST=Ran the script on Beaglebone/Servo v3 connected with Jerry: $ flash_ec --chip stm32 --image ec.bin Change-Id: I553ee68f82a7985a37548dfb6e89b364eaffd0f1 Signed-off-by: Tom Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/287445 Reviewed-by: Dan Shi Reviewed-by: Myles Watson --- util/flash_ec | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/util/flash_ec b/util/flash_ec index 9f93de66b2..1faa983caf 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -100,6 +100,8 @@ BOARDS_MEC1322=( # Flags DEFINE_string board "${DEFAULT_BOARD}" \ "The board to run debugger on." +DEFINE_string chip "" \ + "The chip to run debugger on." DEFINE_string image "" \ "Full pathname of the EC firmware image to flash." DEFINE_string offset "0" \ @@ -119,6 +121,10 @@ fi set -e +if [ -z "${FLAGS_board}" -a -z "${FLAGS_chip}" ]; then + die "should specify a board or a chip." +fi + SERVO_TYPE=servo in_array() { @@ -470,17 +476,25 @@ info "${MCU} UART pty : ${EC_UART}" save="$(servo_save)" if $(in_array "${BOARDS_LM4[@]}" "${BOARD}"); then - flash_lm4 + CHIP="lm4" elif $(in_array "${BOARDS_STM32[@]}" "${BOARD}"); then - flash_stm32 + CHIP="stm32" elif $(in_array "${BOARDS_STM32_DFU[@]}" "${BOARD}"); then - flash_stm32_dfu + CHIP="stm32_dfu" elif $(in_array "${BOARDS_NPCX[@]}" "${BOARD}"); then - flash_npcx + CHIP="npcx" elif $(in_array "${BOARDS_MEC1322[@]}" "${BOARD}"); then - flash_mec1322 + CHIP="mec1322" +elif [ -n "${FLAGS_chip}" ]; then + CHIP="${FLAGS_chip}" else die "board ${BOARD} not supported" fi +if [ -n "${FLAGS_chip}" -a "${CHIP}" != "${FLAGS_chip}" ]; then + die "board ${BOARD} doesn't use chip ${FLAGS_chip}" +fi + +info "Flashing chip ${CHIP}." +flash_${CHIP} info "Flashing done."