Skip to content

autoupdater: extremely slow image download on HiveAP #273

Open
@kpanic23

Description

I'm currently using autoupdater to update the firmware on an Aerohive HiveAP 330. Which takes ages.
So I've used that time to find out about what's holding it up.
The HiveAP 330 uses a 9600bps console output, so any output takes a long time.

The while loop in recv_image_cb outputs the progress in every iteration:

/** Receives data from uclient and writes it to file */
static void recv_image_cb(struct uclient *cl) {
struct recv_image_ctx *ctx = uclient_get_custom(cl);
char buf[1024];
int len;
while (true) {
len = uclient_read_account(cl, buf, sizeof(buf));
if (len <= 0)
return;
printf(
"\rDownloading image: % 5zi / %zi KiB",
uclient_data(cl)->downloaded / 1024,
uclient_data(cl)->length / 1024
);
fflush(stdout);
if (write(ctx->fd, buf, len) < len) {
fputs("autoupdater: error: downloading firmware image failed: ", stderr);
perror(NULL);
return;
}
ecdsa_sha256_update(&ctx->hash_ctx, buf, len);
}
}

Maybe it would be beneficial if the downloading progress would only get shown, like, every 128th iteration or so?

On a sidenote, it also looks to me like the SHA256 checksum is calculated for every iteration as well? Is this necessary? Wouldn't it be sufficient to calculate it once the download is completed?

ecdsa_sha256_update(&ctx->hash_ctx, buf, len);

Okay, it finally finished downloading, took about 20 minutes for the 44MB image...

EDIT:
using # autoupdater >/dev/null it took merely a couple seconds to download the image. So it definitely is related to terminal output.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions