summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorli feng <li1.feng@intel.com>2014-09-08 06:28:04 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-11 21:25:23 +0000
commit31acf49ad29c04daa98682a3cb9e3df827b1aad5 (patch)
tree9cd92dd35f5e84059e06b4af5ec11b7f4690d3b7
parent8894bc5437dbc2d923aa824b22cf82d9a9082352 (diff)
downloadchrome-ec-31acf49ad29c04daa98682a3cb9e3df827b1aad5.tar.gz
strago: Initial board and MEC1322 chip support on flash_ec.
Added flash programming support via servo SPI1 interface. BUG=None TEST=Successfully flashed EC SPI image via servo. BRANCH=none Change-Id: Ib64b4248db8a93ea5025a0f2fe4e44e29134809e Signed-off-by: li feng <li1.feng@intel.com> Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Signed-off-by: Divya Jyothi <divya.jyothi@intel.com> Signed-off-by: icarus sparry <icarus.w.sparry@intel.com> Reviewed-on: https://chromium-review.googlesource.com/256853 Reviewed-by: Shawn N <shawnn@chromium.org>
-rwxr-xr-xutil/flash_ec61
1 files changed, 45 insertions, 16 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 47d6318aff..4d79594cbf 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -82,10 +82,6 @@ BOARDS_STM32=(
zinger
)
-BOARDS_PRIVATE_SPI_PP3300=(
- glower
-)
-
BOARDS_STM32_PROG_EN=(
plankton
)
@@ -100,6 +96,11 @@ BOARDS_NPCX=(
npcx_evb
)
+BOARDS_MEC1322=(
+ glower
+ strago
+)
+
# Flags
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to run debugger on."
@@ -208,9 +209,7 @@ BOARD=${FLAGS_board}
BOARD_ROOT=/build/${BOARD}
# Possible default EC images
-if $(in_array "${BOARDS_PRIVATE_SPI_PP3300[@]}" "${BOARD}"); then
- EC_FILE=ec.spi.bin
-elif [ "${FLAGS_ro}" = ${FLAGS_TRUE} ] ; then
+if [ "${FLAGS_ro}" = ${FLAGS_TRUE} ] ; then
EC_FILE=ec.RO.flat
else
EC_FILE=ec.bin
@@ -271,9 +270,6 @@ if [[ "${MCU}" == "usbpd" ]] ; then
servo_VARS+=" prog_en"
fi
fi
-if $(in_array "${BOARDS_PRIVATE_SPI_PP3300[@]}" "${BOARD}"); then
- servo_VARS+=" spi1_buf_en spi1_buf_on_flex_en spi_hold"
-fi
toad_VARS="${MCU}_uart_parity \
${MCU}_uart_baudrate boot_mode"
@@ -456,10 +452,43 @@ function flash_npcx() {
fi
}
-function flash_private_spi_pp3300() {
- dut_control cold_reset:on spi1_vref:pp3300
- dut_control spi1_buf_en:on spi1_buf_on_flex_en:on spi_hold:off
- sudo flashrom -p ft2232_spi:type=servo-v2,port=B -w "${IMG}"
+function flash_mec1322() {
+ 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 [ ! -x "$FLASHROM" ]; then
+ die "no flashrom util found."
+ fi
+
+ dut_control cold_reset:on
+
+ # Turn on SPI1 interface on servo for 3.3V SPI Flash Chip
+ dut-control spi1_vref:pp3300 spi1_buf_en:on spi1_buf_on_flex_en:on
+
+ SPI_SIZE=$(sudo ${FLASHROM} ${FLASHROM_PARAM} --get-size 2>/dev/null | tail -n 1)
+ IMG_SIZE=$(stat -c%s "$IMG")
+ PATCH_SIZE=$((${SPI_SIZE} - ${IMG_SIZE}))
+
+ # Temp image
+ T=/tmp/flash_mec_$$
+
+ { # Patch temp image up to SPI_SIZE
+ if [[ ${IMG_SIZE} -lt ${SPI_SIZE} ]] ; then
+ dd if=/dev/zero bs=${PATCH_SIZE} count=1 | tr '\0' '\377'
+ fi
+ cat $IMG
+ } > $T
+
+ sudo ${FLASHROM} ${FLASHROM_PARAM} -w "${T}"
+
+ rm $T
+
+ # Turn off SPI1 interface on servo
+ dut_control spi1_vref:off spi1_buf_en:off spi1_buf_on_flex_en:off
+
+ # Do not save/restore servo settings
+ save=
}
if dut_control boot_mode 2>/dev/null ; then
@@ -493,8 +522,8 @@ elif [ "${BOARD}" == "link" ]; then
flash_link
elif $(in_array "${BOARDS_NPCX[@]}" "${BOARD}"); then
flash_npcx
-elif $(in_array "${BOARDS_PRIVATE_SPI_PP3300[@]}" "${BOARD}"); then
- flash_private_spi_pp3300
+elif $(in_array "${BOARDS_MEC1322[@]}" "${BOARD}"); then
+ flash_mec1322
else
die "board ${BOARD} not supported"
fi