From 68c9b61f711b4d4139fc186651e7d59006de720a Mon Sep 17 00:00:00 2001 From: Namyoon Woo Date: Wed, 20 Feb 2019 15:35:13 -0800 Subject: iteflash: relocate "disable watchdog" Watchdog should be disabled no matter iteflash sent the special waveform or not. BUG=b:124976364 BRANCH=none TEST=manually ran iteflash or flash_ec on duts with ITE EC. [Bip with Servo V2] $ ./util/flash_ec --board=bip --image ${IMG} [Bip with CCD without ServoD] $ ./build/bip/util/iteflash -W 0 -c ccd -e -w ${IMG} -m [Bip with CCD without ServoD] $ ./build/bip/util/iteflash -W 1 -c ccd -e -w ${IMG} -m [DragonEgg with Servo V2] $ ./util/flash_ec --board=dragonegg --image ${IMG} [DragonEgg with CCD without ServoD] $ ./build/dragonegg/util/iteflash -W 0 -c ccd -e -w ${IMG} [DragonEgg with CCD without ServoD] $ ./build/dragonegg/util/iteflash -W 1 -c ccd -e -w ${IMG} Change-Id: I29ab2a4073e21c6d5c16c8dc8166b81c9630a404 Signed-off-by: Namyoon Woo Reviewed-on: https://chromium-review.googlesource.com/1479874 Commit-Ready: ChromeOS CL Exonerator Bot Reviewed-by: Matthew Blecker --- util/iteflash.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/util/iteflash.c b/util/iteflash.c index 42de8e982c..5993af67e0 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -533,9 +533,9 @@ static int dbgr_disable_watchdog(struct common_hnd *chnd) ret |= i2c_write_byte(chnd, 0x30, 0x30); if (ret < 0) - printf("DBGR DISABLE WATCHDOG FAILED!\n"); + fprintf(stderr, "DBGR DISABLE WATCHDOG FAILED!\n"); - return 0; + return ret; } /* disable protect path from DBGR */ @@ -550,9 +550,9 @@ static int dbgr_disable_protect_path(struct common_hnd *chnd) } if (ret < 0) - printf("DISABLE PROTECT PATH FROM DBGR FAILED!\n"); + fprintf(stderr, "DISABLE PROTECT PATH FROM DBGR FAILED!\n"); - return 0; + return ret; } /* Enter follow mode and FSCE# high level */ @@ -883,12 +883,6 @@ static int send_special_waveform(struct common_hnd *chnd) * loop. */ ret = check_chipid(chnd); - - /* disable watchdog before programming sequence */ - if (!ret) { - dbgr_disable_watchdog(chnd); - dbgr_disable_protect_path(chnd); - } } else { ret = -1; if (!(iterations % max_iterations)) @@ -1584,6 +1578,26 @@ static int ftdi_i2c_interface_post_waveform(struct common_hnd *chnd) return 0; } +static int interface_post_waveform(struct common_hnd *chnd) +{ + int ret; + + printf("Performing post special waveform work...\n"); + + if (chnd->conf.i2c_if->interface_post_waveform) + ret = chnd->conf.i2c_if->interface_post_waveform(chnd); + + /* disable watchdog before programming sequence */ + ret = dbgr_disable_watchdog(chnd); + if (ret < 0) + return ret; + + ret = dbgr_disable_protect_path(chnd); + if (ret < 0) + return ret; + return ret; +} + /* Close the FTDI USB handle */ static int ftdi_i2c_interface_shutdown(struct common_hnd *chnd) { @@ -1837,8 +1851,7 @@ int main(int argc, char **argv) } } - if (chnd.conf.i2c_if->interface_post_waveform && - chnd.conf.i2c_if->interface_post_waveform(&chnd)) + if (interface_post_waveform(&chnd)) goto terminate; if (chnd.conf.input_filename) { -- cgit v1.2.1