This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Off-Chip OAD does not work with IAR Optimization set to High?

Part Number: CC2640R2F

Hi,

    Here below are what I have observed Off-Chip OAD failure when IAR Optimization set to High.

Scenario A:

  1. Set App optimization to None. Rebuild All BIM, App and Stack and Flash all 3 to CC2640R2 Launchpad.
  2. Create a OAD Image. Change Advertisement Name. Set App optimization to High. Rebuild All App to generate OAD Image bin file.
  3. Perform OAD using BTool. BTool OAD will start and finish successfully.
  4. Check Advertisement Name of CC2640R2 Launchpad if has change. Result is Advertisement Name is still the same and not changed. Meaning OAD was not successful.

Scenario B:

  1. Set App optimization to High. Rebuild All BIM, App and Stack and Flash all 3 to CC2640R2 Launchpad
  2. Create a OAD Image. Change Advertisement Name. Set App optimization to High. Rebuild All App to generate OAD Image bin file.
  3. Perform OAD using BTool. OAD_FLASH_ERROR was returned. OAD did not start and not successful.

     This is an issue for us because, if we do not set IAR optimization to High, the App will exceed the set flash space limit. Is there any way to make the OAD work with IAR optimization set to High?

- kel

  • Hi Markel,

    By how much are you exceeding the flash, how big is your application project? You can see our guide on tips to optimize the flash:
    software-dl.ti.com/.../creating-a-custom-bluetooth-low-energy-application.html

    Best wishes
  • Hi Zahid,

        Here below are the sizes I am getting..

    APP optimization High

    52 755 bytes of readonly  code memory

      4 294 bytes of readonly  data memory

     12 497 bytes of readwrite data memory (+ 64 absolute)

    APP optimization None

    total estimated minimum size of 0x1122b bytes or 70187 bytes

    - kel

  • Hi Zahid,

    I have already applied the tips to optimize the flash before. The problem is when the optimization is set to high, Off-Chip OAD fails.

    - kel
  • Hi,

    Any help regarding this? I am thinking of setting every OAD related functions and variable to volatile, so they won't be affected by optimization.

    - kel
  • Hi Markel,

    Are you setting it high based on speed or size? And which IAR version are you using? Were you able to make it work out of the box?

    It seems you are close to the max size. The BLE5 stack size is 63KB. so the app size left over would be:

    128(total flash) - 63(stack) - 4(BIM) = 61KB

    Best wishes

  • Hi Zahid,

         I set the optimization high based on size. Anyway, I debug our CC2640R2F firmware that was ported to BLE5 Simple Peripheral Off-Chip OAD example program with optimization set to high and I found out that I was not able to debug step into extFlashVerifyPart(). So I set #pragma optimize=none to extFlashVerifyPart() to disable optimization for this function. When I was able to debug step the extFlashVerifyPart(), I get Device ID = 0x00, So this is what I read below from SPI External Flash.

    Manufacturer ID = 0xC2

    Device ID = 0x00

    At original BLE5 Simple Peripheral Off-Chip OAD Example Program with Optimization set to None. This is what I read below, which is the correct value for the External Flash.

    Manufacturer ID = 0xC2

    Device ID = 0x14

    - kel

    Post Edited . . .

    Answers to the other questions.

     And which IAR version are you using?

    IAR Version 8.11.1. We have been using this IAR Version for months and there is no problem using with SDK v1.35 BLE 5.

    Were you able to make it work out of the box?

    Yes, I was able to make the BLE 5 Simple Peripheral Off-Chip OAD example program work out of box. As mentioned in my first post the scenarios where the BLE 5 Simple Peripheral Off-Chip OAD example program will fail Off-Chip OAD.

  • Hi.

        This below is the screenshot of the wrong SPI External Flash Device ID reading. This is BLE5 Simple Peripheral Off Chip OAD Example Program with Optimization set to High (Size). As you can see the infobuf array 2nd byte device id is 0x00. If the Optimization is set to None. the infobuf 2nd byte device id read will be 0x14 which is correct for the SPI External Flash I am using.

    - kel

  • Hi kel,

    Since you are using IAR 8.11.1 instead of the specified IAR EWARM 7.80.3 for SDK 1.35, you'll need to own the investigation for any incompatibility issues. My advice would be to do the following:
    - Rebuild the driverLib and other TI drivers libraries with your IAR version to address the w_char change in the newer IAR EWARM version
    - Experiment with selectively reducing optimization on specific functions with the #pragma optimize=<level> pragma directive

    Note that our next SDK 1.40 will be published in the next few days and contains in-box support for IAR 8.11.1. All of the coreSDK components will be built with this IAR version.

    Best wishes
  • Hi JXS,

    JXS said:
    My advice would be to do the following:- Rebuild the driverLib and other TI drivers libraries with your IAR version to address the w_char change in the newer IAR EWARM version

    How do I do that? Maybe, if I do that I do not need to add the SPI.c, SPI.h, SPICC26XXDMA.c, SPICC26XXDMA.h to the IAR project

    Anyway, I already made the BLE 5 Simple Peripheral Off-Chip OAD example program work with optimization set to High. Here below are my settings.

    1. Set project optimization to "High->Size" with only "Static Clustering" selected. 
    2. Set ExtFlash.c, oad.c, oad.h, oad_target_external_flash.c. optimization to "None"

    I am going to apply these setting to our CC2640R2F product firmware and make it work.

    JXS said:
    Note that our next SDK 1.40 will be published in the next few days and contains in-box support for IAR 8.11.1. All of the coreSDK components will be built with this IAR version.

    Thanks for the information. 

    - kel

  • Hi JXS,

         I have applied the settings to our CC2640R2F Product Firmware. During OAD it writes block per block slowly and then disconnects. Have you experienced the same?

    - kel

  • Hi,

    Anyway for our CC2640R2F Product Firmware, after I commented out 2 BLE Services, I was able to do several successful Off-Chip OAD. I will just find out what if I need to increase stack or heap in order to do Off-Chip OAD with all our BLE Services included.

    - kel