From b41a0632db0abd010331b507cba4b472dd8e2fd8 Mon Sep 17 00:00:00 2001 From: Todd Broch Date: Wed, 19 Nov 2014 12:37:38 -0800 Subject: [PATCH] WORKAROUND: ectool: Throttle flashpd so it does not watchdog EC. CL adds sleep to USB-PD flashing loop in ectool. Real problem is likely busy waiting within the host command master in the EC which causes it to starve other lower priority tasks there. Additionally, 1. Sleep 100ms after reboot to attempt to avoid colliding with other USB-PD traffic communication that happens when accessories boot. 2. Sleep 100ms after last flash write prior to reboot as there's some race between finalizing flash write. Workaround should be removed once we've identified root cause. Signed-off-by: Todd Broch BRANCH=samus BUG=chrome-os-partner:33905 TEST=manual, 1. attach zinger to port 1 of samus 2. create ec.RW.bin for zinger and copy to samus 3. update RW fw on zinger via: ectool --name cros_pd flash_pd 1 1 ec.RW.bin Result: - No longer see watchdog fire on samus EC - See successful update of RW fw on zinger. Takes ~15secs. Change-Id: If617cbf1c25ee92de94bdb312ec822af2a688640 Reviewed-on: https://chromium-review.googlesource.com/230845 Reviewed-by: Todd Broch Commit-Queue: Todd Broch Tested-by: Todd Broch --- util/ectool.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/util/ectool.c b/util/ectool.c index 9901358b5d..d6c47a7407 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -946,6 +946,8 @@ int cmd_flash_pd(int argc, char *argv[]) if (rv < 0) goto pd_flash_error; + usleep(100000); /* 100ms to reboot and get CC line idle */ + /* Erase RW flash */ fprintf(stderr, "Erasing RW flash\n"); p->cmd = USB_PD_FW_FLASH_ERASE; @@ -968,8 +970,17 @@ int cmd_flash_pd(int argc, char *argv[]) p, p->size + sizeof(*p), NULL, 0); if (rv < 0) goto pd_flash_error; + + /* + * TODO(crosbug.com/p/33905) throttle so EC doesn't watchdog on + * other tasks. Remove once issue resolved. + */ + usleep(10000); } + /* 100msec to guarantee writes finish */ + usleep(100000); + /* Reboot into new RW */ fprintf(stderr, "Rebooting PD into new RW\n"); p->cmd = USB_PD_FW_REBOOT;