TIDUE59A May   2018  – September 2020

 

  1.   Description
  2.   Resources
  3.   Features
  4.   Applications
  5. 1System Description
    1. 1.1 Key System Specifications
  6. 2System Overview
    1. 2.1 Block Diagram
    2. 2.2 Design Considerations
    3. 2.3 Highlighted Products
      1. 2.3.1 CC3220
      2. 2.3.2 CC2640R2F
      3. 2.3.3 DRV8837
    4. 2.4 System Design Theory
      1. 2.4.1 CC3220S to CC2640R2F Interface
      2. 2.4.2 CC3220S to DRV8837 Interface
      3. 2.4.3 Software Architecture
      4. 2.4.4 Network Connection Management
      5. 2.4.5 Provisioning
        1. 2.4.5.1 AP Provisioning and SmartConfig™
        2. 2.4.5.2 Wi-Fi Provisioning Over BLE
      6. 2.4.6 Sending and Receiving Messages Through Cloud
        1. 2.4.6.1 Message Queue Telemetry Transport Protocol
        2. 2.4.6.2 MQTT Client Implementation
      7. 2.4.7 Over-the-Air Updates
        1. 2.4.7.1 HyperText Transfer Protocol
      8. 2.4.8 Security Enablers
        1. 2.4.8.1 Secure Boot
        2. 2.4.8.2 Secure Sockets
          1. 2.4.8.2.1 Hardware Accelerators
          2. 2.4.8.2.2 Simple Network Time Protocol
        3. 2.4.8.3 File System Security
          1. 2.4.8.3.1 Failsafe Files and Bundle Protection
      9. 2.4.9 Low-Power Consumption
  7. 3Hardware, Software, Testing Requirements, and Test Results
    1. 3.1 Required Hardware and Software
      1. 3.1.1 Hardware
        1. 3.1.1.1 CC3220S LaunchPad™ Development Kit
        2. 3.1.1.2 CC2640R2F LaunchPad™ Development Kit
        3. 3.1.1.3 Sensor BoosterPack™ Connections (BMI160)
        4. 3.1.1.4 DRV8837EVM Modifications and Connections
        5. 3.1.1.5 Assembling EVMs
      2. 3.1.2 Software
        1. 3.1.2.1 Getting Started With Software
          1. 3.1.2.1.1 Build simple_np Application and Flash CC2640R2F
          2. 3.1.2.1.2 Use Premade UniFlash ImageCreator Project
          3. 3.1.2.1.3 Importing Project Source Files Into CCS
        2. 3.1.2.2 User Files
        3. 3.1.2.3 Run Wi-Fi® Doorlock Demo
          1. 3.1.2.3.1 Connect CC3220 to Network
          2. 3.1.2.3.2 Networking Functions
            1. 3.1.2.3.2.1 Get Current Date and Time (SNTP)
            2. 3.1.2.3.2.2 Send and Receive Messages (MQTT)
            3. 3.1.2.3.2.3 Perform Software Update Using Dropbox (OTA Update)
    2. 3.2 Testing and Results
      1. 3.2.1 Pass or Fail Tests
      2. 3.2.2 Power Measurements
      3. 3.2.3 Test Setup
        1. 3.2.3.1 CC3220S
        2. 3.2.3.2 CC2640R2F
        3. 3.2.3.3 DRV8837
      4. 3.2.4 Test Results
      5. 3.2.5 Battery Life Estimate
  8. 4Design Files
  9. 5Software Files
  10. 6Related Documentation
    1. 6.1 Trademarks
  11. 7Terminology
  12. 8About the Author
  13. 9Revision History
Perform Software Update Using Dropbox (OTA Update)

In addition to providing the ability to remotely control and monitor the state of the demo using MQTT, the CC3220 makes it possible to perform a wireless software update for the system through the cloud. This reference design uses the OTA library provided as part of the CC3220 SimpleLink SDK to implement cloud OTA updates. Dropbox is used as the content delivery network (CDN) in this design, but the OTA implementation could be changed to support other CDNs.

When running the demo from the premade UniFlash ImageCreator project, the system uses a preconfigured Dropbox account to perform the OTA update. When the demo is connected to a network, and the user has verified the ability to communicate with the lock through the MQTT broker, a cloud-based OTA update can be triggered by publishing a message from another client on topic 4 that is subscribed to by the CC3220 (discussed in Section 3.1.2.3.2.2). Receiving a message on topic 4 tells the wifi_doorlock application to execute the RUN step of the cloud OTA state machine.

When the OTA is running, the demo establishes a secure HTTP connection to the Dropbox server and checks to see if there is an available software version with a higher version number than the one the device is currently executing. If an update is discovered, the device downloads all the components of the OTA in a .tar file and saves them to the file system in failsafe mode. When the entire update is successfully downloaded, the OTA state machine requests a system reset. The control task executes the reset and the system reboots with the new software version. If the system successfully reboots and reconnects to the network, the system commits the new software version to make it permanent for all future resets.

To run the OTA update supported by this design with a custom Dropbox account and OTA image, perform the following steps:

  1. Create and configure a Dropbox developer account, as shown in Steps 1 to 10 of Getting Started With the Dropbox™ Cloud Delivery Network (CDN) in the CC3x20 SimpleLink Wi-Fi and Internet of Things Over-the-Air Update application report.
  2. Update the otauser.h file of the OTA library, as stated in Step 10 of Getting Started With the Dropbox™ Cloud Delivery Network (CDN) in the CC3x20 SimpleLink Wi-Fi and Internet of Things Over-the-Air Update application report.
  3. Open the OtaJson.c file in the OTA library and increase the size of MAX_METADATA_FILENAME to 150 (this allows users to support a longer path name to the update file in their Dropbox account and can be adjusted as needed).
  4. Open the OtaArchive.h file in the OTA library and increase the MAX_BUNDLE_CMD_FILES define to 12, so that all of the user files in the wifi_doorlock image can be included in the bundle.
  5. Open the ota.h file in the OTA library and increase OTA_BLOCK_SIZE to 11000.
  6. Rebuild the OTA library and ensure the new library is linked to the wifi_doorlock application in the workspace.
  7. Rebuild the wifi_doorlock application.
  8. Open the premade UniFlash ImageCreator Project for the wifi_doorlock application, then replace mcuimg.bin with the wifi_doorlock application binary built in Step 4.
  9. Reprogram the LaunchPad with the new application containing the custom Dropbox credentials and directory information.
  10. (Optional) Make a small change to the wifi_doorlock application, so to see that the update works correctly, then rebuild. For example, try incrementing the APPLICATION_VERSION define in wifi_doorlock_app.h.
  11. (Optional) Replace the mcuimg.bin file in the UniFlash project with the binary created in Step 10.
  12. Press the Generate Image button in UniFlash ImageCreator.
  13. Select the Create OTA button on the Generate Image page.
  14. When prompted for the OTA private key file name, select Browse and choose the dummy_ota_vendor_key.der file from the SDK (<SDK Install Location>/<SDK Version>/tools/cc32xx_tools/ota-example-cert/dummy_ota_vendor_key.der).
  15. Press the Create OTA button in the prompt when it shows the correct private key.
  16. Save the generated file and load it to the Dropbox account in the folder matching the OTA_VENDOR_DIR define of the otauser.h file (for example, Apps/OTA_R2/OTA_R2_MCU/).

After all of these steps are completed and the LaunchPad is flashed with the new software, the OTA can be run by following the same steps as when evaluating the application from the premade UniFlash ImageCreator project.