Skip to content

FreeRTOS_OTA____

0

I have already created a FreeRTOS OTA job in the console, but it is currently only adding the device to the queue and has not started the OTA process. My device is connected to AWS and has subscribed to $aws/things/thingname/jobs/notify, but I haven't received any messages, and it seems like the job hasn't started. Does the device need to send any specific information to AWS? 在此处输入图片描述

asked 2 years ago240 views

2 Answers
0
Accepted Answer

Hi. This is what your device needs to do: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-workflow-device-online.html. If $aws/things/thingname/jobs/notify is published before you device connected and subscribed to that topic, your device would not receive it. That's why you need to do a GetPendingJobExecutions as well.

The job execution will stayed QUEUED until your device publishes an UpdateJobExecution.

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Thank you for your response. I have read the documentation link you provided. Could you please explain in more detail?

    In the document https://docs.aws.amazon.com/iot/latest/developerguide/jobs-workflow-device-online.html, it mentions subscribing to the notify-next node, which is the $aws/things/[thingname]/jobs/notify-next node, right? However, after subscribing, the job does not start. Does it require subscribing to the $aws/things/[thingname]/jobs/start-next node and sending its corresponding payload? For example, something like this: { "statusDetails": { "string": "job-execution-state" ... }, "stepTimeoutInMinutes": long, "clientToken": "string" } After the job starts, do I need to continuously update the job status to AWS through the $aws/things/[thingname]/jobs/[jobId]/update node? Thank you very much for your help. Could you kindly explain in more detail which nodes the device needs to subscribe to and which information it needs to send to ensure the OTA process goes smoothly?

  • The workflow document has two workflows. You should implement one or the other. Depending on whether you always want to process the next job or be able to select a job. The "Get the next job" workflow is the most common.

    it mentions subscribing to the notify-next node, which is the $aws/things/[thingname]/jobs/notify-next node, right?

    Yes

    However, after subscribing, the job does not start.

    Subscribing won't start a job. As I said (and as the workflow covers), your device needs to call UpdateJobExecution ($aws/things/thingName/jobs/jobId/update) to set the job to IN PROGRESS, else it will stayed QUEUED. Also, if your device is not connected and subscribed before the notify-next is published, your device won't receive it. You need to call DescribeJobExecution when your device first starts up (after subscribing). As well as calling it when you get notify-next. DescribeJobExecution gets you the job document. You need this before progressing to UpdateJobExecution in step 3.

    do I need to continuously update the job status

    No, not continuously. You need to call it once when you receive the job to set the job execution to IN PROGRESS. And then once when the job execution completes to set it to SUCCEEDED (in the case of the happy path). No additional calls are necessary. You can make additional calls to store information in statusDetails, but you don't have to.

  • Hello, I have successfully started the job and downloaded the firmware via HTTP. When creating the FreeRTOS OTA job, I provided my own code signing certificate in the code signing section. Does this mean that the firmware needs to be decoded using the certificate's public key to restore it to the original firmware?

  • Your firmware isn't encoded. The signature is calculated and sent in the job document. On the device, you should calculate the signature using the public key of the code signing certificate. And compare it to the signature in the job document.

-1

Based on the information provided, it seems your device is correctly connected to AWS and subscribed to the appropriate topic, but the OTA process hasn't started. To initiate the OTA update process, your device needs to actively request for updates. Here are the steps your device should take:

  1. After connecting to AWS IoT and subscribing to the notification topic, your device should publish a message to the "$aws/things/[thingname]/jobs/$next/get" topic. This request tells AWS IoT that your device is ready for the next available job.

  2. In response to this request, AWS IoT will send a message to your device with information about the next available job, which in this case would be your OTA update job.

  3. Your device's OTA agent should then process this job information, which includes details about the firmware update, such as file location, size, and signature.

  4. The OTA agent on your device should then start the process of downloading and verifying the new firmware.

  5. Throughout the update process, your device should publish status updates to AWS IoT to indicate the progress of the OTA job.

If you haven't implemented these steps in your device's firmware, particularly the initial request for the next job, that would explain why the OTA process hasn't started despite the job being created in the console. Make sure your device's firmware includes the logic to request and process OTA jobs after connecting to AWS IoT.
Sources
AWS IoT Over the air (OTA) library - FreeRTOS
AWS IoT Over the air (OTA) library - FreeRTOS
Over-the-air updates demo application - FreeRTOS

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.