summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2015-09-17 21:21:00 +0800
committerchrome-bot <chrome-bot@chromium.org>2015-09-21 20:50:56 -0700
commit95ea672601681d01166cf2b8c6cbd297dcc9295a (patch)
tree7731db4c2d1792e91671b248482a23dff9b24448 /util
parentb03f92fbccb4cd07edee75b6eea654692f3dbdf9 (diff)
downloadchrome-ec-95ea672601681d01166cf2b8c6cbd297dcc9295a.tar.gz
nuc: Fixed flash layout issue for npcx
Fixed flash layout issue for npcx Modified drivers: 1. config_flash_layout.h: Fixed layout issue for npcx 2. flash_ec: add flashrom support for boards without JTAG in servo connector BUG=chrome-os-partner:34346 TEST=make buildall -j; test nuvoton IC specific drivers BRANCH=none Change-Id: I0b9b679c52b8a8e2a26c278b5024d0350fb77338 Reviewed-on: https://chromium-review.googlesource.com/300392 Commit-Ready: Mulin Chao <mlchao@nuvoton.com> Tested-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/flash_ec117
1 files changed, 71 insertions, 46 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 96bdb85fbc..d45cd6913b 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -81,11 +81,15 @@ BOARDS_STM32_DFU=(
twinkie
)
-BOARDS_NPCX=(
+BOARDS_NPCX_JTAG=(
npcx_evb
npcx_evb_arm
)
+BOARDS_NPCX_SPI=(
+ wheatley
+)
+
BOARDS_NRF51=(
hadoken
)
@@ -341,6 +345,62 @@ function flash_openocd() {
die "Failed to program ${IMG}"
}
+# helper function for using servo v2/3 with flashrom
+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 [ ! -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}"
+ 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_spi_$$
+
+if $(in_array "${BOARDS_NPCX_SPI[@]}" "${BOARD}"); then
+ { # Patch temp image up to SPI_SIZE
+ cat $IMG
+ if [[ ${IMG_SIZE} -lt ${SPI_SIZE} ]] ; then
+ dd if=/dev/zero bs=${PATCH_SIZE} count=1 | tr '\0' '\377'
+ fi
+ } > $T
+else
+ { # 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
+fi
+
+
+ sudo timeout -k 10 -s 9 "${FLAGS_timeout}" \
+ ${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=
+}
+
function flash_stm32() {
TOOL_PATH="${EC_DIR}/build/${BOARD}/util:$PATH"
STM32MON=$(PATH="${TOOL_PATH}" which stm32mon)
@@ -418,7 +478,7 @@ function flash_nrf51() {
dut_control swd_reset:on swd_reset:off
}
-function flash_npcx() {
+function flash_npcx_jtag() {
IMG_PATH="${EC_DIR}/build/${BOARD}"
OCD_CHIP_CFG="npcx_chip.cfg"
if [ "${FLAGS_ro}" = ${FLAGS_TRUE} ] ; then
@@ -435,49 +495,12 @@ function flash_npcx() {
flash_openocd
}
-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
-
- SERIALNAME=$(${DUT_CONTROL_CMD} serialname | cut -d: -f2)
- if [[ "$SERIALNAME" != "" ]] ; then
- FLASHROM_PARAM="${FLASHROM_PARAM},serial=${SERIALNAME}"
- 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 timeout -k 10 -s 9 "${FLAGS_timeout}" \
- ${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
+function flash_npcx_spi() {
+ flash_flashrom
+}
- # Do not save/restore servo settings
- save=
+function flash_mec1322() {
+ flash_flashrom
}
if dut_control boot_mode 2>/dev/null ; then
@@ -502,8 +525,10 @@ elif $(in_array "${BOARDS_STM32[@]}" "${BOARD}"); then
CHIP="stm32"
elif $(in_array "${BOARDS_STM32_DFU[@]}" "${BOARD}"); then
CHIP="stm32_dfu"
-elif $(in_array "${BOARDS_NPCX[@]}" "${BOARD}"); then
- CHIP="npcx"
+elif $(in_array "${BOARDS_NPCX_JTAG[@]}" "${BOARD}"); then
+ CHIP="npcx_jtag"
+elif $(in_array "${BOARDS_NPCX_SPI[@]}" "${BOARD}"); then
+ CHIP="npcx_spi"
elif $(in_array "${BOARDS_NRF51[@]}" "${BOARD}"); then
CHIP="nrf51"
elif $(in_array "${BOARDS_MEC1322[@]}" "${BOARD}"); then