OTA(Over-the-Air) 업데이트 데모 애플리케이션 - FreeRTOS

OTA(Over-the-Air) 업데이트 데모 애플리케이션

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 업데이트를 위한 설정을 완료한 경우 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