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.

About Off-chip OAD in BLE-Stack v2.1

Other Parts Discussed in Thread: CC2640, BLE-STACK, CC2650, CC2650STK

Hi, Experts

I am currently working on a project based on CC2640. I have some questions about OAD with external flash.
In the last release version of BLE-Stack, it includes OAD for external flash.
I have built and tested project "SensorTag" included in this package on CC2650 SensorTag device.

Now, I want to verify OAD feature, but the reference project in document "Over-the-Air Download User’s Guide For BLE-Stack™ Version: 2.1.0" is "SimpleBLEPeripheral".
I want to make sure that all steps described in chapter 9 are necessary for SensorTag.
In 9.3.1 "Building the Application Image using IAR",
    step I,
      Should I add symbols "HAL_IMAGE_E" and "SENSORTAG_HW" ?
    step III,
      Should I change the original .icf file to "$PROJ_DIR$\..\..\..\..\..\common\cc26xx\IAR\cc26xx_ble_app_oad.icf" ?
      Should I add symbol definition "APP_IMAGE_START=0x1000" ?

Besides, in chapter 10 of this document, it only describes how to use "BLE Device Monitor" to send the OAD image in .hex format.
For Off-chip OAD, could I use Android app downloaded from "git.ti.com/.../sensortag-20-android" to do this ?
I think it supports both On-chip and Off-chip solutions in .bin format.
Besides, for Off-chip solution, this app seems to use a full 128KB .bin OAD imgae but image created by previous scenario would be 120KB only.
Am I right ?

Any suggestion will be appreciated.

  • Hi Bohan,

    Actually there are two slightly different off-chip OAD models. One is used in SensorTag OAD sample application and the other is used in SimpleBLEPeripheral OAD sample application runnng on SensorTag hardware. The OAD User's Guide describes only the latter one which is more fail-safe than the former one.

    The differences between SensorTag OAD sample app and SBP OAD sample app are as follows:

    <SensorTag OAD sample app>
    - Works with the BIM of the configuration 'BIM_extflash - FlashOnly_SensorTag'
    - The application image starts at 0x00000
    - When reset, the application starts.
    - When OAD completes, the application calls the BIM so that it copies the downloaded image from the off-chip flash to the on-chip flash and reset the system.
    - Works with Android/iOS SensorTag app for OAD

    <SBP OAD sample app running on SensorTag HW>
    - Works with the BIM of the configuration 'BIM_extflash - FlashOnly'
    - The application image starts at 0x01000
    - When reset, the BIM starts and copies the image from the off-chip flash to the on-chip flash if any. Then, jumps to the application image.
    - When OAD completes, the application reset the system.
    - Works with Windows BLE Device Monitor application for OAD

    Hence, which model is more proper for your product should be considered first. Once the model is chosen, please start with the sample application corresponding to the chosen OAD model.

    - Cetri
  • Hi, Cetri

    Thank you for your reply and suggestion.
    This sounds more reasonable and it is similar to pre-release version we got from FAE before.
    Because our hardware design is similar to CC2650 SensorTag, if I don't misunderstand,
    the proper procedure with IAR IDE might be

    For BIM project :

    (1) Choose "FlashOnly_SensorTag" configuration for BIM project.

    For Application project :

    (1) Add symbols "HAL_IMAGE_E" and "SENSORTAG_HW".

    (2) Add post-build Python command to generate App+Stack combined hex image.

    (3) Change linker configuration .icf file to "$PROJ_DIR$\..\..\..\..\..\common\cc26xx\IAR\cc26xx_ble_app_oad.icf".

    (4) Add configurable file symbol definition "APP_IMAGE_START=0x0000"

    (5) Switch the RTOS in Flash configuration.

    However, I am not sure if these mentioned steps for application project are still necessary or not.
    I think (1), (2), and (5) might not be needed. Am I right ?
    Besides, could I use JFlash to combine each .hex image of application, stack and BIM project to generate final full image in .bin format ?
    Is there official procedure to do this ?

    Thank you.
  • Hi, Cetri

    Would you please give me any suggestion or advice ?

    Thank you.
  • Hy,

    when trying to compile the Sensor Tag OAD example as described above, I see an eclipse warning about an invalid include path:

    Does this have any relevance? I can't find the folder "OADExtTester" on my PC, did I miss anything during installation?

    Regards

    Harald

  • Hi Bohan,

    First, you need to choose which OAD mode you want to follow, the generic, fail-safe model or the legacy ST-specific model. If you decide to go with the legacy model(I suppose you prefer this), I would recommend starting with the 'FlashOnlyOAD' configuration of SensorTag project and not following anything in the CC2640 BLE OAD User's Guide.

    Regarding bin images merge, I think it's doable to combine the BIM for ST, the application and the stack altogether into one binary file to flash the device initially. However, the images to be downloaded through OAD shouldn't include BIM.

    - Cetri

  • Hi Harald,

    Where did you get the project? It seems that you are using an alpha version project on top of the official latest release. Please try the one included in the official release.

    - Cetri
  • Hy, I was wrong: the warning results from the BIM_ExtFlash project in "FlashOnly_SensorTag" configuration
    c:\ti\simplelink\ble_cc26xx_2_01_00_44423\Projects\ble\util\BIM_extflash\CC26xx\CCS\.cproject line 145 contains this include path. This is from the Stack 2.1 installation ble_cc26xx_setupwin32_2_01_00_44423.exe that I downloaded Aug 3rd this year.
    Regards
    Harald
  • Hi Harald,

    Thanks for letting us know. You can just ignore it if it doesn't prevent the project from being built. You can remove that line from the property as well.

    - Cetri
  • Hi, Cetri

    Thank you for your advice.
    Yes, We need to use Android and iOS applications to upgrade firmware, so we choose the legacy ST-specific model for OAD.
    Do you have any document describing the detail procedures to generate OAD image for this ?

    I have done some tests, but unfortunately, the most tests failed to work and made device useless.
    IAR or SmartRF Flash Programmer2 would fail to upload firmware to the device after unsuccessful OAD.
    Besides, these devices would contain invalid Bluetooth address, 00:00:00:00:00:00.

    No matter I choose "FlashOnly" or "FlashOnly_SensorTag" for BIM project, if I don't follow
    "Over-the-Air Download User’s Guide For BLE-Stack™ Version: 2.1.0" to
    build three projects and combine ALL THREE images into one OAD image, OAD would fail and make device useless.

    The only way I could do OAD successfully was using the combined full 128KB (BIM + App + Stack) image.
    I have tested these on both CC2650 SensorTag and our CC2640 device.
    However, there is one more problem on our CC2640 device.
    Our device could not restart automatically after OAD procedure was complete, but OAD image had been upgraded into internal flash successfully,
    because device would work again with new firmware if I power off and on device manually.

    Android application source code is downloaded from git.ti.com/.../sensortag-20-android.

    Our product will enter mass production next month. I need to solve this problem as soon as possible.
    Would you please help me with this ?

    Thank you.
  • Hi Bohan,

    I'm sorry my explanation about the merged image was wrong. An OAD image CAN include BIM in it, so you are going in one of the right directions. By the way, it should work without BIM as well, but I found that it doesn't work without BIM in case there has been some garbage data in the beginning of the page 31, which is the placeholder for the BIM, of the off-chip flash memory. In that case,  the garbage data will mislead the OAD service into considering as if a new BIM exists and copying it into the on-chip flash. One of the simplest fixes for this would be as follows:


    void OAD_imgIdentifyWrite(uint16_t connHandle, uint8_t *pValue) { ... if (OADTarget_validateNewImage(pValue+hdr_offset, &ImgHdr, oadBlkTot)) { imageAddress = OADTarget_imageAddress(pValue+hdr_offset); imagePage = imageAddress / HAL_FLASH_PAGE_SIZE; // Open the target interface OADTarget_open(); #if 1 // Erase the BIM page OADTarget_eraseFlash(31); #endif // Store the image header OADTarget_storeImageHeader(pValue); // Image accepted, request block 0. OAD_getNextBlockReq(connHandle, 0); } ... }

    - Cetri

  • Hi, Cetri

    Thank you for your advice.

    I will try the modification you suggested.

    Although I could succeed in completing off-chip OAD process by my own way,

    would you please help me to confirm that my procedure is correct and acceptable, or if TI has suggested official procedure for this ?

    (1) Choose "FlashOnly_SensorTag" for BIM project

    (2) Change linker configuration .icf file to "$PROJ_DIR$\..\..\..\..\..\common\cc26xx\IAR\cc26xx_ble_app_oad.icf".

    (3) Add configurable file symbol definition "APP_IMAGE_START=0x0000"

    (4) Combine BIM, App and Stack hex images to generate final .bin image by using JFlash.

    (5) Use Android App downloaded from "git.ti.com/.../sensortag-20-android" with this

       .bin OAD image to upgrate firmware.

    Besides, have you had any experience with system getting stuck in following step

    void Bim_safeStart(uint32_t start, uint32_t len, uint32_t dstAddr)
    {
      // Initialize external flash driver.
      BLS_init();
    
      // Copy over the image. Note that failure cannot be handled.
      Bim_copyImage(start, len, dstAddr);
    
      // Close external flash driver.
      BLS_close();
    
      // Trigger reset.
      HWREG(PRCM_BASE + PRCM_O_WARMRESET) = 4;
      WatchdogResetEnable();
      WatchdogEnable();
      WatchdogReloadSet(0);
    
      // Enable reset interrupt.
      CPUcpsie();
    
      // Stay here till reset.
      for (;;);
    }

    Is there any method to verify this or any clue to find out the root cause ?

    Any suggestion will be appreciated.

    Thank you.

  • Hi Bohan,

    As I stated multiple times, please use the existing SensorTag project as the baseline. SensorTag project is using cc26xx_ble_app.icf and doesn't define APP_IMAGE_START because the default value is 0x00000.

    Where in Bim_safeStart() is the system stuck? This may not be relevant, but just for your information, off-chip flash access is not possible in debug mode because one of SPI pins is multiplexed with one of debug pins.

    - Cetri
  • Hi, Cetri

    I apologize for my unclear and wrong description.
    Yes, I do use existing SensorTag project as the baseline, and my previous procedure is based on it, too.
    But I am sorry that I made a mistake about "APP_IMAGE_START". It should be 0x1000 but not 0x0000 in my previous reply.
    The reason I bother you so many times with this off-chip procedure is I need to make sure I don't get the wrong way before production.
    Except for OAD, it will be impossible to do anything about firmware in our product after production.
    I feel very sorry about this, and thank you for your understanding.

    Besides, I know DIO_17 is shared by both SPI clock and TDI in CC2650 SensorTag, but we make individual pins for this in our design.
    Thank you for reminding me about this.

    I think system gets stuck in final "for loop" because system reset dose not take place.
    I add LED control in the beginning step of application task function, but it dose not get there.
    I don't know how to verify this in more detail and I have no idea about the possible root cause currently.
    If the OAD process I take is confirmed to be correct and acceptable, this is the last problem I need to solve.

    Would you please give me some suggestions about this ?

    Thank you.
  • Hi Bohan,

    The legacy ST-specific OAD is NOT fail-safe. If OAD is the only way to update the firmware after production, I would recommend using the generic OAD although I know this is too late as your development is almost at the final stage.

    I'll take a look at the system reset failure issue when I'm back to work. Sep 7 is a holiday here. Thanks for your understanding.

    - Cetri

  • Hi, Cetri

    OK !
    Feel really sorry to bother you on holiday.

    Looking forward to your further suggestions... : )

    Thank you.
  • Hi Bohan,

    We are looking into this. In the mean time, can you replace the watchdog reset with the hard-reset-equivalent function as follows?

    void Bim_safeStart(uint32_t start, uint32_t len, uint32_t dstAddr)
    {
      // Initialize external flash driver.
      BLS_init();
    
      // Copy over the image. Note that failure cannot be handled.
      Bim_copyImage(start, len, dstAddr);
    
      // Close external flash driver.
      BLS_close();
    
    #if 0
      // Trigger reset.
      HWREG(PRCM_BASE + PRCM_O_WARMRESET) = 4;
      WatchdogResetEnable();
      WatchdogEnable();
      WatchdogReloadSet(0);
    
      // Enable reset interrupt.
      CPUcpsie();
    #else
      // system reset
      HAL_SYSTEM_RESET();
    #endif
    
      // Stay here till reset.
      for (;;);
    }
    

    - Cetri

  • Hi, Cetri

    Sorry for late reply due to business trip.
    I have tested methods you suggested.
    After many tests and verifications, I am sorry that I think I misled us.
    System reset in previous function works.
    System gets stuck in some procedure of BIM after successful reset due to incorrect OAD image.
    I create off-chip OAD image in the wrong way because I might misunderstand what you suggested.
    However, finally, it works...

    Besides, could I use these system reset methods in normal BLE application ?

    Thank you for your help and advice these days.

    Have a nice day ! : )
  • Hi Bohan,

    Good to know it works.

    Yes I think you can use the system reset in your application.

    - Cetri

  • Hi Cetri,

    I follow BLE Stack-2.1 OAD user guide and test off-chip OAD function with IAR and CCS. I can update FW success with IAR project, but there is no response after OAD complete with CCS project. Can you help to check this issue? Thanks
  • Hi YUHUA,

    Did you follow the last paragraph of section 9.3.2 step VI? That's one difference between IAR and CCS builds.

    - Cetri

  • Hi Cetri,

    Yes, of course. If you do not follow step VI, you will get error.
    In your test, CCS project can work correctly?
  • Hi YUHUA,

    I found an error on the post processing command for CCS project. Sorry about it. The size of the stack generated by CCS is a little bigger than that generated by IAR, so the starting address of the stack should be adjusted accordingly when making an App+Stack combined image.

    Please go to Property->Build on the application project and select Steps tab. There is 'Post-build steps' as follows:

    "${CG_TOOL_HEX}" -order MS --memwidth=8 --romwidth=8 --intel -o "${ProjName}.hex" "${ProjName}.out"
    python "C:/Python27/Scripts/hexmerge.py" -o "${PROJECT_LOC}/FlashOnly_ST_OAD_ExtFlash/OAD_IMAGE_FULL.hex" -r "1000:1CFFF" --overlap=error "${PROJECT_LOC}/FlashOnly_ST_OAD_ExtFlash/${ProjName}.hex":1000:EFFF "${PROJECT_LOC}/../SimpleBLEPeripheralStack/FlashROM/SimpleBLEPeripheralStack.hex":F000:1CFFF

    Modify the end address of the application from EFFF to DFFF and the start address of the stack from F000 to E000 as follows:

    "${CG_TOOL_HEX}" -order MS --memwidth=8 --romwidth=8 --intel -o "${ProjName}.hex" "${ProjName}.out"
    python "C:/Python27/Scripts/hexmerge.py" -o "${PROJECT_LOC}/FlashOnly_ST_OAD_ExtFlash/OAD_IMAGE_FULL.hex" -r "1000:1CFFF" --overlap=error "${PROJECT_LOC}/FlashOnly_ST_OAD_ExtFlash/${ProjName}.hex":1000:DFFF "${PROJECT_LOC}/../SimpleBLEPeripheralStack/FlashROM/SimpleBLEPeripheralStack.hex":E000:1CFFF

    Let me know if this works.

    - Cetri

  • Hi Cetri,

    Thank you for your help. It works.
  • 你的for loop是如何解决的?我的BIM_ext只在调试的时候才正常工作,直接上电起动不了。
  • Hi, I'm a student in Univ of Texas at Arlington, we are working on the OAD project. Bricked many tags. for Sensortag we were able to get the image working with-$ C:\Python27\Scripts>python hexmerge.py -o SensorTagSuper.hex -r 0000:1FFFF SensorTag.hex:0000:1EFFF SensorTagStack.hex BIM_ExtFlash.hex:1F000:1FFFF --overlap=error - from wiki

    But not able to do the same for SBP. range as below

    python C:/Python27/Scripts/hexmerge.py -o D:\testbin\SimpleBLEPeripheralSuper.hex -r 1000:1FFFF D:\testbin\SimpleBLEPeripheral.hex:1000:EFFF D:\testbin\SimpleBLEPeripheralStack.hex :F000:1CFFF D:\testbin\BIM_ExtFlash.hex:1F000:1FFFF --overlap=error (try)(R1)(bricked the tag)

    Can you share the phyton script used to combine (BIM+App+Stack).

    Thanks
    Karthik
  • Hi Cetri, We are working on a OAD project at Univ of Texas,Arlington.

    If you have Sensortag firmware on the Tag, is it possible to OAD a SBLEP over the Sensortag project as it connects via mobile App?

    The wiki processors.wiki.ti.com/.../CC2650_SensorTag_User's_Guide gives
    -C:\Python27\Scripts>python hexmerge.py -o SensorTagSuper.hex -r 0000:1FFFF SensorTag.hex:0000:1EFFF SensorTagStack.hex BIM_ExtFlash.hex:1F000:1FFFF --overlap=error for the App+stack+BIM for ST, it was succesful

    but for SBLEP it gives

    python "C:/Python27/Scripts/hexmerge.py" -o "${PROJECT_LOC}/FlashOnly_ST_OAD_ExtFlash/OAD_IMAGE_FULL.hex" -r "1000:1EFFF" --overlap=error "${PROJECT_LOC}/FlashOnly_ST_OAD_ExtFlash/${ProjName}.hex" "${PROJECT_LOC}/../SimpleBLEPeripheralStack/FlashROM/SimpleBLEPeripheralStack

    -I understand the App image for ST starts at 0X0000 & for SensorTag it starts at 0x01000.
    -The BIM for the ST is different config from the BIM for SBLEP
    Can we use the APP+Stack+BIM of SBLEP over the Sensortag firmware through the Mobile APP. Please give the steps. We have bricked many tags with no success
  • Hi Karthik,

    You can refer to the first response on the page 1, SBP OAD sample works with Windows BLE Device Monitor application.

    Regards
    Wei
  • Thank you Wei Lu.

    - with BLE Device Monitor what Hardware should be used. I have the CCdebugger. I presume some Bluetooth Hw is reqd with it. Please share a link of the hardware to buy

    -If the firmware on cc2650stk kit is SensorTag project, is it possible to do an OAD of SBLE over it?

    Thanks

    Karthik

  • Hi Bohan,

    Can you share the way you build a successful OAD program?

    Wei
  • Hi Cetri,
    We were able to do OAD of Sensortag with a new version using
    $ C:\Python27\Scripts>python hexmerge.py -o SensorTagSuper.hex -r 0000:1FFFF SensorTag.hex:0000:1EFFF SensorTagStack.hex BIM_ExtFlash.hex:1F000:1FFFF --overlap=error

    We bricked many tags trying to do it for SBLEP,
    will
    $ C:\Python27\Scripts>python hexmerge.py -o SimpleBleperipheralSuper.hex -r 0000:1FFFF SimpleBleperipheral.hex:0000:1CFFF SimpleBleperipheralStack.hex BIM_ExtFlash.hex:1F000:1FFFF --overlap=error
    - SBLEP App starts at Ox0000,
    - BIM is for SBLEP
    -Trying to write the same size of the SBLEP hex from 0x0000 instead of 0X0000
    -Create a bin

    When the App on the HW is SensorTag-> Connect via TI android App->FW upload of the new SBLEP .bin , Will it work or kindly let me how this can be done.

    Thanks & Regards
    Karthikeyan
  • Sorry correction:Trying to write the same size of the SBLEP hex from 0x0000 instead of 0X1000

  • Hi Karthikeyan,

    So you can use TI App to OAD new FW and upgrade successfully on SBP project, right?
    I cannot implement OAD with IOS App.
    Can you explain "Trying to write the same size of the SBLEP hex from 0x0000 instead of 0X1000"?

    Thanks
    Wei
  • Hi Wei,
    We have developed our own Android App. We were able to program a Sensortag project with a new version & still working on SBP OAD.

    The Sensortag's App starts from 0X0000 the oth page but the SBLE spec for OAD as in the OAD guide refers to the SBP app starting from 0x1000 the first page., but that is only for the App+Stack. I had asked Cetri if we can completely replace the 128Kb MCU memory as in the case of SensorTag with App+Stack+BIM for SBP too.

    Best Regards
    Karthikeyan
  • Dear all,

    Maybe , this reply is a little late but I still hope this would have some help.
    I use IAR in my project with following steps to generate a off-chip OAD image for iOS and Android applications. And it works.
    I do not use CCS so I cannot give any suggestion for it. Sorry...

    (1) Config BIM project to FlashOnly_SensorTag
    (2) DON'T follow the official guide to change .icf file ! You MUST use the original one !
    (3) DON'T change APP_IMAGE_START !
    (4) Modify something, change FW_VERSION, and re-build all three projects, BIM, App, and Stack.
    (5) Combine ALL THREE .hex files into one OAD .bin image by using JFlash.
    (6) Use Android app to do OAD with this .bin image

    Indeed, I did nothing except for (1) and (5). Yes, that's it.
    : )
  • Hello,

    我的問題是錯誤的 OAD image 和 interrupt vector 所造成的,與硬件或 code 本身無關!
  • Hi Bohan,

    Thank you.

    Did you try this with the SBP project ?

    Thanks

    Karthikeyan

  • Hi, Karthikeyan


    I do not port and test this feature on SBP. I use SensorTag as our reference project due to hardware similarity.

    But I think it could also work on SBP if BIM and corresponding profiles are integrated.

  • Thank you Bohan, we were successful in OAD for SensorTag but bricked many tags trying SBP. We tried SBP with APP+Stack+BIM for SBP not the SensorTag BIM.

    We are trying to find the right way.

    Best Regards

    Karthikeyan