OTA update task is failed when it try to get stream

uhey22e wrote on January 06, 2019:

Hello.
I have been trying to port OTA update demo to
STM32L4 Discovery kit IoT node.

Now, I’ve stubbed +aws_ota_pal.c+ and run +aws_ota_update_demo.c+ .
The thing seems to subscribe OTA update jobs successfully so the updating task is launched when I create the job on web console.
But the job is failed when it tries to publish to topic “$aws/things/stm32-test/streams/AFR_OTA-313b4591-0958-4ad4-8b58-e5f3fed32748/get/cbor”.
Following is a console output when task is in this loop.


100 31447 [OTA Task] [prvPublishGetStreamMessage] OK: $aws/things/stm32-test/streams/AFR_OTA-313b4591-0958-4ad4-8b58-e5f3fed32748/get/cbor
101 31459 [OTA Task] [prvStartRequestTimer] Starting OTA_FileRequest timer.
102 31485 [IP-task] Socket sending wakeup to MQTT task.
103 31490 [MQTT] Received message 0 from queue.
104 31617 [IP-task] Socket sending wakeup to MQTT task.
105 31623 [MQTT] Received message 0 from queue.
106 31628 [MQTT] Received fixed header, 151 bytes to receive.
107 32744 [OTA] State: Active  Received: 1   Queued: 1   Processed: 1   Dropped: 0
108 33959 [OTA Task] Sending command to MQTT task.
109 33963 [MQTT] Received message 70000 from queue.
110 33968 [MQTT] Initiating MQTT publish.
111 33984 [MQTT] Notifying task.
112 33988 [OTA Task] Command sent to MQTT task passed.
113 33993 [IP-task] Socket sending wakeup to MQTT task.
114 33998 [MQTT] Received message 0 from queue.
115 34003 [OTA Task] [prvPublishGetStreamMessage] OK: $aws/things/stm32-test/streams/AFR_OTA-313b4591-0958-4ad4-8b58-e5f3fed32748/get/cbor
116 34015 [OTA Task] [prvStartRequestTimer] Starting OTA_FileRequest timer.
117 34146 [IP-task] Socket sending wakeup to MQTT task.
118 34152 [MQTT] Received message 0 from queue.
119 34157 [MQTT] Received fixed header, 151 bytes to receive.
120 34751 [OTA] State: Active  Received: 1   Queued: 1   Processed: 1   Dropped: 0
121 36515 [OTA Task] Sending command to MQTT task.
122 36519 [MQTT] Received message 80000 from queue.
123 36524 [MQTT] Initiating MQTT publish.
124 36540 [MQTT] Notifying task.
125 36544 [OTA Task] Command sent to MQTT task passed.
126 36549 [IP-task] Socket sending wakeup to MQTT task.
127 36554 [MQTT] Received message 0 from queue.
// continued...

In CloudWatch logs, following error logs are recorded.


{
    "timestamp": "2019-01-06 19:08:15.222",
    "logLevel": "ERROR",
    "accountId": "200001232690",
    "status": "Failure",
    "actionType": "GetStream",
    "protocol": "MQTT",
    "clientId": "stm32-test",
    "topicName": "$aws/things/stm32-test/streams/AFR_OTA-f85ce53a-5a51-4cf0-8bf6-7e9eb3cf5520/get/cbor",
    "streamId": "AFR_OTA-f85ce53a-5a51-4cf0-8bf6-7e9eb3cf5520",
    "clientToken": "rdy",
    "details": "The request status is FAILURE. Error: Stream block not found due to unexpected exception. null"
}

What is the cause of this error?
Any help would be highly appreciated. Thanks.

DanG-AWS wrote on January 07, 2019:

Hello, first, when you create the OTA job in the AWS console for your Amazon FreeRTOS device, please double check that job creation is succeeding. It should display as “in progress” in your Jobs view on the console.

Second, confirm that the OTA job role you’re using is configured with sufficient rights as described in https://docs.aws.amazon.com/freertos/latest/userguide/create-service-role.html. Note that the OTA service attempts to create the stream from the S3 bucket that contains your digitally signed firmware image.

Third, can you please describe how you’re creating your “Code signing profile”?

uhey22e wrote on January 08, 2019:

DanG,

Thanks for your reply.

I reviewed settings according to your suggestions, then I was able to start downloading a image.
What I did is re-creating “Code signer profile” as following CLI command.

Before (not working)


aws signer put-signing-profile \
--profile-name stm32_dev_profile \
--signing-material certificateArn=arn:aws:acm:ap-northeast-1:<aws id>:certificate/<cert id> \
--platform AWSIoTDeviceManagement-SHA256-ECDSA \
--signing-parameters certname=/

After (working!)


aws signer put-signing-profile --profile-name stm32_dev_ota \
--signing-material certificateArn=arn:aws:acm:ap-northeast-1:<aws id>:certificate/<cert id> \
--platform AmazonFreeRTOS-Default \
--signing-parameters certname=/cert

After creating a profile, I created OTA job via web console selecting this profile.
Then, STM started downloading image.

For one’s information, would you please let me know difference between these two platforms, “AmazonFreeRTOS-Default” and “AWSIoTDeviceManagement-SHA256-ECDSA”?

Thanks.

Edited by: uhey22e on Jan 8, 2019 9:25 AM

mradula-aws wrote on January 08, 2019:

Hi uhey22e, you can get the list of signing platforms from the CLI command aws signer list-signing-platforms. A signing platform is a predefined set of instructions for the hash and encryption algorithms used to sign the image. With AmazonFreeRTOS-Default" and "AWSIoTDeviceManagement-SHA256-ECDSA, the difference is the signing image format. Hope this helps!

Edited by: mradula-aws on Jan 8, 2019 1:08 PM