diff options
author | Namyoon Woo <namyoon@chromium.org> | 2019-08-14 17:44:39 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-22 02:10:33 +0000 |
commit | b5cbdf78a66802e7e9aec6a365d9e5135f2b8e48 (patch) | |
tree | 48805766d579407c1006f376145625d682c0d0f2 /util | |
parent | 0596ecd75a278f0079b09646c95256fe063705fc (diff) | |
download | chrome-ec-b5cbdf78a66802e7e9aec6a365d9e5135f2b8e48.tar.gz |
util: UartUpdateTool retries Host/Dev sync up to three times
This patch increases the number of device sync attempts from two to
three.
It is to be tolerant on the first command failure because of USB
DATA PID mismatch that could happen from USB reconnection.
BUG=b:135617689
BRANCH=none
TEST=Tested on Hatch and Kohaku, Octopus and Grunt.
$ ./util/flash_ec --board hatch --image ${IMG}
...
Performing a Host/Device synchronization check...
Host/Device synchronization failed, error = 1.
Writing [784] bytes in [4] packets
...
INFO: Flashing done.
INFO: Restoring servo settings...
The first attempt runs good.
Disconnect Suzy-Q cable, and reconnect it, and run it again:
$ ./util/flash_ec --board hatch --image ${IMG}
Before this patch, it used to fail:
...
Performing a Host/Device synchronization check...
Host/Device synchronization failed, error = 2.
Host/Device synchronization failed, error = 1.
ERROR: Failed to load monitor binary.
INFO: Restoring servo settings...
After this patch, it succeeds:
...
Performing a Host/Device synchronization check...
Host/Device synchronization failed, error = 2.
Host/Device synchronization failed, error = 1.
Writing [784] bytes in [4] packets
...
INFO: Flashing done.
INFO: Restoring servo settings...
Change-Id: Id8e7041a5cb08075129148ddba5e8cf12f3aae54
Signed-off-by: Namyoon Woo <namyoon@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1755182
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/uut/main.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/util/uut/main.c b/util/uut/main.c index 603c7bbf37..6c924ae011 100644 --- a/util/uut/main.c +++ b/util/uut/main.c @@ -26,6 +26,7 @@ #define MAX_FILE_NAME_SIZE 512 #define MAX_PARAM_SIZE 32 #define MAX_MSG_SIZE 128 +#define MAX_SYNC_RETRIES 3 /* Default values */ #define DEFAULT_BAUD_RATE 115200 @@ -255,6 +256,7 @@ int main(int argc, char *argv[]) uint32_t strip_size; enum sync_result sr; uint8_t *buffer; + int sync_cnt; if (argc <= 1) exit(EC_UNSUPPORTED_CMD_ERR); @@ -291,21 +293,21 @@ int main(int argc, char *argv[]) /* Verify Host and Device are synchronized */ DISPLAY_MSG(("Performing a Host/Device synchronization check...\n")); - sr = opr_check_sync(baudrate); - - /* - * If it fails, try it once more. There is an issue that the first - * command after EC reset gets 0x00 byte response. Note b/126795953. - */ - if (sr != SR_OK) + for (sync_cnt = 1; sync_cnt <= MAX_SYNC_RETRIES; sync_cnt++) { sr = opr_check_sync(baudrate); - - if (sr != SR_OK) { + if (sr == SR_OK) + break; + /* + * If it fails, try it again up to three times. + * It might fail for garbage data drainage from H1, or + * for timeout due to unstable data transfer yet. + */ display_color_msg(FAIL, - "Host/Device synchronization failed, error = %lu.\n", - sr); - exit_uart_app(EC_SYNC_ERR); + "Host/Device synchronization failed, error = %lu," + " fail count = %d\n", sr, sync_cnt); } + if (sync_cnt > MAX_SYNC_RETRIES) + exit_uart_app(EC_SYNC_ERR); if (auto_mode) { size = param_get_file_size(file_name); |