flash_ec: Accomodate using flashrom on beaglebone

Currently, using flash_ec for mec1322 chips only
supports flashing from servo v2.  Updated to work from
v3 as well.  This is a resubmission.

BUG=chromium:554230
BRANCH=None
TEST=tested locally with beaglebone/cyan setup at my desk
     Ran flash_ec --board=cyan --chip=mec1322
     --image=/tmp/image.bin.  Also ran with servov2.

Change-Id: Ia2a7edb577350cd4aa1c9835f24f4e3df2e508e2
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313053
Reviewed-by: Wai-Hong Tam <waihong@chromium.org>
This commit is contained in:
Shelley Chen
2015-11-18 16:29:19 -08:00
committed by chrome-bot
parent 0ddef3548b
commit 06c2b877d6

View File

@@ -232,6 +232,11 @@ ec_enable_boot0() {
eval ${SERVO_TYPE}_${MCU}_boot0
}
# Returns 0 on success (if on beaglebone)
on_servov3() {
grep -qs '^CHROMEOS_RELEASE_BOARD=beaglebone_servo' /etc/lsb-release
}
# Put back the servo and the system in a clean state at exit
FROZEN_PIDS=""
cleanup() {
@@ -375,15 +380,21 @@ function flash_openocd() {
function flash_flashrom() {
TOOL_PATH="${EC_DIR}/build/${BOARD}/util:/usr/sbin/:$PATH"
FLASHROM=$(PATH="${TOOL_PATH}" which flashrom)
FLASHROM_PARAM="-p ft2232_spi:type=servo-v2,port=B"
if on_servov3; then
FLASHROM_PARAM="-p linux_spi"
else
FLASHROM_PARAM="-p ft2232_spi:type=servo-v2,port=B"
fi
if [ ! -x "$FLASHROM" ]; then
die "no flashrom util found."
fi
SERIALNAME=$(${DUT_CONTROL_CMD} serialname | cut -d: -f2)
if [[ "$SERIALNAME" != "" ]] ; then
FLASHROM_PARAM="${FLASHROM_PARAM},serial=${SERIALNAME}"
if ! on_servov3; then
SERIALNAME=$(${DUT_CONTROL_CMD} serialname | cut -d: -f2)
if [[ "$SERIALNAME" != "" ]] ; then
FLASHROM_PARAM="${FLASHROM_PARAM},serial=${SERIALNAME}"
fi
fi
dut_control cold_reset:on