TI CC3200 SFT Example

Secure File Transfer for CC3200 Firmware Updates

 

What you will learn

This tutorial teaches you how to configure a Xively Secure File Transfer (SFT) deployment to update the firmware of a Texas Instruments SimpleLink™ Wi-Fi® CC3200 LaunchPad™ development kit over MQTT. Binaries are provided for ease of use, but the source code is also provided if you want to make changes to the firmware yourself.

Hardware you will need

Texas Instruments SimpleLink™ Wi-Fi® CC3200 LaunchPad™ development kit.

A Windows machine to run UniFlash to program your TI CC3200.

Step 1 of 9 Download Precompiled Firmware

We've pre-built two firmware images for the TI CC3200 that include Xively clients which use Xively SFT. You can flash one onto the device using CCS Uniflash from your Windows machine, and store the other in the cloud for Xively SFT to transfer to the device.

Both images will respond to messages published to the device over the blink topic. The first image firmwareA.bin will toggle the green and orange lights on and off in unison, while the second image firmwareB.bin will toggle the lights in series. This difference of visual behavior tells you if the firmware update has taken place.

You can download these images from our github repository. Please keep these files readily available for a subsequent step of this tutorial:

Download Links:

  1. firmwareA.bin
  2. firmwareB.bin

Step 2 of 9 Add Firmware Administrator Role to Your Account

The use of Xively's Secure File Transfer is gated by an account role that you must add to your account. As an administrator of your own account you can add this role yourself through Xively's REST API.

Create a JWT (web token)

You will need a JWT to authorize the next few REST calls you'll make (below.)

  1. Navigate to the Xively UserLogin REST Endpoint.
  2. Click the shaded Model Schema box to the right. This will pre-populate the body value box with the schema that you need to fill out.
  3. In the white body value box, enter your email address, password, and accountId

Example:

📘

Note:

If you don't have your accountId then you can retrieve it from Xively CPM by clicking the Gear/Cogwheel in the upper right hand corner.

  1. Click Try it out!.
  2. In the Response Headers find the entry for xively-access-token and copy the value (excluding quotation marks.)

Extract your userId from the JWT

  1. Navigate to jwt.io.
  2. Scroll down to see the Encoded text area.
  1. Highlight the value contained within the text area.
  2. Paste your xively-access-token into the text area. On the right, you should see a JSON object with variousf fields, including your user-id. You need the user-id value in the next step.

Add the FIRMWARE_MANAGER and ACCOUNT_ADMIN Roles to your Account.

  1. Navigate to Add User Role REST API Endpoint.
  2. In the Authorization field, enter Bearer and paste your xively-access-token JWT from step 1 above. Ensure there's a space between the word Bearer and your JWT.
  3. In the userId field, copy and paste your user-id value from step 2 above.
  4. Click the shaded Model Schema box on the right of the page to pre-populate the body text area.
  5. In the body text area, for the name field enter in FIRMWARE_MANAGER.
  6. In the body text area, for the scope field enter user.

Example:

{
  "name": "FIRMWARE_MANAGER",
  "scope": "user"
}
  1. Click Try it out!.

Result: You should see a Response Code value of 200.
Important: If you receive a different value than 200 then please start this section over again.

Add the ACCOUNT_ADMIN role to your account

  1. You can reuse all the fields from the previous step, but replace the FIRMWARE_MANAGER value in the name field with the new value of ACCOUNT_ADMIN.

Example:

{
  "name": "ACCOUNT_ADMIN",
  "scope": "user"
}
  1. Click Try it out!.

Result: You should see a Response Code value of 200.

Confirm Your New Account Roles

Make sure that your account roles have been updated.

  1. You will need to login with a new session to Xively CPM .
    a. If you are already logged-in then you must first logout before you can confirm your new roles. Click the Gear/Cogwheel in the upper right-hand corner of any CPM page and select Logout from the context menu.
  2. Login to Xively CPM
  3. Click the Gear/Cogwheel in the upper right-hand corner of any CPM page and select My Profile
  4. Check the Permissions header in the upper section of the page and ensure that it has Firmware Manager and Account Admin.

Example:

Step 3 of 9 Provision a Device in Xively

Before connecting a physical device to Xively, create its digital representation in the system. Log into Xively CPM to complete the following steps.

Create a Device Group

  1. On the left-hand menu, click on All groups > + ADD NEW
  2. Do not modify the first two fields. For the Group's name type in CC3200 SFT Demo Group
  3. Click Create

Create a CC3200 Device Template

  1. Click on Device templates > Create New Device Template
  2. Click on Unnamed device template at the top of the page and give your template the name CC3200 SFT Demo.
  3. Add a new Simple Message channel. Click the + (plus sign) and name the channel blink. Click Save Channel

Create your Device

  1. Click Create new device. Ensure that template field reads CC3200 SFT Demo.
  2. Name the Device by giving it the Serial Number value of CC3200 Launchpad XL.
  3. Click Associate device with a group. An empty field will appear. Click it and select CC3200 SFT Demo Group

Result: You've just created a device in Xively and you've added it to a Group. The Group will let you send messages to the device from another device ( see Appendix: Blink ) for more information.

Step 4 of 9 Configure Xively Credential File

The Xively client application on the device will read your Wi-Fi and Xively credentials from a file stored in flash memory.

An example default Xively Configuration file is located in the base directory of the CC3200 SFT Tutorial Sources in **examples/cc3200/xively_firmware_updates/xively_cfg.txt`, and also available in our Github Repository.

Example:

"account_id": "PASTE_XIVELY_CREDENTIAL_HERE"
"device_id": "PASTE_XIVELY_CREDENTIAL_HERE"
"password": "PASTE_XIVELY_CREDENTIAL_HERE"
"wifi_security_type": "wpa2"
"wifi_ssid": "PASTE_WIFI_CREDENTIAL_HERE"
"wifi_password": "PASTE_WIFI_CREDENTIAL_HERE"

Save this file to your computer and edit it with the following steps.

Configure your Device Credentials

  1. For the first line, account_id, replace the text PASTE_XIVELY_CREDENTIAL_HERE with your Xively Account ID.
    Remember: you can get your Account ID by clicking on the Cogwheel in the upper right corner of Xively CPM.
  2. For device_id, go to Devices -> All Devices page in Xively CPM and click on the device CC3200 Launchpad XL* to open its Device Details page. This is the device you provisioned above. In the box to the left click on the text beneath Xively Device ID to copy the ID to the Clipboard. Paste it over the PASTE_XIVELY_CREDENTIAL_HERE for the device_id** in the configuration file.
  3. For password, once again from the Device Details Page, click the Get Password button in the upper right corner. Copy the value to the clipboard and paste it over the PASTE_XIVELY_CREDENTIAL_HERE text for password.

🚧

Warning:

You should keep quotes around all of the key/values in the xively_cfg.txt file. For instance, the first line of the file should look something like this:

"account_id": "3fDSMvPK-T7g4-zvdp-2aUi-IT2Wa7U7P4Yh"

Configure your WiFi Credentials

  1. For wifi_security_type you are pre-configured for WPA2. This is valid for most networks. Other valid options here are wep and wpa.
  2. For wifi_ssid replace PASTE_WIFI_CREDENTIAL_HERE with your WiFi SSID/Name.
  3. For wifi_password replace PASTE_WIFI_CREDENTIAL_HERE with your WiFi password.
  4. Save the file.
    Important: You need this file in Step 6 of 9 Flash the Device below.

Step 5 of 9 Install CCS UniFlash

  1. From Code Composer Studio™ Uniflash download page choose 'Windows Offline Version'.
  2. Begin the installation process.
  3. On the Select Components window, uncheck all options bar Simplelink Wi-Fi CC31xx/CC32xx and continue the installation process.

Step 6 of 9 Flash the Device

Flashing the device means that software is stored on the device that will last even after the device is unplugged and plugged back in.

For a firmware update demo, we would like to install a bootloader that can switch between software versions. This bootloader will make it safe to test new firmware and rollback if the new firmware fails. Thankfully, Texas Instruments has provided a bootloader to the public with this exact functionality.

Create a new Device Image that includes the bootloader, your Xively credentials file, and a baseline application that will connect to Xively.

Download the CC3200 SDK (currently version 1.3)

  1. Visit the CC3200 SDK download page.
  2. Click the Download button to the right of CC3200SDK: SimpleLink Wi-Fi CC3200 Software Development Kit (SDK).
  3. Register for TI's website or sign in as necessary.
    4 Download the installer .zip file onto your Windows machine.
  4. Execute the installer and accept the default parameters.

Create a New Device Configuration

  1. Run CCS Uniflash.
  2. Select File->New Configuration.
  3. For the Connection field, pick CC3x Serial(UART) Interface.
  4. For the Board or Device field, pick SimpleLink Wifi CC3100/CC3200
  5. Click OK.

Configure the TI Bootloader

The CC3200's SDK versions 1.1 and 1.2 include a precompiled bootloader. To set it up in Uniflash:

  1. Click on /sys/mcuimg.bin in the file list menu on the left.
  2. Click the Browse button on the right of the URL field. Browse to your SDK install path (for instance c:\ti\CC3200SDK_1.3.0* and locate the file in the path example\application_bootloader\ccs\Release\application_bootloader.bin**.
  3. Check Update and Verify.

Add the Xively firmware image

  1. In the top Menu select Operation->Add File.
  2. A new file name will appear under the User Files subsection file list on the left with the name new file/ and a GUID suffix. Click the new file/{GUID}.
  3. In the Name field, type /sys/mcuimg2.bin.
  4. Click the Browse button next to the URL field.
  5. Browse to the firmwareA.bin file you downloaded earlier.
  6. Check Update and Verify.

Format and Flash the Device

  1. Plug in your CC3200 device into the USB port of your computer and ensure that the J15 Jumper (SOP 2) is Jumped by placing the jumper on both pins.
  2. Press the white RESET button on the device, which is located on the same edge as the USB power cable.
  1. Click on the top entry in the list on the left *CC31XX/CC32XX Flash Setup and Configuration**.
  2. Enter the COM port that your device is connected to.
    For more information on how to determine the COM port that the device is connected to, please see our Troubleshooting Section.
  1. Click Format.
  2. Select 1 MB from the popup window and click OK.
  3. When complete, click Program
  4. Once that's complete your device is completely flashed with the software you need.

Step 7 of 9 Store New Firmware in Dropbox

The Xively SFT Service requires the files be hosted in cloud storage. You could host the file on your own servers, but for the sake of this example, we'll describe how to host the file on Dropbox.

  1. Create an account in Dropbox, or login to your existing account.
  2. In the left-hand menu, click on My Files.
  1. Browse to the FirmwareB.bin file on your machine (download link from above) and drag it into the DropBox webpage.
    Tip: A pop-up bar at the bottom of the page will track the file upload progress.
  2. Once the download is complete, click the filename in DropBox file list.
  3. Click the Share button in the upper right corner of the page.
  4. Click Create Link and copy the link.
  5. Paste link into a text editor. At the end of the string you should see ?dl=0. Alter this by turning the zero into a one: ?dl=1. Save this URL as you need it for the next step.

Step 8 of 9 Configure Xively Secure File Transfer

Create a new deployment

  1. Login to Xively CPM.
  2. Click on Devices > Firmware deployment
  3. Click the Create new deployment button in the upper right corner of your screen.
  4. Click on Untitled firmware package and name it CC3200 SFT Tutorial

Add your CC3200 device

  1. Click the Add test devices button.
  2. Click on the Device Template Filter pulldown box.
  3. Select the CC3200 SFT Demo template that you created earlier.
  4. Check CC3200 Launchpad XL.
  5. Click the Add button in the lower right.

Add the firmware file to the deployment

  1. Click Add files
  2. For the *Name type firmware.
  3. For the *Revision type 1.01
  4. For the *File URL paste your dropbox download link with the `?dl=1' suffix.
  5. For the checksum copy and paste the following string: ZTA3ODNhZWY5MjExZTU5Yzk5YjNiMDRkMGZhYmRjMDc3YjFlMmQ3YjEzMWQ3OTkyMjhlN2VjZjZlYWFiZDQxZg==
  6. Click the Add button.

📘

Note:

The fingerprint is a SHA-256 digest of FirmwareB.bin computed using the online tools MD5 File.com</> and then Base64 Encoded using Base64 Decode and Encode. If you compute these values yourself, please be sure to use the SHA-256 algorithm and remove all leading and trailing spaces in the Base64 Encode text area before hitting Encode.

Confirm the Firmware deployment

Click the Run Test button in the upper right, then click Start on the confirmation dialog.

Result: You now have a Secure File Transfer deployment of a firmware file, its revision number and its checksum.

📘

Warning:

While Xively SFT can be used to deliver multiple files in a single software deployment, this demo has safety mechanisms to ensure that you have configured this tutorial exactly as prescribed.

Therefore if you were to add more than one file to this deployment, or if you were to name the file something other than firmware, then the firmwareA.bin Application that you flashed onto the device will reject the firmware update.

Step 9 of 9: Run Demo

  1. If you've just flashed your device, remove the jumper from the SOP jumper section, highlighted by the blue box in the image above.
    Important: If you do not do this step then the device will continue to be in ready-to-flash mode and will not execute the program you've loaded onto it.
  2. Plug in the device then hit the RESET button.
  3. Your device should flash its three lights while it provisions itself onto your WiFi. If your lights continue to blink then please check to ensure that you're WiFi Credentials are correct in your xively_cfg.txt file (Step 5) and reflash your device with your changes (Step 6).

Check Device Connection

If the lights have stopped blinking, then check to see if your device is properly connected.

  1. Open up the Devices' Details Page ( Devices->All Devices->TI CC3200-LAUNCHXL).
  2. Click the Messaging tab at the top.
  3. InPublish To, select blink.
  4. Type 1 into the text area and click Publish
  5. Check the lights on the device. The Green and Orange LED lights should be illuminated.
    Result: your device is connected to Xively and subscribed to its topics!

Start the Device SFT Delivery.

The device will report its current firmware revision to Xively SFT when you push the SW2 button in the lower right of the device. When you press this button Xively SFT tells the device that the newer firmware is available. The device starts requesting this firmware in 1kb chunks, flashing the Red LED for every chunk it downloads.

Upon completion, the device will reboot with the new firmware and you must click the SW2 button.

Confirm the New Firmware is Bootable

After the firmware is download, all of the lights will illuminate and the device will reboot.

  1. Confirm the device is properly connected by sending another message on the blink topic. You can send a value of 1 again.
  2. You should now see only the Green LED light up.
  3. Send another 1 on the Blink topic.
  4. You should now see the Green LED switch off and the Orange LED illuminate. This means that the new firmware is installed!
  5. Unplug the device and plug it back in then repeat the test to ensure that the firmware is flashed properly and is committed.

Congratulations! If you've made it this far then this means you have successfully delivered new firmware to a TI CC3200!

Appendix A: Troubleshooting

I've changed the hosted firmware file in SFT but my device continues to receive the older file

Files configured in Xively SFT are cached in order to be able to distribute them to a massive number of devices. Due to this, if you change the file in at the download link that you've created, then you will need to delete the firmware package and create a new one. Doing this will reset the cache and allow you to use the same download link as before.

All Three Lights Continually Flash on Boot

This is a CC3200 WiFi driver reaction to being unable to connect to a WiFi access point. Check your WiFi and Xively credentials file and re-flash the device with any changes. See Step 3 of 9 Provision a Device in Xively for more information.

UniFlash complains that it can't connect the device.

This usually occurs because the SOP 2 Jumper does not have the jumper connecting the two pins. See the section Format and Flash the Device for information on how to configure the jumper, and then press RESET on the device before attempting to use UniFlash to configure the device again. Note: you don't need to restart UniFlash.

How do I determine my COM port on Windows?

  1. Ensure that your CC3200 is plugged into your computer with the USB cable that came with your device.

  2. Type Device Manager into your start menu search bar.

  3. Click on Ports (COM & LPT)

  4. Look for an entry CC3200LP Dual Port and note the COM port number.

Example:

How do I connect a serial connection?

To debug further you can run a serial terminal to monitor debug logs on the device in case your device fails to connect to Xively and you need to diagnose the problem, or if you are curious about what the device is currently doing.

  1. Install a serial terminal program.
    We recommend Putty (Windows) or Serial Tools (macOS).
  2. Ensure that UniFlash is closed.
    Note: Depending on what UniFlash is currently doing, it might monopolize the serial connection that you are trying to establish. It is safest to close the program until you become more comfortable with UniFlash connection states.
  3. Ensure that the jumper SOP 2 has exposed pins and the jumper has been removed.
  4. Use your serial terminal program to connect to your device.
    The connection should have the following terminal properties:
  • Baud Rate: 115200
  • Data Bits: 8
  • Stop Bits: 1
  • Parity: None
  • Flow Control: None
  • Com Port: This is specific to your computer. This is usually com3 on Windows, and usbModem on macOS.
  1. Start the terminal session by clicking Connect on your client.
  2. To get the full console log, reset your device. Press the RESET button on your CC3200.

Appendix B: Blink

This section will describe how to run a python script on your computer to constantly publish blink messages to your device even while it's loading new firmware. This is meant to show that the device is properly connected and that the Xively C Client can download fimrware in the background without interrupting application control or application flow.

Appendix C: Build Client from Scratch

The source for this example is in the examples\cc3200\xively_firmware_updates of the Xively C Client github repository. Building this application is similar to building our standard CC3200 Demo Example, so if you can then map that knowledge to this example. Feel free to build and test the example for yourself.

A Step by Step tutorial for building the example from scratch for this specific example is coming soon.

Updated 2 years ago

TI CC3200 SFT Example


Secure File Transfer for CC3200 Firmware Updates

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.