Commit 3e91120f authored by Gerson Fernando Budke's avatar Gerson Fernando Budke Committed by Johan Hedberg
Browse files

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: default avatarGerson Fernando Budke <gerson.budke@ossystems.com.br>
Signed-off-by: default avatarOtavio Salvador <otavio@ossystems.com.br>
(cherry picked from commit 1128eab3)
parent fb244f75
Loading
Loading
Loading
Loading
+5 −3
Changes for lib/updatehub/updatehub.c: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -405,13 +405,15 @@ static void install_update_cb(void)
	}

	if (coap_next_block(&response_packet, &ctx.block) == 0) {
		LOG_ERR("Could not get the next");
		if (ctx.downloaded_size != ctx.block.total_size) {
			LOG_ERR("Could not get the next coap block");
			ctx.code_status = UPDATEHUB_DOWNLOAD_ERROR;
			goto cleanup;
		}

	if (ctx.downloaded_size == ctx.block.total_size) {
		if (!install_update_cb_sha256())
		LOG_INF("Firmware downloaded successfully");
		if (!install_update_cb_sha256()) {
			LOG_ERR("Firmware validation has failed");
			ctx.code_status = UPDATEHUB_DOWNLOAD_ERROR;
			goto cleanup;
		}