summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2017-04-26 17:37:48 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-05-01 21:54:04 -0700
commit98b8d8c840bfb2679ba0eb716233cafc9c47a536 (patch)
tree02475945125fd7e929191b418e66daf1fcd09bad
parent47b7e566afd6e3adfdbf6ca2877d353134b8dd24 (diff)
downloadchrome-ec-98b8d8c840bfb2679ba0eb716233cafc9c47a536.tar.gz
iteflash: exit DBGR mode after flashing
This change is separated from CL:344481. We need a cold reset after flashing, but we kill 'servod' before execute iteflash for each flashing process. With this change, we can restart 'servod' again without errors. And we are able to use dut-control to do a EC cold reset. BRANCH=none BUG=none TEST=flashing completed, and wait for servo's cold reset. Change-Id: Ifc242467211253fabcd733a971e999baa68a1026 Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/488002 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--util/iteflash.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/util/iteflash.c b/util/iteflash.c
index 82d2c9d3fb..cb583af64e 100644
--- a/util/iteflash.c
+++ b/util/iteflash.c
@@ -288,6 +288,11 @@ static int dbgr_reset(struct ftdi_context *ftdi)
{
int ret = 0;
+ /* Reset CPU only, and we keep power state until flashing is done. */
+ ret |= i2c_write_byte(ftdi, 0x2f, 0x20);
+ ret |= i2c_write_byte(ftdi, 0x2e, 0x06);
+ ret |= i2c_write_byte(ftdi, 0x30, 0x40);
+
ret |= i2c_write_byte(ftdi, 0x27, 0x80);
if (ret < 0)
printf("DBGR RESET FAILED\n");
@@ -295,18 +300,23 @@ static int dbgr_reset(struct ftdi_context *ftdi)
return 0;
}
-/* Do WatchDog Reset*/
-static int do_watchdog_reset(struct ftdi_context *ftdi)
+static int exit_dbgr_mode(struct ftdi_context *ftdi)
{
+ uint8_t val;
int ret = 0;
- ret |= i2c_write_byte(ftdi, 0x2f, 0x20);
- ret |= i2c_write_byte(ftdi, 0x2e, 0x06);
- ret |= i2c_write_byte(ftdi, 0x30, 0x4C);
- ret |= i2c_write_byte(ftdi, 0x27, 0x80);
-
- if (ret < 0)
- printf("WATCHDOG RESET FAILED\n");
+ /* We have to exit dbgr mode so that EC won't hold I2C bus. */
+ ret |= i2c_write_byte(ftdi, 0x2f, 0x1c);
+ ret |= i2c_write_byte(ftdi, 0x2e, 0x08);
+ ret |= i2c_read_byte(ftdi, 0x30, &val);
+ ret |= i2c_write_byte(ftdi, 0x30, (val | (1 << 4)));
+ /*
+ * NOTE:
+ * We won't be able to send any commands to EC
+ * if we have exit dbgr mode.
+ * We do a cold reset for EC after flashing.
+ */
+ printf("=== EXIT DBGR MODE %s ===\n", (ret < 0) ? "FAILED" : "DONE");
return 0;
}
@@ -1090,8 +1100,8 @@ int main(int argc, char **argv)
ret = 0;
terminate:
- /* DO EC WATCHDOG RESET */
- do_watchdog_reset(hnd);
+ /* Exit DBGR mode */
+ exit_dbgr_mode(hnd);
/* Close the FTDI USB handle */
ftdi_usb_close(hnd);