summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2013-04-12 12:16:11 -0700
committerChromeBot <chrome-bot@google.com>2013-04-16 09:44:50 -0700
commit67f2910ff16803f3e94099509c5945f2345023af (patch)
tree0bdad9a98f9c7e96193d5323d1451d564e8244bf
parent8b3262d644003b3c9727998dc8d4b0c749450aef (diff)
downloadchrome-ec-67f2910ff16803f3e94099509c5945f2345023af.tar.gz
flash_ec: add support for flashing with Toad cable
Add support for flashing Spring board through the Toad cable (given the Write Protect screw is not on). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=spring BUG=chrome-os-partner:17570 TEST=with both a Toad cable and a servo v2, flash EC on Spring EVT with the following command: ./util/flash_ec --board=spring and check the state of the servo/toad before and after. Original-Change-Id: Ia4e0d32b062d58b4e906d3f006003fa6097add83 Reviewed-on: https://gerrit.chromium.org/gerrit/48031 Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 0498d687326aca32e074e74e970a6e32fc839d93) Change-Id: I0b0eec32a46671bc2f63fc757e2a3db8db814f00 Reviewed-on: https://gerrit.chromium.org/gerrit/48224 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
-rwxr-xr-xutil/flash_ec60
1 files changed, 48 insertions, 12 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 3fbe203e27..1e295222cb 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -29,15 +29,43 @@ check_flags_only_and_allow_null_arg "$@" && set --
set -e
+SERVO_TYPE=servo
+
+# reset the EC
+toad_hard_reset() {
+ info "you probably need to hard-reset your EC with Refresh+Power"
+}
+
+servo_hard_reset() {
+ dut_control cold_reset:on
+ dut_control cold_reset:off
+}
+
+ec_reset() {
+ eval ${SERVO_TYPE}_hard_reset
+}
+
+# force the EC to boot in serial monitor mode
+toad_boot0() {
+ dut_control boot_mode:yes
+}
+
+servo_boot0() {
+ dut_control spi1_vref:pp3300
+}
+
+ec_enable_boot0() {
+ eval ${SERVO_TYPE}_boot0
+}
+
+# Put back the servo and the system in a clean state at exit
cleanup() {
if [ -n "${save}" ]; then
info "Restoring servo settings..."
servo_restore "$save"
fi
- # reset the EC
- dut_control cold_reset:on
- dut_control cold_reset:off
+ ec_reset
}
trap cleanup EXIT
@@ -80,21 +108,23 @@ DUT_CONTROL_CMD="dut-control --port=${FLAGS_port}"
# Find the EC UART on the servo v2
function ec_uart() {
SERVOD_FAIL="Cannot communicate with servo. is servod running ?"
- ($DUT_CONTROL_CMD uart1_pty || \
+ ($DUT_CONTROL_CMD ec_uart_pty || \
die "${SERVOD_FAIL}") | cut -d: -f2
}
# Servo variables management
-SERVO_VARS="uart1_en uart1_parity uart1_baudrate \
+servo_VARS="ec_uart_en ec_uart_parity ec_uart_baudrate \
jtag_buf_on_flex_en jtag_buf_en spi1_vref"
+toad_VARS="ec_uart_parity ec_uart_baudrate boot_mode"
function dut_control() {
$DUT_CONTROL_CMD "$1" >/dev/null
}
function servo_save() {
- $DUT_CONTROL_CMD ${SERVO_VARS}
+ SERVO_VARS_NAME=${SERVO_TYPE}_VARS
+ $DUT_CONTROL_CMD ${!SERVO_VARS_NAME}
}
function servo_restore() {
@@ -119,14 +149,15 @@ function flash_daisy() {
info "Using serial flasher : ${STM32MON}"
- dut_control uart1_en:on
- dut_control uart1_parity:even
- dut_control uart1_baudrate:115200
+ if [ "${SERVO_TYPE}" = "servo" ] ; then
+ dut_control ec_uart_en:on
+ fi
+ dut_control ec_uart_parity:even
+ dut_control ec_uart_baudrate:115200
# force the EC to boot in serial monitor mode
- dut_control spi1_vref:pp3300
+ ec_enable_boot0
# reset the EC
- dut_control cold_reset:on
- dut_control cold_reset:off
+ ec_reset
${STM32MON} -d ${EC_UART} -e -w ${IMG}
}
@@ -153,6 +184,11 @@ info "Using EC image : ${IMG}"
EC_UART="$(ec_uart)"
info "EC UART pty : ${EC_UART}"
+if dut_control uart_mux 2>/dev/null ; then
+ SERVO_TYPE=toad
+ info "Using a TOAD cable"
+fi
+
save="$(servo_save)"
case "${BOARD}" in