Skip to content

Commit 3e91120

Browse files
nandojvejhedberg
authored andcommitted
lib: updatehub: Fix download block error
The current version aborts update when found last transfer block. Now, system checks only at end of coap block transfer total size and install if download is ok. Signed-off-by: Gerson Fernando Budke <[email protected]> Signed-off-by: Otavio Salvador <[email protected]> (cherry picked from commit 1128eab)
1 parent fb244f7 commit 3e91120

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/updatehub/updatehub.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,15 @@ static void install_update_cb(void)
405405
}
406406

407407
if (coap_next_block(&response_packet, &ctx.block) == 0) {
408-
LOG_ERR("Could not get the next");
409-
ctx.code_status = UPDATEHUB_DOWNLOAD_ERROR;
410-
goto cleanup;
411-
}
408+
if (ctx.downloaded_size != ctx.block.total_size) {
409+
LOG_ERR("Could not get the next coap block");
410+
ctx.code_status = UPDATEHUB_DOWNLOAD_ERROR;
411+
goto cleanup;
412+
}
412413

413-
if (ctx.downloaded_size == ctx.block.total_size) {
414-
if (!install_update_cb_sha256())
414+
LOG_INF("Firmware downloaded successfully");
415+
if (!install_update_cb_sha256()) {
416+
LOG_ERR("Firmware validation has failed");
415417
ctx.code_status = UPDATEHUB_DOWNLOAD_ERROR;
416418
goto cleanup;
417419
}

0 commit comments

Comments
 (0)