diff options
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); |