无线更新演示应用程序 - FreeRTOS
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

无线更新演示应用程序

FreeRTOS 包括一个演示应用程序,用于演示无线 (OTA) 库的功能。OTA 演示应用程序位于 freertos/demos/ota/aws_iot_ota_update_demo.c 文件中。

OTA 演示应用程序执行以下操作:

  1. 初始化 FreeRTOS 网络堆栈和 MQTT 缓冲池。

  2. 创建任务来执行 OTA 库 (vRunOTAUpdateDemo())。

  3. 创建 MQTT 客户端 (prxCreateNetworkConnection())。

  4. 连接到 AWS IoT MQTT 代理 (IotMqtt_Connect())。

  5. 调用 OTA_AgentInit() 创建 OTA 任务,并注册在 OTA 任务完成时使用的回调。

  6. 重用 MQTT 连接 (xOTAConnectionCtx.pvControlClient = xConnection.xMqttConnection;)。

在使用 OTA 更新之前,请完成 FreeRTOS 无线更新 中的所有先决条件

在完成 OTA 更新的设置后,在支持 OTA 功能的平台上下载、构建、刷写并运行 FreeRTOS OTA 演示。设备特定的演示说明可用于以下取得 FreeRTOS 认证的设备:

在设备上构建、刷写并运行 OTA 演示应用程序后,您可以使用 AWS IoT 控制台或 AWS CLI 来创建 OTA 更新作业。在您创建 OTA 更新任务之后,连接到终端仿真器以查看 OTA 更新的进度。记下此过程中生成的任何错误。

成功 OTA 更新作业会显示类似以下内容的输出。为简便起见,在本示例中,我们删除了列表中的一些行。

313 267848 [OTA] [OTA] Queued: 1 Processed: 1 Dropped: 0 314 268733 [OTA Task] [OTA] Set job doc parameter [ jobId: fe18c7ec_8c31_4438_b0b9_ad55acd95610 ] 315 268734 [OTA Task] [OTA] Set job doc parameter [ streamname: 327 ] 316 268734 [OTA Task] [OTA] Set job doc parameter [ filepath: /sys/mcuflashimg.bin ] 317 268734 [OTA Task] [OTA] Set job doc parameter [ filesize: 130388 ] 318 268735 [OTA Task] [OTA] Set job doc parameter [ fileid: 126 ] 319 268735 [OTA Task] [OTA] Set job doc parameter [ attr: 0 ] 320 268735 [OTA Task] [OTA] Set job doc parameter [ certfile: tisigner.crt.der ] 321 268737 [OTA Task] [OTA] Set job doc parameter [ sig-sha1-rsa: Q56qxHRq3Lxv6KkorvilVs4AyGJbWsJd ] 322 268737 [OTA Task] [OTA] Job was accepted. Attempting to start transfer. 323 268737 [OTA Task] Sending command to MQTT task. 324 268737 [MQTT] Received message 50000 from queue. 325 268848 [OTA] [OTA] Queued: 2 Processed: 1 Dropped: 0 326 269039 [MQTT] MQTT Subscribe was accepted. Subscribed. 327 269039 [MQTT] Notifying task. 328 269040 [OTA Task] Command sent to MQTT task passed. 329 269041 [OTA Task] [OTA] Subscribed to topic: $aws/things/TI-LaunchPad/streams/327 330 269848 [OTA] [OTA] Queued: 2 Processed: 1 Dropped: 0 ... // Output removed for brevity 346 284909 [OTA Task] [OTA] file token: 74594452 .. // Output removed for brevity 363 301327 [OTA Task] [OTA] file ready for access. 364 301327 [OTA Task] [OTA] Returned buffer to MQTT Client. 365 301328 [OTA Task] Sending command to MQTT task. 366 301328 [MQTT] Received message 60000 from queue. 367 301328 [MQTT] Notifying task. 368 301329 [OTA Task] Command sent to MQTT task passed. 369 301329 [OTA Task] [OTA] Published file request to $aws/bin/things/TI-LaunchPad/streams/327/get 370 301632 [OTA Task] [OTA] Received file block 0, size 1024 371 301647 [OTA Task] [OTA] Remaining: 127 ... // Output removed for brevity 508 304622 [OTA Task] Sending command to MQTT task. 509 304622 [MQTT] Received message 70000 from queue. 510 304622 [MQTT] Notifying task. 511 304623 [OTA Task] Command sent to MQTT task passed. 512 304623 [OTA Task] [OTA] Published file request to $aws/bin/things/TI-LaunchPad/streams/327/get 513 304860 [OTA] [OTA] Queued: 47 Processed: 47 Dropped: 83 514 304926 [OTA Task] [OTA] Received file block 4, size 1024 515 304941 [OTA Task] [OTA] Remaining: 82 ... // Output removed for brevity 797 315047 [MQTT] MQTT Publish was successful. 798 315048 [MQTT] Notifying task. 799 315048 [OTA Task] Command sent to MQTT task passed. 800 315049 [OTA Task] [OTA] Published 'IN_PROGRESS' status to $aws/things/TI-LaunchPad/jobs/fe18c7ec_8c31_4438_b0b9_ad55acd9561801 315049 [OTA Task] Sending command to MQTT task. 802 315049 [MQTT] Received message d0000 from queue. 803 315150 [MQTT] MQTT Unsubscribe was successful. 804 315150 [MQTT] Notifying task. 805 315151 [OTA Task] Command sent to MQTT task passed. 806 315152 [OTA Task] [OTA] Un-subscribed from topic: $aws/things/TI-LaunchPad/streams/327 807 315172 [OTA Task] Sending command to MQTT task. 808 315172 [MQTT] Received message e0000 from queue. 809 315273 [MQTT] MQTT Unsubscribe was successful. 810 315273 [MQTT] Notifying task. 811 315274 [OTA Task] Command sent to MQTT task passed. 812 315274 [OTA Task] [OTA] Un-subscribed from topic: $aws/things/TI-LaunchPad/streams/327 813 315275 [OTA Task] [OTA] Resetting MCU to activate new image. 0 0 [Tmr Svc] Starting Wi-Fi Module ... 1 0 [Tmr Svc] Simple Link task created Device came up in Station mode 2 137 [Tmr Svc] Wi-Fi module initialized. 3 137 [Tmr Svc] Starting key provisioning... 4 137 [Tmr Svc] Write root certificate... 5 243 [Tmr Svc] Write device private key... 6 339 [Tmr Svc] Write device certificate... 7 436 [Tmr Svc] Key provisioning done... Device disconnected from the AP on an ERROR..!! [WLAN EVENT] STA Connected to the AP: Guest , BSSID: 44:48:c1:ba:b2:c3 [NETAPP EVENT] IP acquired by the device Device has connected to Guest Device IP Address is 192.168.3.72 8 1443 [Tmr Svc] Wi-Fi connected to AP Guest. 9 1444 [Tmr Svc] IP Address acquired 192.168.3.72 10 1444 [OTA] OTA demo version 0.9.1 11 1445 [OTA] Creating MQTT Client... 12 1445 [OTA] Connecting to broker... 13 1445 [OTA] Sending command to MQTT task. 14 1445 [MQTT] Received message 10000 from queue. 15 2910 [MQTT] MQTT Connect was accepted. Connection established. 16 2910 [MQTT] Notifying task. 17 2911 [OTA] Command sent to MQTT task passed. 18 2912 [OTA] Connected to broker. 19 2913 [OTA Task] Sending command to MQTT task. 20 2913 [MQTT] Received message 20000 from queue. 21 3014 [MQTT] MQTT Subscribe was accepted. Subscribed. 22 3014 [MQTT] Notifying task. 23 3015 [OTA Task] Command sent to MQTT task passed. 24 3015 [OTA Task] [OTA] Subscribed to topic: $aws/things/TI-LaunchPad/jobs/$next/get/accepted 25 3028 [OTA Task] Sending command to MQTT task. 26 3028 [MQTT] Received message 30000 from queue. 27 3129 [MQTT] MQTT Subscribe was accepted. Subscribed. 28 3129 [MQTT] Notifying task. 29 3130 [OTA Task] Command sent to MQTT task passed. 30 3138 [OTA Task] [OTA] Subscribed to topic: $aws/things/TI-LaunchPad/jobs/notify-next 31 3138 [OTA Task] [OTA] Check For Update #0 32 3138 [OTA Task] Sending command to MQTT task. 33 3138 [MQTT] Received message 40000 from queue. 34 3241 [MQTT] MQTT Publish was successful. 35 3241 [MQTT] Notifying task. 36 3243 [OTA Task] Command sent to MQTT task passed. 37 3245 [OTA Task] [OTA] Set job doc parameter [ clientToken: 0:TI-LaunchPad ] 38 3245 [OTA Task] [OTA] Set job doc parameter [ jobId: fe18c7ec_8c31_4438_b0b9_ad55acd95610 ] 39 3245 [OTA Task] [OTA] Identified job doc parameter [ self_test ] 40 3246 [OTA Task] [OTA] Set job doc parameter [ updatedBy: 589827 ] 41 3246 [OTA Task] [OTA] Set job doc parameter [ streamname: 327 ] 42 3246 [OTA Task] [OTA] Set job doc parameter [ filepath: /sys/mcuflashimg.bin ] 43 3247 [OTA Task] [OTA] Set job doc parameter [ filesize: 130388 ] 44 3247 [OTA Task] [OTA] Set job doc parameter [ fileid: 126 ] 45 3247 [OTA Task] [OTA] Set job doc parameter [ attr: 0 ] 46 3247 [OTA Task] [OTA] Set job doc parameter [ certfile: tisigner.crt.der ] 47 3249 [OTA Task] [OTA] Set job doc parameter [ sig-sha1-rsa: Q56qxHRq3Lxv6KkorvilVs4AyGJbWsJd ] 48 3249 [OTA Task] [OTA] Job is ready for self test. 49 3250 [OTA Task] Sending command to MQTT task. 51 3351 [MQTT] MQTT Publish was successful. 52 3352 [MQTT] Notifying task. 53 3352 [OTA Task] Command sent to MQTT task passed. 54 3353 [OTA Task] [OTA] Published 'IN_PROGRESS' status to $aws/things/TI-LaunchPad/jobs/fe18c7ec_8c31_4438_b0b9_ad55acd95610/u55 3353 [OTA Task] Sending command to MQTT task. 56 3353 [MQTT] Received message 60000 from queue. 57 3455 [MQTT] MQTT Unsubscribe was successful. 58 3455 [MQTT] Notifying task. 59 3456 [OTA Task] Command sent to MQTT task passed. 60 3456 [OTA Task] [OTA] Un-subscribed from topic: $aws/things/TI-LaunchPad/streams/327 61 3456 [OTA Task] [OTA] Accepted final image. Commit. 62 3578 [OTA Task] Sending command to MQTT task. 63 3578 [MQTT] Received message 70000 from queue. 64 3779 [MQTT] MQTT Publish was successful. 65 3780 [MQTT] Notifying task. 66 3780 [OTA Task] Command sent to MQTT task passed. 67 3781 [OTA Task] [OTA] Published 'SUCCEEDED' status to $aws/things/TI-LaunchPad/jobs/fe18c7ec_8c31_4438_b0b9_ad55acd95610/upd68 3781 [OTA Task] [OTA] Returned buffer to MQTT Client. 69 4251 [OTA] [OTA] Queued: 1 Processed: 1 Dropped: 0 70 4381 [OTA Task] [OTA] Missing job parameter: execution 71 4382 [OTA Task] [OTA] Missing job parameter: jobId 72 4382 [OTA Task] [OTA] Missing job parameter: jobDocument 73 4382 [OTA Task] [OTA] Missing job parameter: ts_ota 74 4382 [OTA Task] [OTA] Missing job parameter: files 75 4382 [OTA Task] [OTA] Missing job parameter: streamname 76 4382 [OTA Task] [OTA] Missing job parameter: certfile 77 4382 [OTA Task] [OTA] Missing job parameter: filepath 78 4383 [OTA Task] [OTA] Missing job parameter: filesize 79 4383 [OTA Task] [OTA] Missing job parameter: sig-sha1-rsa 80 4383 [OTA Task] [OTA] Missing job parameter: fileid 81 4383 [OTA Task] [OTA] Missing job parameter: attr 82 4383 [OTA Task] [OTA] Returned buffer to MQTT Client. 83 5251 [OTA] [OTA] Queued: 2 Processed: 2 Dropped: 0