summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Wai-Hong Tam <waihong@chromium.org>2015-07-29 05:26:24 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-04 19:21:57 +0000
commit12495e2b40eb4c5abb2202effd47ec131b43dc89 (patch)
tree66eba2c915424f84773d7908bb393b7f9dbebcf8
parentb61de792ef91e30270b8be591f044d9c13e2aeb0 (diff)
downloadchrome-ec-12495e2b40eb4c5abb2202effd47ec131b43dc89.tar.gz
flash_ec: Set a 10-minute timeout for flashing EC
The flash_ec script is called by the lab infrastructure to flash the EC firmware of DUT. To prevent the EC flashing tool hanged forever (may be caused by some bugs), set a 10-minute timeout to force it to be killed. BRANCH=none BUG=chromium:514810 TEST=Patched the change to servo v3. Triggered flash_ec to flash EC on Jerry. Set the timeout to a small value to force to kill itself. test2: ./flash_ec --board=hadoken # or samus, anything using openocd remove the USB cable half way through (openocd hangs) ps au | grep openocd Change-Id: I39ad8659b41764fd0dba30a86eca301fbbc5243f Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/289247 Commit-Queue: Myles Watson <mylesgw@chromium.org>
-rwxr-xr-xutil/flash_ec17
1 files changed, 12 insertions, 5 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 00df693210..4ccfa2d0fc 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -100,6 +100,8 @@ DEFINE_string chip "" \
"The chip to run debugger on."
DEFINE_string image "" \
"Full pathname of the EC firmware image to flash."
+DEFINE_integer timeout 600 \
+ "Timeout for flashing the EC, measured in seconds."
DEFINE_string offset "0" \
"Offset where to program the image from."
DEFINE_integer port 9999 \
@@ -328,7 +330,8 @@ function flash_openocd() {
dut_control jtag_buf_on_flex_en:on
dut_control jtag_buf_en:on
- sudo openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -f "${OCD_CHIP_CFG}" \
+ sudo timeout -k 10 -s 9 "${FLAGS_timeout}" \
+ openocd -s "${OCD_PATH}" -f "${OCD_CFG}" -f "${OCD_CHIP_CFG}" \
-c "${OCD_CMDS}" || \
die "Failed to program ${IMG}"
}
@@ -356,7 +359,8 @@ function flash_stm32() {
# Reset the EC
ec_reset
# Unprotect flash, erase, and write
- ${STM32MON} -d ${EC_UART} -U -u -e -w "${IMG}"
+ timeout -k 10 -s 9 "${FLAGS_timeout}" \
+ ${STM32MON} -d ${EC_UART} -U -u -e -w "${IMG}"
# Remove the Application processor reset
# TODO(crosbug.com/p/30738): we cannot rely on servo_VARS to restore it
if $(servo_has_warm_reset); then
@@ -382,11 +386,13 @@ function flash_stm32_dfu() {
SIZE=$(wc -c ${IMG} | cut -d' ' -f1)
# Remove read protection
- sudo $DFU_UTIL -a 0 -s ${ADDR}:${SIZE}:force:unprotect -D "${IMG}"
+ sudo timeout -k 10 -s 9 "${FLAGS_timeout}" \
+ $DFU_UTIL -a 0 -s ${ADDR}:${SIZE}:force:unprotect -D "${IMG}"
# Wait for mass-erase and reboot after unprotection
sleep 1
# Actual image flashing
- sudo $DFU_UTIL -a 0 -s ${ADDR}:${SIZE} -D "${IMG}"
+ sudo timeout -k 10 -s 9 "${FLAGS_timeout}" \
+ $DFU_UTIL -a 0 -s ${ADDR}:${SIZE} -D "${IMG}"
}
function flash_lm4() {
@@ -444,7 +450,8 @@ function flash_mec1322() {
cat $IMG
} > $T
- sudo ${FLASHROM} ${FLASHROM_PARAM} -w "${T}"
+ sudo timeout -k 10 -s 9 "${FLAGS_timeout}" \
+ ${FLASHROM} ${FLASHROM_PARAM} -w "${T}"
rm $T