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.

CC2540: OAD Manager Fails to Send Large Image B

Part Number: CC2540

Hello All,

I am currently working on performing OAD on an Image-B that has been modified to use more than half of the flash memory. 

I have completed the following steps:

1. Load BIM onto Target Device Using Smart RF Flash Programmer

2. Load Image-A Using Smart RF Flash Programmer

3. Load Image-B Using Smart RF Flash Programmer

- Image B is Running - I can connect to Bluetooth and receive notification updates. Verified by LED output (Green LED) Great!

4. Using OAD Manager on a SmartRF05 board:

- Connect to device

- Load IMAGE-A.bin through Serial Boot Loader tool

- Send OAD update

5. Image-A is now running - I can connect to Bluetooth, (no notifications from Image-A) Verified by LED output (red LED) Great!

6. Using OAD Manager on a SmartRF05 board:

- Connect to device

- Load IMAGE-B.bin through Serial Boot Loader tool

- Serial Boot Loader Tool Fails with the following error:

7. I debug the OAD_Manager program to find where the fail code is being sent. I traced it back to this point:

8. If I pass this break point quickly, it will show the error message shown in #6 above instead of a timeout. 

Some notes that I have done:

  • I am using SimpleBLEPeripheral to create Image-A and Image-B. 
    • OAD_IMG_A_AREA        52  
    • OAD_IMG_B_AREA       (124 - OAD_IMG_A_AREA)
    • I noticed there is a discrepancy in the OADManager of the OAD_IMG_B_AREA, but changing this value to match makes me get an error (same as #6 above) as soon as I click Load Image in the SBL tool without even downloading anything (immediate error 0% progress).

Any help is greatly appreciated!

  • Hi Obie,

    Have you attempted to sniff the communication? Also, have you tried OAD from a smartphone?

  • J Lindh said:

    Hi Obie,

    Have you attempted to sniff the communication? 

    Hello Joakim,

    I am not actually getting to the point where I send the file over the air, so I have not attempted to sniff the communication. This is failing before the serial boot loader process can complete in the case of Image-B.

    *Edit: I did step through the UART communication and watched the sbBuf receive data each step. I am not sure what I would be looking for here, but I can step through that.

    J Lindh said:

    Also, have you tried OAD from a smartphone?

    I have not tried OAD from a smartphone. I cannot find any existing reference to this, if you have one I would greatly appreciate it. Although, I prefer to run an OAD manager from a hardware device as I will need to do this in my end use.

  • Hi Obie,

    Have you seen the BLE Developer’s Guide for Over-the-Air Download for CC254x?

    Have you tried following all the steps mentioned there?

    Best Regards,
    Yuval

  • Hey Yuval,

    Yes that is what I followed originally, but I needed more than just two extra pages so I modified my .xcl files as shown below. I am able to successfully complete the process for Image-A (the "small" image) but unable to get the Serial Boot Load process to complete using the "large" Image-B. Note that BOTH of the images  are able to run when directly loaded onto the chip (as .hex). I only have a problem when I try to load my Image-B.bin file (generated linker extra output and build option settings). My Image-A.bin loads to the Serial Boot Loader tool just fine, sends over bluetooth, and runs. Everything compiles and builds without issue. However, my Image-B does not even make it past the Serial Boot Loader step as shown in the original post.

    For reference of my Image-A and Image B here are some details of what I did.

    1. Using SimpleBLEPeripheral here is what was removed from Image-A as suggested by another thread (https://e2e.ti.com/support/wireless-connectivity/bluetooth/f/538/t/265419) :

    - remove SNV

    - remove gapBondMgr calls

    - remove simpleGATT

    - remove deviceInfo

    2. Modifications to .xcl files for Image-A and Image-B

    - Image A  .xcl file Change #1 (old left, new right)

    - Image A  .xcl file Change #2  (old left, new right)

    - Image B .xcl file Change  (old left, new right)

  • Any suggestions? This must have been done before, as I see others claim to have had success...

    Why was all of the information for the CC2540 removed from http://processors.wiki.ti.com/ ?

  • Hi Obie,
    What are in the contents of pBuf during the time that you catch the failure case?
    Also make sure optimization is turned off or you could be hitting the failure case without actually being there.
    Best Regards,
    Yuval
  • Yuval G said:
    Also make sure optimization is turned off or you could be hitting the failure case without actually being there.

    This is great help, thank you!

    I didn't realize optimization was turned on and I could not understand how it was getting to the default case. When I remove optimizations, I now get a failure where I would expect it would happen inside the condition where it checks if it is between the beginning and end.

    Yuval G said:
    Hi Obie,
    What are in the contents of pBuf during the time that you catch the failure case?

    pBuf[RPC_POS_CMD1] is shown below during the failure case, looks like it responds properly when I remove optimization:

    From What I can see here, the t16 value is exceeding OAD_DONGLE_SBL_END so I tried modifying the values that affect that as follows:

    I tried to modify the values of OAD_DONGLE_SBL_IMG_MAX and OAD_IMG_B_PAGE to the sizes that I have them in oad_target.h of the OAD Profile directory that was used to build my SimpleBLEPeripheral images.

    1. Where OAD_IMG_B_AREA (124 - OAD_IMG_A_AREA) where OAD_IMG_A_AREA is 52. This gives me 72. I tried to set OAD_DONGLE_SBL_IMG_MAX to 72.
    2. OAD_IMG_B_PAGE to the value of OAD_IMG_B_PAGE (8) since it starts at 0x4030 where 0x4030 / 0x800 = ~8.

    This did not work unfortunately and looks like it now is calculating t16 before the OAD_DONGLE_SBL_IMG_BEG value but is making it to the default case (optimization is disabled)... I notice that the LCD goes blank in this case and the code does not loop back around if I continue running meaning it crashed hard on the second write. This doesn't happen in the previous case before modifying the values. I think I might be overwriting something here... 

  • I was able to get the SBL to complete successfully!

    I realized that the settings for these Image Sizes are referring to the memory on the OAD Manager board not the OAD target board...As a default, the OAD manager is around 126kb meaning it cannot accommodate the size of a large image as default. 

    I removed gapBondMgr and modified the oad_mgr.xcl to minimize the size of the OAD Manager to :

    113 410 bytes of CODE memory (+ 1 278 range fill )
    28 bytes of DATA memory (+ 87 absolute )
    7 364 bytes of XDATA memory
    194 bytes of IDATA memory
    8 bits of BIT memory
    4 358 bytes of CONST memory

    I then set the OAD_IMG_B_PAGE=55 and #define OAD_DONGLE_SBL_IMG_MAX   72

    This allowed the SBL to complete successfully!

    Note: I was getting stack overflow errors upon SBL completion  using 55 and 72 above before I minimized the OAD Manager code size

    When I press the Joystick Button in I see:

    OAD Chars Found! 
    ImgA Id 2, 7C00

    UserId AAAA

    But it never starts the OAD process, It just stays at that message on the LCD.

    Is it OK to remove gapBondMgr from this project as well or is that screwing up my OAD? 

    Edit: It looks like this is OK, the part that is failing is here:

    I made sure that the Image-B I am sending has the Image B definitions and is Version 0x0004 While the version running on the board should be Image A Version 0x0002. This is also the same message I get if I try to send the Image-A again while Image-A is running.

  • I was able to complete the OAD of Image B by modifying the following in simpleBLEPeripheral.c:

    After changing it from always being true to now be false when using Image-A.

    The download now completes for Image A and Image B.