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.

CC2652R: OTA cannot work in my custom board

Part Number: CC2652R
Other Parts Discussed in Thread: SIMPLELINK-CC13X2-26X2-SDK, LAUNCHXL-CC26X2R1, UNIFLASH, , Z-STACK, CC2538

Hi TI Team,

When I use coordinator  zc_ota_server   (original code SDK 3.10)and zed ota swith (original code in SDK 3.10) with both development boards everything can work perfectly.

And, I just follow the instruction: http://dev.ti.com/tirex/content/simplelink_cc13x2_26x2_sdk_3_10_01_11/docs/zigbee/html/zigbee/ota_upgrade.html#building-and-downloading-target-applications

When I use zed ota swith (original code in SDK 3.10) with custom board OTA says abort and can load only 0.6%.

The only change in flash is we were using the MX25R8035FBDIL0 in custom board instead of MX25R8035FZUIL0 in dev board.

Regards,

Walter

  • Do you use sniffer to check what happens over the air?

  • Hi Walter,

    Have you loaded the flash of your custom board with the BLE project zero sample application? http://dev.ti.com/tirex/content/simplelink_cc13x2_26x2_sdk_3_40_00_02/docs/zigbee/html/zigbee/ota_upgrade.html#building-and-downloading-target-applications 

    A valid image is required on the external flash.  Also make sure that you are properly installing the BIM alongside the application image on the CC2652R1.  You can also refer to the rfWsnConcentratorOadServer example: http://dev.ti.com/tirex/explore/node?node=ABO3oqByvzWKzL027Q16hQ__pTTHBmu__LATEST 

    Regards,
    Ryan

  • It seems your device send OTA Upgrade End Request before it actually receives complete OTA image. I suggest you to trace and debug it.

  • Hi Ryan,

    What SDK need to download for BLE Project Zero?

    If using a custom hardware design including an unprogrammed off-chip external flash device, the BLE Project Zero can be copied as the Factory Image by loading both the project_zero_unsecure_app.hex from <SDK_DIR>\source\ti\ble5stack\hexfiles\<device> and <device>_bim_offchip.hex from <SDK_DIR>\source\ti\ble5stack\hexfiles\<device>\bim_offchip\Release_unsecure projects and holding down BTN-1 after a device reset. 

    What PIN is BTN-1 is it equivalent to button in development board?

    Regards,

    Walter

  • Hi Walter,

    The documentation refers to the latest SIMPLELINK-CC13X2-26X2-SDK (v3.40) so the image can be found in simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\hexfiles, however you could also build this project for your own SDK version by following this SLA: http://dev.ti.com/tirex/explore/node?node=AIixxGE2y6tnPJ7cm65SFQ__pTTHBmu__LATEST 

    BTN-1 is connected to DIO13 as shown on the LAUNCHXL-CC26X2R1 datasheet and silkscreen.

    Regards,
    Ryan

  • Hi Ryan,

    Now it can complete download my ZED after doing this:

    1. reset from uniflash 

    2. load C:\ti\simplelink_cc13x2_26x2_sdk_3_10_00_53\source\ti\ble5stack\hexfiles\cc26x2r1\ble5_project_zero_cc26x2r1lp_app_FlashROM_Release_unsecure.hex
    3. load debug unsecure cc26x2r1lp_bim_offchip.hex

    4. press btn 1 (DIO13) during power cycle to reset chip.

    5. reset from uniflash 
    6. load debug cc26x2r1lp_bim_offchip.hex
    7. load switch zed ota orig
    8. pair to coordinator
    9. the otaserver tool will complete downloading new image 100%

    But, the custom end device not rebooting and not running the new firmware. Even power cycle device not rejoining and execute new firmware.

    Running switch zed ota orig it development board  zed can work perfectly.

    Regards,

    Walter

  • Hi Walter,

    Have you tried using erase_storage_offchip_cc13x2lp.hex to remove all external flash memory?  After step 4, did you confirm that the BLE5 project zero was correctly loaded from the external flash and running on the CC2652R device?  You may consider evaluating with the pre-built images from the v3.40 SDK (non-Zigbee).  After the download is complete is the device not able to run the original software after rebooting?  Does it appear to be in a factory reset state?

    Regards,
    Ryan

  • Hi Ryan,

    Is it support on-chip OTA solution for CC2652R at the present?

  • As I know, TI doesn’t provide Zigbee off-chip OTA until latest CC26x2 Z-Stack.

  • Hi miffy,

    Z-Stack on-chip OTA support is only currently available for the CC2538.

    Regards,
    Ryan 

  • As far as know,the CC2652R off-chip OTA solution have some bugs in spi flash writing stage,I has been attemp porting source code to another spi flash instead of default MX25R8035FZUIL0 flash,and successful.

    Following steps may be helpful,for example to support spi flash Adesto AT25DF041B-MAHN-T,of course,you can porting any spi flash for Atmel or Winbond and so on.

    1. modify BIM array flashInfo in directory examples\nortos\CC26X2R1_LAUNCHXL\common\bim\bim_offchip

    {
            .manfId = 0x1F,         // Adesto AT25DF041B-MAHN-T
            .devId = 0x44,
            .deviceSize = 0x080000  // 512 KByte (4 Mbit)
    }
    

    2. modify CC26X2R1_LAUNCHXL.c corresponding project.

    /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */
    const NVS_Config NVS_config[CC26X2R1_LAUNCHXL_NVSCOUNT] = {
    #ifndef Board_EXCLUDE_NVS_INTERNAL_FLASH
        {
            .fxnTablePtr = &NVSCC26XX_fxnTable,
            .object = &nvsCC26xxObjects[0],
            .hwAttrs = &nvsCC26xxHWAttrs[0],
        },
    #endif
    #ifndef Board_EXCLUDE_NVS_EXTERNAL_FLASH
        {
            .fxnTablePtr = &NVSSPI25X_fxnTableEx,
            .object = &nvsSPI25XObjects[0],
            .hwAttrs = &nvsSPI25XHWAttrs[0],
        },
    #endif
    };

    3. rename NVSSPI25X_fxnTable to NVSSPI25X_fxnTableEx in NVSSPI25X.c and add this file to project simultaneously

    4. modify BIM source code,call follwing method in extFlashOpen function

    /* for global unprotect chip ,Write Status Register */
    #define WRITE_STATUS_BYTE_1       0x01
    
    static bool extFlashGlobalUnlock(void)
    {
      uint8_t wbuf[2];
      /* Wait till previous erase/program operation completes */
      int ret = extFlashWaitReady();
      if (ret)
      {
          return (false);
      }
      
      wbuf[0] = WRITE_STATUS_BYTE_1;
    
      ret = extFlashWriteEnable();
      if (ret)
      {
          return (false);
      }
        
      wbuf[1] = 0x00;
    
      extFlashSelect();
    
      if (bspSpiWrite(wbuf, sizeof(wbuf)))
      {
          /* failure */
          extFlashDeselect();
          return (false);
      }
    
      extFlashDeselect();
    
      return (true);    
    }
    

    5. change sector size macro

    #define SPISECTORSIZE    0x100
    #define SPIREGIONSIZE    (SPISECTORSIZE * 2048)
    #define VERIFYBUFSIZE    64

    6. change binaryPagesLen variable type to size_t

    7. change following segment to calculate correct flash pages(TI original AND algorithm incorrect)

    //If for some reason the OTA Upgrade file is larger than what OAD header indicates, only copy what OAD header indicates
    if(binaryAddrOffset + len < binaryAddrStart + oad_imgHdr.fixedHdr.len)
    {
        //add the image payload into the image section
        if(writeFlashPg(EXT_FLASH_PAGE(binaryAddrOffset), binaryAddrOffset % EFL_PAGE_SIZE, &pData[i], len ) != FLASH_SUCCESS)
        {
            flash_close();
            //Something went wrong...
            return 0xC8;
        }
        binaryAddrOffset += len;
        zclOTA_FileOffset += len - 1; //Minus 1 due to zclOTA_FileOffset being increased at if ( ++zclOTA_FileOffset >= zclOTA_DownloadedImageSize )
    }

    8. modify flash_interface_ext_rtos_NVS.c as follwing(modify uint8_t to size_t in all corresponding source code to suitable correct page size calc,for example: CRC32_calc)

    /*********************************************************************
     * @fn      readFlashPg
     *
     * @brief   Read data from flash.
     *
     * @param   page   - page to read from in flash
     * @param   offset - offset into flash page to begin reading
     * @param   pBuf   - pointer to buffer into which data is read.
     * @param   len    - length of data to read in bytes.
     *
     * @return  None.
     */
    uint8_t readFlashPg(size_t page, uint32_t offset, uint8_t *pBuf, uint16_t len)
    {
      uint8_t flashStat = FLASH_FAILURE;
    
      if(isOpen)
      {
        if(NVS_read(nvsHandle, EXT_FLASH_ADDRESS(page,offset), pBuf, len)
                    == NVS_STATUS_SUCCESS)
        {
            flashStat = FLASH_SUCCESS;
        }
      }
      return (flashStat);
    }
    

    9. erase flash correction

    #define SPIFLASH_SECTOR_ERASE 0x81
    
    /*
     *  ======== doErase ========
     */
    static int_fast16_t doErase(NVS_Handle handle, size_t offset, size_t size)
    {
        NVSSPI25X_HWAttrs const *hwAttrs;
        NVSSPI25X_Object *object;
        uint32_t sectorBase;
        size_t eraseSize;
        int_fast16_t rangeStatus;
        uint8_t wbuf[4];
    
        /* Sanity test the erase args */
        rangeStatus = checkEraseRange(handle, offset, size);
    
        if (rangeStatus != NVS_STATUS_SUCCESS) {
            return (rangeStatus);
        }
    
        hwAttrs = handle->hwAttrs;
        object = handle->object;
    
        /* Set protected global variables */
        spiHandle = object->spiHandle;
        spiCsnGpioIndex = hwAttrs->spiCsnGpioIndex;
    
        /* Start erase at this address */
        sectorBase = (uint32_t)hwAttrs->regionBaseOffset + offset;
    
        while (size) {
            /* Wait till previous erase/program operation completes */
            int ret = extFlashWaitReady(handle);
            if (ret) {
                return (NVS_STATUS_ERROR);
            }
    
            ret = extFlashWriteEnable(handle);
            if (ret) {
                return (NVS_STATUS_ERROR);
            }
            
            /* sector erase only */
            eraseSize = hwAttrs->sectorSize;
            wbuf[0] = SPIFLASH_SECTOR_ERASE;
    
            /* Format command to send over SPI */
            wbuf[1] = (sectorBase >> 16) & 0xff;
            wbuf[2] = (sectorBase >> 8) & 0xff;
            wbuf[3] = sectorBase & 0xff;
    
            /* Send erase command to external flash */
            NVSSPI25X_assertSpiCs(handle, spiCsnGpioIndex);
            if (extFlashSpiWrite(wbuf, sizeof(wbuf))) {
                NVSSPI25X_deassertSpiCs(handle, spiCsnGpioIndex);
                return (NVS_STATUS_ERROR);
            }
            NVSSPI25X_deassertSpiCs(handle, spiCsnGpioIndex);
    
            sectorBase += eraseSize;
            size -= eraseSize;
        }
    
        return (NVS_STATUS_SUCCESS);
    }

    10. you can reference I has been mentioned one years ago hyperlink https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/p/791989/2930302#2930302

  • Hi Ryan,

    I confirm there is no more issue  when loading ZED switch OTA original code in my custom board after I use debug unsecure in Step (6).

    NEW Issue:

    After, porting my custom code to zed switch OTA base code,  commissioning is not completed. The coordinator is deleting ZED. I have attached the sniffer code with this problem.

    The custom code  with non-OTA base code, do not have this problem.  I have attached the sniffer code without this problem.

    Please take a look.

    sniffer_april27_2020_can_add_srcadd_0x3ae9.rarsniffer_april27_2020_cannot_add_srcaddrs_0xc1cc_0xe74f_0x3c69_0x97bd_0x9b2f_0x245a_0xb01d_0xd4ff_0x61eb.rar

    Regards,

    Walter

  • Hi Walter,

    Make sure you erase all device memory before loading the ZED BIM and OTA project again, and please do likewise for the ZC OTA server.  You could debug the zc_ota_server project to determine why the Management Leave Request is sent.

    Regards,
    Ryan

  • Hi Ryan,

    There is no problem pairing when using zc_server_ota orig code in cc2652 launcpad..

    But,,when I use the cc2538 non-ota  code in custom board cc2538 cannot pair already.

    Is there any configuration needed to disable in cc2538 code to accept the pairing?

    Regards,

    Walter

  • Hi Walter,

    Are you saying a CC2538 ZED non-OTA project cannot join the CC2652 ZC OTA server, or that you are trying to join the CC2652 ZED to a CC2538 ZC?  If not either of these scenarios then please further explain the behavior you are witnessing and provide a sniffer log.  You can also reference this  thread: https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/t/893026 

    Regards,
    Ryan

  • Hi Ryan,

    As you know, currently we used the cc2538 as coordinator without OTA and CC2652 without OTA as ZED.

    So, eventually we wanted to activate OTA for both sides. But, we will put OTA for ZED first and let's see if it can join to our cc2538 coordinator without OTA.

    First we used the ZED switch ota from SDK3.10 as base code using external flash. It can join to ZC server OTA from sdk3.10 when using cc2652 launchpad.

    But when we join to current cc2538 coordinator without OTA, it cannot join already. I have attached the logs for you to see.

    8372.sniffer_may12_2020_can_src_51be.rar1263.sniffer_april27_2020_cannot_add_srcaddrs_0xc1cc_0xe74f_0x3c69_0x97bd_0x9b2f_0x245a_0xb01d_0xd4ff_0x61eb.rar

    Questions:

    1. Is it a requirement to use cc2538 OTA also to be able to be able to support such a change?

    2. What are the changes needed to be done in cc2538 non-ota code to be able to support joining from ZED cc2652 with OTA.

    Regards,

    Walter

  • Hi Walter,

    OTA is on the application layer, not network, and an OTA-enabled CC2652 ZED should be able to join the CC2538 ZC.  There is no clear indication on the sniffer log as to why the ZC requests the ZED to leave the network so I recommend you debug the CC2538 project to determine the root cause.  Note that it requests the CC2652R to remove children and not rejoin.

    Regards,
    Ryan

  • Hi Ryan,

    I used minimal code change from original  code of zed switch ota in sdk 3.10 and join coordinator of cc2538  non-ota but have this issue of identify query:.

    But no issue when joining cc2652 non-ota to cc2538 non-ota. Is there any permission issue or security issue in default setting of cc2652 with ota code?

    The complete  sniffer is here.

    device sending identifyquery_src_addr 0xaa9b.rar

    Regards,

    Walter

  • This is not an issue nor is it unexpected.  Since the ZED now has an outgoing cluster (OTA) then it will attempt to identify corresponding clusters to bind with on the network as part of the BDB F&B process.  This will occur for the length of BDBC_MIN_COMMISSIONING_TIME at a rate of FINDING_AND_BINDING_PERIODIC_TIME so long as no Identify Query Response occurs, which will not happen with a non-OTA ZC.

    Regards,
    Ryan

  • Hi Ryan,

    In our original implementation,  after commissioning zed device will send report data. 

    1. Key for non-ota

    2. Key for with ota

    We noticed that we are not receiving report data after commissioning in firmware with ota. The  sniffer log  is attached.jun02_8b3d_non-ota_fw.rarjun02_f9c0_ota_fw.rar

    Regards,

    Walter

  • Hi Walter,

    There appears to be an issue with the OTA ZED firmware as it continuously sends Match Descriptor Requests, you will need to review the implementation of ZCL_OTA_SEND_MATCH_DESCRIPTOR_EVT from ota_client_app.c and zstackmsg_CmdIDs_ZDO_MATCH_DESC_RSP from zcl_samplesw.c to determine the issue. Also please be aware of this E2E thread: https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/p/899435/3325654#3325654 

    Regards,
    Ryan