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 <waihong@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/287445
Reviewed-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Myles Watson <mylesgw@chromium.org>
This commit is contained in:
Tom Wai-Hong Tam
2015-07-23 01:01:16 +08:00
committed by ChromeOS Commit Bot
parent 90741a36a5
commit e5f7583cc6

View File

@@ -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."