OTA Demo Stuck after receiving all the data blocks

I have ported the AWS OTA demo code to B-L475E-IOT01A STM32 kit using the example implementation available inhttps://github.com/STMicroelectronics/amazon-freertos-ST

I have updated the PAL file, vector table and used the bootloader came with the ST example appropriately ,

I am using the AWS Free RTOS version 202002.00 2/18/2020.

After triggering the OTA job from the AWS console, Device gets all the data blocks properly, Once the final expected data block is received the example code gets stuck at some semaphore i don’t know the location in the code exactly, i have attached the debug output for your reference.
NOTE
1.ST OTA example uses version 201906.00 Major
2.This OTA example is working fine without any issues but when i try to port this to version 202002.00 , aforementioned issue occurs

Debug Output
1347 68461 [OTA Agent Task] [prvIngestDataBlock] Remaining: 2
1348 68467 [OTA Agent Task] [prvOTAAgentTask] Called handler. Current State [WaitingForFileBlock] Event [ReceivedFileBlock] New state [WaitingForFileBlock]
1349 68497 [OTA Agent Task] [prvIngestDataBlock] Received file block 363, size 1024
1350 68518 [OTA Agent Task] [prvIngestDataBlock] Remaining: 1
1351 68524 [OTA Agent Task] [prvOTAAgentTask] Called handler. Current State [WaitingForFileBlock] Event [ReceivedFileBlock] New state [WaitingForFileBlock]
1352 68565 [OTA Agent Task] [prvIngestDataBlock] Received file block 364, size 1024
1353 68587 [OTA Agent Task] [prvIngestDataBlock] Received final expected block of file.
1354 68595 [OTA Agent Task] [prvStopRequestTimer] Stopping request timer.
1355 68602 [OTA Agent Task] [prvPAL_CloseFile] Authenticating and closing file.
1356 68609 [OTA Agent Task] [prvPAL_CheckFileSignature] Started sig-sha256-ecdsa signature verification, file: /device/updates
1357 68621 [OTA Agent Task] [prvPAL_ReadAndAssumeCertificate] No such certificate file: /device/updates. Using aws_ota_codesigner_certificate.h.
1358 68999 [iot_thread] State: WaitingForFileBlock Received: 368 Queued: 0 Processed: 0 Dropped: 0
1359 70008 [iot_thread] State: WaitingForFileBlock Received: 368 Queued: 0 Processed: 0 Dropped: 0
1360 71017 [iot_thread] State: WaitingForFileBlock Received: 368 Queued: 0 Processed: 0 Dropped: 0
1361 72026 [iot_thread] State: WaitingForFileBlock Received: 368 Queued: 0 Processed: 0 Dropped: 0
1362 72748 [OTA Agent Task] [prvPAL_CloseFile] sig-sha256-ecdsa signature verification passed.
1363 72757 [OTA Agent Task] [prvContextUpdateImageHeaderAndTrailer] OTA Sequence Number: 40
1364 72766 [OTA Agent Task] [prvContextUpdateImageHeaderAndTrailer] Image - Start: 0x080201a0, End: 0x0807b5d8
1365 72780 [OTA Agent Task] [prvContextUpdateImageHeaderAndTrailer] Writing Trailer at: 0x080eb5d8
1366 72789 [OTA Agent Task] [prvPAL_CloseFile] Image header updated.
1367 72795 [OTA Agent Task] [prvIngestDataBlock] File receive complete and signature is valid.
1368 72804 [OTA Agent Task] [prvStopRequestTimer] Stopping request timer.
1369 72811 [OTA Agent Task] [prvUpdateJobStatus_Mqtt] Msg: {“status”:“IN_PROGRESS”,“statusDetails”:{“self_test”:“ready”,“updatedBy”:“0x90001”}}
1370 72825 [OTA Agent Task] [INFO ][MQTT][72825] (MQTT connection 0x10006920) MQTT PUBLISH operation queued.
1371 72835 [OTA Agent Task] [INFO ][MQTT][72835] (MQTT connection 0x10006920, PUBLISH operation 0x10006d70) Waiting for operation completion.
1372 73035 [iot_thread] State: WaitingForFileBlock Received: 368 Queued: 0 Processed: 0 Dropped: 0
1373 73200 [OTA Agent Task] [INFO ][MQTT][73200] (MQTT connection 0x10006920, PUBLISH operation 0x10006d70) Wait complete with result SUCCESS.
1374 73212 [OTA Agent Task] [prvUpdateJobStatus_Mqtt] ‘IN_PROGRESS’ to $aws/things/IET_iot_test/jobs/AFR_OTA-iet_ota_job_v9/update
1375 73224 [OTA Agent Task] Received eOTA_JobEvent_Activate callback from OTA Agent.
1376 73232 [OTA Agent Task] [INFO ][MQTT][73232] (MQTT connection 0x10006920) Disconnecting connection.
1377 73242 [OTA Agent Task] [INFO ][MQTT][73242] (MQTT connection 0x10006920, DISCONNECT operation 0x10006d70) Waiting for operation completion.
1378 73258 [OTA Agent Task] [INFO ][MQTT][73258] (MQTT connection 0x10006920, DISCONNECT operation 0x10006d70) Wait complete with result SUCCESS.
1379 73271 [OTA Agent Task] [INFO ][MQTT][73271] (MQTT connection 0x10006920) Connection disconnected.
1380 73281 [OTA Agent Task] [INFO ][MQTT][73281] (MQTT connection 0x10006920) Network connection closed.
1381 73291 [NetRecv] [ERROR][NET][73291] Error -128 while receiving data.
1382 73298 [NetRecv] [WARN ][NET][73298] Receive requested 94 bytes, but 0 bytes received instead.
1383 73307 [NetRecv] [ERROR][MQTT][73307] (MQTT connection 0x10006920) Error processing incoming data. Closing connection.

Hello Rudresh,

The OTA process seems to be complete as the eOTA_JobEvent_Activate event was generated in the callback. After this the OTA demo should disconnect and call OTA_ActivateNewImage which must reset the device. From the log it seems the device is getting stuck after disconnect on network receive task. The error code -128 is for attempting to close a socket that is already closed.

I will look into the port you mentioned at https://github.com/STMicroelectronics/amazon-freertos-ST and investigate this issue further. As a workaround if you want to test if your port works you can try calling OTA_ActivateNewImage immediately after you get the eOTA_JobEvent_Activate event .

Thanks for you response,

I will do as per your suggestion and update the status in this thread.

As I mentioned in my previous post, ST github example works fine, integration which I did for latest AWS free rtos version 202002.00 has some issues i think. I will also double check on my side the changes which I made(Updating PAL files, Vector table,config files) but i didn’t make any changes at the application level.

Hello Rudresh,

Did the solution worked for you and you could get OTA running ?

Unfortunately no, it again got stuck before resetting…

Actually i was waiting for your reply on the actual fix,

Is this a problem with AWS SDK 202002.00 or might be an issue in my porting from 201906.00 Major? .

If you could tell me, what are the AWS SDK files that needs to be updated that would be helpful for me to verify

i have updated only the portion of the code responsible for programming the received data block in to flash and it is working fine. I didn’t make any changes with respect to data communication.

So kindly help me in debugging this problem