diff options
author | Yicheng Li <yichengli@chromium.org> | 2020-10-07 13:19:48 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-10 00:30:59 +0000 |
commit | e371a6360ccad67f4264f3ebda4ce0df08c5b18a (patch) | |
tree | a5ef3e1f8403bbd976f348b2ad9147385ebec352 /util | |
parent | 063c4877b22199a9d1e0c70e2061e750f0fe7ad6 (diff) | |
download | chrome-ec-e371a6360ccad67f4264f3ebda4ce0df08c5b18a.tar.gz |
ectool: Retry fpframe command when a frame fails
The fpframe command downloads fingerprint templates frame by frame.
Add some retries to it, so that if there's a problem in the transport
layer, we don't give up immediately.
BRANCH=none
BUG=b:169783567, b:160208269
TEST=cros_workon --board=zork start ec-utils
emerge-zork ec-utils
cros deploy <IP> ec-utils
(On Morphius)
for i in {1..1000}; do ectool --name=cros_fp fpframe > /dev/null;
done
==> No fpframe failures (before there were 20+)
TEST=Enroll one fingerprint, then
with old ectool: ectool --name=cros_fp fpframe > before.txt
with new ectool: ectool --name=cros_fp fpframe > after.txt
cmp before.txt after.txt
==> Same
Signed-off-by: Yicheng Li <yichengli@chromium.org>
Change-Id: I66a31824d2515be2ac284abb98c389d89e494687
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2459226
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
Tested-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
Commit-Queue: Bhanu Prakash Maiya <bhanumaiya@google.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/util/ectool.c b/util/ectool.c index 81bd860b53..505c526892 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -1909,6 +1909,8 @@ static void *fp_download_frame(struct ec_response_fp_info *info, int index) int cmdver = ec_cmd_version_supported(EC_CMD_FP_INFO, 1) ? 1 : 0; int rsize = cmdver == 1 ? sizeof(*info) : sizeof(struct ec_response_fp_info_v0); + const int max_attempts = 3; + int num_attempts; /* templates not supported in command v0 */ if (index > 0 && cmdver == 0) @@ -1938,8 +1940,15 @@ static void *fp_download_frame(struct ec_response_fp_info *info, int index) while (size) { stride = MIN(ec_max_insize, size); p.size = stride; - rv = ec_command(EC_CMD_FP_FRAME, 0, &p, sizeof(p), - ptr, stride); + num_attempts = 0; + while (num_attempts < max_attempts) { + num_attempts++; + rv = ec_command(EC_CMD_FP_FRAME, 0, &p, sizeof(p), + ptr, stride); + if (rv >= 0) + break; + usleep(100000); + } if (rv < 0) { free(buffer); return NULL; |