summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-03-05 11:09:51 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-11 23:03:38 +0000
commit17d126f028af4f105c9513e5cf0e104dab457c0b (patch)
treee986da44826e1188581cc4149f269f0e5f8bd5b0 /util
parent8cacfbc58afea1d98effecad7d6ebbc716cf25b5 (diff)
downloadchrome-ec-17d126f028af4f105c9513e5cf0e104dab457c0b.tar.gz
flash_ec: make c2d2 uart flashing more reliable
Remove sleeps from C2D2 flash path and ensure the EC doesn't come out of reset long enough to do damage before we start flashing it. BRANCH=none BUG=b:150796623 TEST=Verify that no console prints from EC occur before flashing happens (this is a positive change in behavior with this CL) Cq-Depend: chromium:2090124, chromium:2090576 Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I76560dcb6e7483ae36dc8c0f37ef99da126b0be3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2090077 Reviewed-by: David Schneider <dnschneid@chromium.org> Reviewed-by: Raul E Rangel <rrangel@chromium.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/flash_ec51
1 files changed, 41 insertions, 10 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 172d3c1f8e..452aad2d19 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -408,12 +408,9 @@ servo_ec_hard_reset() {
}
c2d2_ec_hard_reset() {
+ # This is an H1-level reset (instead of just an EC-level reset)
dut_control cold_reset:on
dut_control cold_reset:off
-
- # Cold reset on C2D2 is H1 reset, which will double reset the EC
- # We need to wait a little bit to ensure we catch final EC reset
- sleep 0.2
}
servo_usbpd_hard_reset() {
@@ -1341,13 +1338,47 @@ function flash_npcx_uut() {
dut_control ccd_keepalive_en:on
fi
- # Force the EC to boot in UART update mode
- ec_enable_boot0 "uut"
- ec_reset
+ # C2D2 does not use waits and has to ensure that the EC does not come
+ # out of reset after using a H1-level reset
+ if [[ "${SERVO_TYPE}" =~ "c2d2" ]] ; then
+ # Handle the case when flash_ec starts before DUT power is
+ # applied. Otherwise just use h1-level reset.
+ if [[ "$(dut_control_get h1_vref_present)" = "off" ]] ; then
+ info "Please attach C2D2 to DUT and power DUT now!"
+ # Waits ~40 seconds for Vref presence before timeout
+ local LOOP_COUNTER=100
+ while [[ "$(dut_control_get h1_vref_present)" = "off" \
+ && "${LOOP_COUNTER}" -gt 0 ]] ; do
+ sleep 0.1
+ let LOOP_COUNTER=LOOP_COUNTER-1
+ done
+ else
+ # Ensure DUT is in clean state with H1 Reset
+ dut_control cold_reset:on
+ dut_control cold_reset:off
+ fi
- # For CCD, disable the trigger pin for normal UART operation
- ec_disable_boot0 "uut"
- sleep 0.1
+ # Don't let the EC come out of reset after H1 reset
+ dut_control ec_reset:on
+
+ # Force the EC to boot in UART update mode coming out of reset
+ ec_enable_boot0 "uut"
+ dut_control ec_reset:off
+
+ # Ensure normal UART operation
+ ec_disable_boot0 "uut"
+ else
+ # Force the EC to boot in UART update mode
+ ec_enable_boot0 "uut"
+ ec_reset
+
+ # Have to wait a bit for EC boot-up
+ sleep 0.1
+
+ # Ensure normal UART operation
+ ec_disable_boot0 "uut"
+ sleep 0.1
+ fi
# Remove the prefix "/dev/" because uartupdatetool will add it.
local UUT_ARGS=( "--port=${EC_UART#/dev/}" " --baudrate=115200" )