fix: Fix-Runde 1 für Task 4 - Reset nur bei akzeptiertem OTA-Image, hängende Downloads/Sessions begrenzen

This commit is contained in:
Michael Sauer
2026-09-12 01:56:58 +02:00
parent aa8151c3d6
commit 37c05d2f90
7 changed files with 122 additions and 27 deletions
+21 -2
View File
@@ -172,6 +172,7 @@ static void tls_fwup_img_update_header(T_BOOTER* img_param)
/* ninlight: SHA256 + tail verification hook instead of the QConnex RSA check (see sdk/PATCHES.md) */
#include "util/nl_sha256.h"
#include "sys/nl_fwup_hook.h"
#include "sys/nl_ota.h" /* nl_ota_set_error() - see sdk/PATCHES.md point 1 */
static void fwup_scheduler(void *data)
@@ -440,9 +441,20 @@ static void fwup_scheduler(void *data)
printf("%02x ", bptr[i]);
printf("\n");
#endif
if (org_checksum != image_checksum || !nl_fwup_verify_tail(image_sha256, RSA_SHA256, 512)) // QC_CHANGE_MK
if (org_checksum != image_checksum) // QC_CHANGE_MK
{
/* ninlight: a checksum failure never reaches nl_fwup_verify_tail() below,
* so report it here explicitly - otherwise last_ota_error would fall back
* to the generic "download" instead of the more precise "crc" (see
* sdk/PATCHES.md point 1). */
TLS_DBGPRT_ERR("varify incorrect[0x%02x, but 0x%02x]\n", org_checksum, image_checksum);
nl_ota_set_error("crc");
request->status = TLS_FWUP_REQ_STATUS_FCRC;
fwup->current_state |= TLS_FWUP_STATE_ERROR_CRC;
goto request_finish;
}
else if (!nl_fwup_verify_tail(image_sha256, RSA_SHA256, 512)) // QC_CHANGE_MK
{
request->status = TLS_FWUP_REQ_STATUS_FCRC;
fwup->current_state |= TLS_FWUP_STATE_ERROR_CRC;
goto request_finish;
@@ -478,7 +490,14 @@ request_finish:
{
request->complete(request, request->arg);
}
if(fwup->updated_len >= (fwup->total_len))
/* ninlight: only reset when the image was actually accepted. Before this fix the
* condition below fired unconditionally once the transfer reached its end -
* including a request that got rejected by nl_fwup_verify_tail() (trailer/device/
* hash mismatch) or by the checksum check above (goto request_finish also lands
* here). Resetting in that case would reboot into the OLD firmware and never let
* ota_task() report the failure - so last_ota_error stayed NULL forever. See
* sdk/PATCHES.md point 1. */
if(fwup->updated_len >= (fwup->total_len) && !(fwup->current_state & TLS_FWUP_STATE_ERROR))
{
fwup_update_autoflag();
tls_sys_reset();