CC2640 OAD User's Guide

From Texas Instruments Wiki
Jump to: navigation, search

Intro

This page will serve as an addendum to the CC2640 (BLE-Stack v2.x) and CC2640R2F (BLE-Stack v3.x) Bluetooth low energy (BLE) Over-the-Air (OAD) User's Guides. OAD is a Device Firmware Upgrade (DFU) method that allows for updating the firmware wireless over a BLE connection.

For CC2640/CC2650, the OAD User's Guide can be found in the latest BLE SDK installer: http://www.ti.com/ble-stack. The guide is located in the docs folder of the SDK installation. References in this guide to CC2640 apply to CC2650 when running BLE applications.

For CC2640R2F, the OAD User's Guide can be found online as well as in the docs folder of the SDK installation.

Off by one Error for CC2640R2F (BLE-Stack v3.1.0)

Replace the following code in oad.c at line 1985 if(idPld->len > (stackImageHeader->stackStartAddr - 1)) with the following if((idPld->len - 1) >= stackImageHeader->stackStartAddr)

Optimize Available Flash to Application for CC2640R2F (BLE-Stack v3.1.0)

The following steps will maximize the amount of flash available to the user application. There are some tradeoffs:

  • The service changed indication will not be sent
  • (IAR) the entire flash region of the user application will be sent OTA (up to the App/Stack boundary).

1. Optimize stack configuration

  • In the stack project open the build_config.opt file and comment out the following line /* -DV41_FEATURES=L2CAP_COC_CFG */
  • In the application files (oad_persistent_app.c, simple_peripheral_oad_onchip.c) comment out references to GAPBondMgr_ServiceChangeInd( ... );
  • Re-build the persistent application, stack, and user application in that order.

2. Improve packing by giving persistent app a fixed size

  • See the attached linker file for IAR. Patch this file over the one in source\ti\blestack\common\cc26xx\iar
  • Re-build the persistent application, stack, and user application in that order.

3. Allow user application to split .text section for efficient packing

  • See attached linker file for IAR. CCS is not affected
  • Apply the off by one error fix above.
  • In the file oad_image_header_app.c replace references to ROSTK with FLASH_END
  • Re-build the persistent application, stack, and user application in that order.

File:Cc26xx_app_oad_optimized.zip

On-Chip OAD Out of Memory Error for CC2640R2F (BLE-Stack v3.0.1)

Note: BLE-Stack v3.0.1 is delivered in both SIMPLELINK_CC2640R2_SDK v1.30.00.25 and v1.35.00.33.

In the CCS project, oad_target_cc2640r2lp_app, a build error will occur with the following text:

error #10099-D: program will not fit into available memory.

This error occurs during the linking phase of the oad_target_cc2640r2lp_app project. The issue itself is due to the linker wishing to place the .text section of the application into one continuous block. This isn't possible because there isn't a hole in memory large enough to accommodate all of the memory in one chunk. This hole in memory is not the same as unused memory - unused memory refers to all the available memory remaining.

The workaround for this issue is to modify the linker command file to tell the linker it's allowed to break up the .text section based on it's individual objects and place them where they can fit.

In effect, modify the linker command file, 'cc26xx_app_oad_onchip.cmd', such that

.text : > FLASH

becomes

.text : >> FLASH

See E2E post.


On-Chip OAD for CC2640 (BLE-Stack v2.2.1)

Note: TI provides support for demonstrating the out-of-box on-chip OAD example for CC2640 running BLE-Stack 2.2.1 in the configuration specified in the OAD User's Guide. TI is unable to provide support for running other sample applications (Image B) or protocol stack configurations in the on-chip OAD configuration. Customers are encouraged to confirm their application memory requirements can meet the available flash and supported stack configuration in the on chip configuration for CC2640. For larger applications, external flash memory (off-chip OAD) may be required to support OAD. TI recommends customers use the CC2640R2F with BLE-Stack v3.x for supporting on-chip OAD with both IAR and CCS while providing more available application flash memory.

A number of fixes to get the on-chip OAD project working have been identified post-release which are provided in a roll up patch. The patch for the file is located: *On-chip OAD Patch

Apply this patch over a fresh installation of the TI BLE 2.2.1 SDK. The patch updates the OAD related projects and BIM as well as the OAD profile source.

The instructions in the OAD Guide Can be followed with the patch. Here are modified instructions to work with BTool(see addendum for more information):

  1. Build OAD Target app found in $BLE_INSTALL$\examples\cc2650lp\oad_target\iar starting with Stack Project
  2. Create the unified hex file by running merge.bat found in $BLE_INSTALL$\examples\cc2650lp\oad_target\iar\app
  3. Flash oad_target_cc2650lp_unified.hex in $BLE_INSTALL$\examples\cc2650lp\oad_target\iar\app with Flash Programmer 2
  4. Build Image B by opening simple_peripheral sample project, and selecting the FlashOnly_OAD_ImgB, just the app project only
  5. Create the OAD binary by running onchip_img_b.bat found in $BLE_INSTALL$\examples\cc2650lp\simple_peripheral\iar\app
  6. Use BTool to OAD simple_peripheral_cc2650lp_img_b.bin to the OAD target (the LP flashed with oad_target_cc2650lp_unified.hex)

Addendum

TI OAD Image Tool

We recommend using the TI OAD Image Tool to generate hex and bin files. It is documented in the appendix of the OAD User's Guide.

The tool can be downloaded from https://github.com/ti-simplelink/ble_examples

Using BTool with CC2640

The CC2640 BLE OAD User's Guide found in the BLE SDK installer specifies the use of BLE Device Monitor as the OAD downloader. BTool is now being suggested as the OAD downloader, as it solves some of the known issues with BLE Device Monitor. This section describes how to get the necessary version of BTool and what changes are needed from the Out of box demo instructions provided in the CC2640 BLE OAD User's Guide. Note that these changes apply to both on-chip and off-chip OAD, and they only specify the deviations from the CC2640 BLE OAD User's Guide, which should be used for all other steps.

The latest version of BTool provided with the CC2640R2 SDK is needed. The SDK can be downloaded here: http://www.ti.com/tool/download/SIMPLELINK-CC2640R2-SDK. The version provided with BLE-STACK V3.0 is BTool v1.41.16.

Required hardware and software:

  • 2 CC2650 LaunchPads (1 for the target and 1 for the downloader)
  • BLE-Stack SDK 2.2.x
  • BTool (version provided with the latest CC2640R2 SDK)
  • Flash Programmer 2
  • Python 2.7.x (v2.7.10 or higher)

Needed changes from steps in CC2640 BLE OAD User's Guide:

  1. Use BTool instead of BLE Device Monitor. To do this, build and download the app and stack projects for host_test onto the CC2650 LaunchPad that is being used as the downloader. Then, open BTool and connect to the device being used as the downloader. Scanning for devices using the "Scan" button under the "Discover/Connect tab" should show the desired OAD target (preparing this device has not changed form the instructions in the CC2640 BLE OAD User's Guide). Find the OAD target device under "Slave BDA" and click the "Establish" button. Then, select the "OAD" tab to begin initiating the OAD process. Using the "Read Image File" button, choose the file that is to be sent with OAD. Press the "send" button to begin OAD, and use the "Status" field to verify that the process was successful, and to keep track of how many blocks have been sent during the process. See the following image for an example:
    BTool_OAD_example.png
  2. Use the TI OAD Image Tool as described in the CC2640 BLE OAD User's Guide, but be sure to output a bin file (the example in the guide only outputs a hex file). This bin file is what will be sent over with OAD using BTool.


Known Issues

Some known issues have been reported and resolved on the E2E forum, please see Relevant E2E forum posts below. Other know issues will be listed in this section.

IAR OAD Project Crashes after Boundary change

This is a known issue affecting BLE Stack 2.2.x projects. The issue can be reproducing using the the simple_peripheral project OAD_ExtFlash configuration in IAR.


Steps to re produce:
  1. Change build_config.opt to enable a feature that grows the stack boundary (i.e. enable Data Length Extension)
  2. Re-build BIM, stack, then app projects.
  3. Load these projects in the same order.
  4. Notice the device will crash after BIOS_Start, this is because the memory at ICALL_STACK0_ADDR is corrupted (0xFF)
Steps to Resolve:
  1. Go into the application project, right click and selection options
  2. Select Linker from the left hand pane
  3. Select Checksum pane
  4. Uncheck the "Fill unused code memory" box
  5. Re-build the application project.


Relevant E2E Forum Posts