summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-01-04 13:28:15 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-18 05:09:35 -0800
commit289347ad6aa4aae56cb90b42b6655ae49ecbb337 (patch)
tree743e4ddf7e7f7833219c3066843c97fd2547bb7d
parentbc4b786156b3dd51de75f512d05679d5b413399b (diff)
downloadchrome-ec-289347ad6aa4aae56cb90b42b6655ae49ecbb337.tar.gz
flash_ec: Support NPCX_INT_SPI using CCD.
A few things needed to be moved around in order for flashing the npcx7 to work over CCD. This commit makes those changes and fixes a small bug with the serial number parameter for raiden devices. (It just needed a space). It also fixes using just a SuzyQable to flash. BUG=b:71548795 BRANCH=None TEST=`./util/flash_ec --board meowth` with a servo_v4 and verify that flashing is successful. TEST=Repeat above test with a servo_v2. TEST=Repeat above test with a servo_micro. TEST=Repeat above test with a SuzyQable. Change-Id: I8ff22fb1d2a5fe7af2ad30a14bf896dbae65c024 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/851354 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
-rwxr-xr-xutil/flash_ec43
1 files changed, 35 insertions, 8 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 927135ca87..e7136e33b1 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -299,6 +299,10 @@ servo_sh_hard_reset() {
dut_control sh_reset:off
}
+ccd_cr50_ec_hard_reset() {
+ servo_ec_hard_reset
+}
+
ec_reset() {
stype=${SERVO_TYPE}
if [[ "${SERVO_TYPE}" =~ "servo" ]] ; then
@@ -354,6 +358,7 @@ on_servov3() {
error_reported= # Avoid double printing the error message.
on_raiden() {
if [[ "${SERVO_TYPE}" =~ "servo_v4" ]] || \
+ [[ "${SERVO_TYPE}" =~ "ccd_cr50" ]] || \
[[ "${SERVO_TYPE}" =~ "servo_micro" ]]; then
return 0
fi
@@ -385,7 +390,7 @@ cleanup() {
kill -CONT ${pid}
done
- if ! on_raiden || [[ "${SERVO_TYPE}" =~ "servo_micro" ]] ; then
+ if ! on_raiden || $(servo_has_cold_reset); then
ec_reset
fi
}
@@ -589,6 +594,17 @@ function flash_flashrom() {
die "no flashrom util found."
fi
+ # Check whether the SPI flash is internal to the NPCX's EC.
+ #
+ # If the in_array function return non-zero, the script will exit.
+ # Therefore, temporarily ignore errors so we can capture the return
+ # value.
+ set +e
+ local board_is_npcx_internal_spi
+ $(in_array "${BOARDS_NPCX_INT_SPI[@]}" "${BOARD}")
+ board_is_npcx_internal_spi=$?
+ set -e # Okay, don't ignore errors anymore.
+
if ! on_servov3; then
SERIALNAME=$(get_serial)
if [[ "$SERIALNAME" != "" ]] ; then
@@ -606,7 +622,7 @@ function flash_flashrom() {
dut_control cold_reset:on
# If spi flash is in npcx's ec, enable gang programer mode
- if $(in_array "${BOARDS_NPCX_INT_SPI[@]}" "${BOARD}"); then
+ if [ $board_is_npcx_internal_spi -eq 0 ]; then
# Set GP_SEL# as low then start ec
dut_control fw_up:on
sleep 0.1
@@ -627,6 +643,17 @@ function flash_flashrom() {
sleep 1
fi
else
+ if [ $board_is_npcx_internal_spi -eq 0 ]; then
+ # Set GP_SEL# as low then start ec
+ dut_control cold_reset:on
+ dut_control fw_up:on
+ # sleep 0.1
+ dut_control cold_reset:off
+ else
+ # Assert EC reset.
+ dut_control cold_reset:on
+ fi
+
# Temp layout
L=/tmp/flash_spi_layout_$$
@@ -636,7 +663,6 @@ function flash_flashrom() {
--fast-verify"
fi
-
# flashrom should report the image size at the end of the output.
FLASHROM_CMDLINE="sudo ${FLASHROM} ${FLASHROM_PARAM} --get-size"
if [ "${FLAGS_verbose}" = ${FLAGS_TRUE} ]; then
@@ -673,7 +699,7 @@ function flash_flashrom() {
# Generate the correct flashrom command to write the ec.
FLASHROM_CMDLINE="${FLASHROM} ${FLASHROM_PARAM}"
- FLASHROM_CMDLINE+="${FLASHROM_OPTIONS} -w ${T}"
+ FLASHROM_CMDLINE+=" ${FLASHROM_OPTIONS} -w ${T}"
if [ "${FLAGS_verbose}" = ${FLAGS_TRUE} ]; then
echo "Running flashrom:" 1>&2
@@ -684,6 +710,11 @@ function flash_flashrom() {
rm $T
+ # Set GP_SEL# as default to disable GP mode when ec reboots
+ if [ $board_is_npcx_internal_spi -eq 0 ]; then
+ dut_control fw_up:off
+ fi
+
if ! on_raiden || [[ "${SERVO_TYPE}" =~ "servo_micro" ]] ; then
# Turn off SPI1 interface on servo
dut_control spi1_vref:off spi1_buf_en:off
@@ -691,10 +722,6 @@ function flash_flashrom() {
dut_control spi1_buf_on_flex_en:off
fi
- # Set GP_SEL# as default to disable GP mode when ec reboots
- if $(in_array "${BOARDS_NPCX_INT_SPI[@]}" "${BOARD}"); then
- dut_control fw_up:off
- fi
else
rm $L
fi