diff options
author | Donald Huang <donald.huang@ite.com.tw> | 2016-02-24 17:14:19 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-02-25 11:22:09 -0800 |
commit | 8e31328e024306bdc3b6c917d131d13f7375ba6e (patch) | |
tree | 6a6091ffa782ea07b3c122ef622835a64b824db2 /util | |
parent | a58c24ee374068a017a72c344729d209b2e5bc85 (diff) | |
download | chrome-ec-8e31328e024306bdc3b6c917d131d13f7375ba6e.tar.gz |
it8380dev: util: Fix iteflash flash issue
Fix iteflash flash issue.
1. Avoid EC watchdog reset while flashing.
2. Do watchdog reset after flashing.
BRANCH=none
BUG=none
TEST=Test OK on ITE8390CX.
You can run "make -j BOARD=it8380dev" to build ec.bin
and flash the ec.bin via
"sudo ./build/it8380dev/util/iteflash -w ./build/it8380dev/ec.bin"
/* ==SNAPSHOT START== */
(cr) ((29b0840...)) donald@donald-nb ~/trunk/src/platform/ec $ sudo ./build/it8380dev/util/iteflash -w ./build/it8380dev/ec.bin
Waiting for the EC power-on sequence ...CHIPID 8390, CHIPVER 82, Flash size 256 kB
Done.
CHIPID 8390, CHIPVER 82, Flash size 256 kB
Erasing chip...
/100%
Writing 262144 bytes at 0x00000000
Done.
Verify 262144 bytes at 0x00000000
-100%
Verify Done.
/* ==SNAPSHOT END== */
Change-Id: I43fc5124f3854a516df17fab78649d4b083ed9b0
Signed-off-by: Donald Huang <donald.huang@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/328873
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/iteflash.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/util/iteflash.c b/util/iteflash.c index b74f1d3ca6..62bf8b8de2 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -283,6 +283,34 @@ static int check_chipid(struct ftdi_context *ftdi) return 0; } +/* DBGR Reset*/ +static int dbgr_reset(struct ftdi_context *ftdi) +{ + int ret = 0; + + ret |= i2c_write_byte(ftdi, 0x27, 0x80); + if (ret < 0) + printf("DBGR RESET FAILED\n"); + + return 0; +} + +/* Do WatchDog Reset*/ +static int do_watchdog_reset(struct ftdi_context *ftdi) +{ + int ret = 0; + + ret |= i2c_write_byte(ftdi, 0x2f, 0x20); + ret |= i2c_write_byte(ftdi, 0x2e, 0x06); + ret |= i2c_write_byte(ftdi, 0x30, 0x44); + ret |= i2c_write_byte(ftdi, 0x27, 0x80); + + if (ret < 0) + printf("WATCHDOG RESET FAILED\n"); + + return 0; +} + /* Enter follow mode and FSCE# high level */ static int spi_flash_follow_mode(struct ftdi_context *ftdi, char *desc) { @@ -1034,9 +1062,13 @@ int main(int argc, char **argv) if (flags & FLAG_UNPROTECT) command_write_unprotect(hnd); - if (flags & FLAG_ERASE || output_filename) + if (flags & FLAG_ERASE || output_filename) { command_erase(hnd, flash_size, 0); + /* Call DBGR Rest to clear the EC lock status */ + dbgr_reset(hnd); + } + if (input_filename) { ret = read_flash(hnd, input_filename, 0, flash_size); if (ret) @@ -1056,6 +1088,10 @@ int main(int argc, char **argv) /* Normal exit */ ret = 0; terminate: + + /* DO EC WATCHDOG RESET */ + do_watchdog_reset(hnd); + /* Close the FTDI USB handle */ ftdi_usb_close(hnd); ftdi_free(hnd); |