There was a bug in the OTA library, addressed by the following post:
However, a bug remains. As written the FSM for the OTA library will not properly progress to other archives, even though the comparison is correct. The fix is to do the following:
1. In OtaLib.c, comment out the line, below:
case OTA_STATE_CHECK_ARCHIVE_NEW_UPDATE: { uint8_t *pVersionFileName; _SlOtaLibTrace(("OTA_run: CdnClient_GetNextDirFile\r\n")); pOtaLib->pOtaFileName = CdnClient_GetNextDirFile(pCdnClient, &pOtaLib->OtaFileSize); /* check if last file in the list, still without tar file */ if( pOtaLib->pOtaFileName == NULL) { /* tar file not found, return no updates */ _SlOtaLibTrace(("OTA_run: ERROR CdnClient_ReqOtaDir - tar not found, no updates\r\n")); pOtaLib->ConsecutiveOtaErrors = 0; pOtaLib->State = OTA_STATE_IDLE; _OtaCleanToIdle(pOtaLib); return OTA_RUN_STATUS_NO_UPDATES; } _SlOtaLibTrace(("OTA_run: CdnClient_GetNextDirFile: file=%s, size=%ld\r\n", pOtaLib->pOtaFileName, pOtaLib->OtaFileSize)); if (strstr((const char *)pOtaLib->pOtaFileName, ".tar") == NULL) { _SlOtaLibTrace(("OTA_run: WARNING, not a tar file, filename=%s\r\n", pOtaLib->pOtaFileName)); /* Stay on state, check next file version */ pOtaLib->State = OTA_STATE_CHECK_ARCHIVE_NEW_UPDATE; return OTA_RUN_STATUS_CONTINUE; } /* continue anyway, user app can override this decision */ // COMMENT THIS LINE OUT //pOtaLib->State = OTA_STATE_REQ_FILE_URL; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< /* Init the Tar parser module */ OtaArchive_init(&pOtaLib->OtaArchive);
2. Add in OTA_set:
case EXTLIB_OTA_SET_OPT_ACCEPT_UPDATE: /* check if after OTA_STATE_CHECK_ARCHIVE_NEW_UPDATE state */ if (pOtaLib->State != OTA_STATE_CHECK_ARCHIVE_NEW_UPDATE) { _SlOtaLibTrace(("OTA_set: ERROR EXTLIB_OTA_SET_OPT_ACCEPT_UPDATE in wrong state = %d\r\n", pOtaLib->State)); return OTA_OPT_ERROR_WRONG_STATE; } pOtaLib->State = OTA_STATE_REQ_FILE_URL; break;
3. If you wish to DECLINE an update, don't call Ota_set, just do nothing.
These changes will enable the FSM to progress.
Happy to send a patch if there is a mechanism to do that.