summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2018-10-23 14:24:06 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-11-05 22:09:31 -0800
commit814670624a79091c6f95176ad622ee708633bb11 (patch)
tree0790320ebc012fc5040fc068f768d0aa0e8745e3 /util
parentc7af4fb76f258368da122aff6dad6bb33a0be12e (diff)
downloadchrome-ec-814670624a79091c6f95176ad622ee708633bb11.tar.gz
iteflash: re-connect to Cr50 after triggering sync sequence
ITE SYNC sequence generation now requires rebooting the H1, which means that the USB connection to the CCD host would be shut down. This patch adds closing and re-opening of the connection when itflash requests sending the ITE SYNC sequence. BRANCH=none BUG=b:75976718 TEST=using dragonegg P1 hardware verified that the EC can be reprogrammed over CCD by running the following command: $ ./build/dragonegg/util/iteflash -c -e -w build/dragonegg/ec.bin ... Verify 524288 bytes at 0x00000000 \ 99% Verify Done. $ also verified that the EC is running the new image. Change-Id: I2a485a741d5e90ecc8c5a91f4cf4f29cfee04b73 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1305116 Reviewed-by: Matthew Blecker <matthewb@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/iteflash.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/util/iteflash.c b/util/iteflash.c
index d608031f83..79bb3a31b5 100644
--- a/util/iteflash.c
+++ b/util/iteflash.c
@@ -711,6 +711,21 @@ static int ftdi_config_i2c(struct ftdi_context *ftdi)
#define SPECIAL_BUFFER_SIZE \
(((SPECIAL_LEN_USEC * SPECIAL_FREQ * 2 / USEC) + 7) & ~7)
+static int connect_to_ccd_i2c_bridge(struct common_hnd *chnd)
+{
+ int rv;
+
+ rv = usb_findit(chnd->conf.usb_vid, chnd->conf.usb_pid,
+ CR50_I2C_SUBCLASS, CR50_I2C_PROTOCOL, &chnd->uep);
+
+ if (rv) {
+ fprintf(stderr, "%s: usb_findit returned error %d\n",
+ __func__, rv);
+ }
+
+ return rv;
+}
+
static int ccd_trigger_special_waveform(struct common_hnd *chnd)
{
uint8_t response[20];
@@ -731,8 +746,15 @@ static int ccd_trigger_special_waveform(struct common_hnd *chnd)
if (response[0])
return -response[0];
+ /*
+ * The target is about to get reset, let's shut down the USB
+ * connection.
+ */
+ usb_shut_down(&chnd->uep);
- return 0;
+ sleep(3);
+
+ return connect_to_ccd_i2c_bridge(chnd);
}
static int ftdi_send_special_waveform(struct common_hnd *chnd)
@@ -1485,16 +1507,12 @@ static int ccd_i2c_interface_init(struct common_hnd *chnd)
int ret;
chnd->conf.usb_vid = CR50_USB_VID;
chnd->conf.usb_pid = CR50_USB_PID;
- ret = usb_findit(chnd->conf.usb_vid, chnd->conf.usb_pid,
- CR50_I2C_SUBCLASS, CR50_I2C_PROTOCOL, &chnd->uep);
- if (ret < 0) {
- fprintf(stderr, "%s: usb_findit() returned %d error", __func__,
- ret);
- return ret;
+ ret = connect_to_ccd_i2c_bridge(chnd);
+ if (!ret) {
+ printf("Using CCD device%s\n",
+ chnd->conf.usb_serial ? ", ignoring serial number" : "");
}
- printf("Using CCD device%s\n",
- chnd->conf.usb_serial ? ", ignoring serial number" : "");
- return 0;
+ return ret;
}
static int ccd_i2c_interface_shutdown(struct common_hnd *chnd)