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.

RTOS/CC2652R: How to enable CC2652R OTA support 512KB spi flash (adesto AT25DF041B with 512KB density)

Part Number: CC2652R

Tool/software: TI-RTOS

I have been modify BIM to implements support 512KB flash,I have do test with LED_DEBUG and green LED blink indicate spi flash work well.

Why read the "header" from newest spi flash chip first perform OTA? the spi flash is empty with new chips.

It looks like first need write full firmware to external spi flash?

                    if(flash_open() != 0)
                    {
                        //Search for a metadata header to fit the Zigbee image
                        ExtImageInfo_t oad_imgHdrFactoryNew;

                        //OAD binary pages required to store the binary
                        uint8   binaryPagesLen   = 0;

                        // Read the factory new metadata page
                        readFlash(EFL_ADDR_META_FACT_IMG, (uint8_t *)&oad_imgHdrFactoryNew, EFL_METADATA_LEN);

                        //is a valid header
                        if(memcmp(&oad_imgHdrFactoryNew.fixedHdr.imgID, oad_externalFLashID, sizeof(oad_externalFLashID)) != 0)
                        {
                            flash_close();
//this section return ABORT if perform OTA procedure //This release does not support not having the Factory New image return ZCL_STATUS_ABORT; }

  • Hi behold,

    Hopefully this previous E2E post can help clarify things: e2e.ti.com/.../

    Regards,
    Ryan
  • Thanks for you,

    It seems like this,if external flash is a new spi flash and has no header,it will not be perform OTA at all.

    If you want perform OTA,you have to first write a firmware to external flash.

    Is it possible defined CREATE_FACT_IMG_INT_TO_EXT_FLSH  in BIM,then burn firmware with BIM and execute once,BIM must copy internal flash to extern flash,and OTA may be work well?

  • This macro is not currently supported in Zigbee projects but you could reference the BLE examples to get started.

    e2e.ti.com/.../733399
    e2e.ti.com/.../780797

    Regards,
    Ryan
  • where is global variable NVSSPI25X_fxnTable defined?

    I can found NVSSPI25X.c,but it seems like not used by project,I think this variable has been defined in some library files.
    How to porting application layer spi flash read/write/erase API to suitable new spi flash chips?
  • It is defined in NVSSPI25X.c as you noticed, pointed to by .fxnTablePtr in CC26X2R1_LAUNCHXL.c, and used by the NVS driver in flash_interface_ext_rtos_NVS.c of the ota application folder. You will need to make your own variation of NVSSPI25x files for your corresponding external flash memory device.

    Regards,
    Ryan
  • How to write correct ExtImageInfo_t to new external spi flash to suitable read metadata header fill variable local oad_imgHdrFactoryNew from zcl_ota.c?

    In other word,how to process newest external spi flash to suitable OTA procedure.
  • Please consult the examples and suggestions provided in the E2E links referenced.

    Regards,
    Ryan
  • Hi Cyan,

        After a long period of debugging, I found some glitches and one bug in the simplelink_cc13x2_26x2_sdk_3_10_00_53,we hope to Improvement in the future.

    1. If number of external flash sector greater than 256,the corresponding type of variable could not work correct ,we have to change uint8_t to size_t ,we modify correspond variable in corresponding source file.

    zcl_ota.c

    static uint8_t oadEraseExtFlashPages(size_t imgStartPage, uint8_t imgPageLen)
    {
        uint8_t status = ZSuccess;
    
        for (uint8_t i = 0; i < imgPageLen; i++)
        {
           uint8_t flashStat = eraseFlashPg(imgStartPage);
            if(flashStat == FLASH_FAILURE)
            {
                // If we fail to pre-erase, then halt the OAD process
                status = ZFailure;
                break;
            }
            imgStartPage++;
        }
        return status;
    }

    flash_interface_ext_rtos_NVS.c


    uint8_t eraseFlashPg(size_t page)
    {
      uint8_t flashStat = FLASH_FAILURE;
      if(isOpen)
      {
          if(NVS_erase(nvsHandle, EXT_FLASH_ADDRESS(page,0), EFL_PAGE_SIZE)
             == NVS_STATUS_SUCCESS)
          {
              flashStat = FLASH_SUCCESS;
          }
      }
    
      return flashStat;
    }

    2. the bug about external flash page offset calculate algorithm may be incorrect in zcl_ota.c

    incorrect source code

    //add the remaining payload image into the image section
    if(writeFlashPg(EXT_FLASH_PAGE(binaryAddrOffset), binaryAddrOffset & (~EXTFLASH_PAGE_MASK), &pData[i], len - i ) != FLASH_SUCCESS)
    {
    	flash_close();
    	//Something went wrong...
    	return ZCL_STATUS_ABORT;
    }
    
    //Update the address offset in external flash
    binaryAddrOffset += len - i;
    
    //Keep track of OTA element bytes received
    zclOTA_ElementPos += len - i;

    correct source code:

    //add the remaining payload image into the image section
    if(writeFlashPg(EXT_FLASH_PAGE(binaryAddrOffset), binaryAddrOffset % EFL_PAGE_SIZE, &pData[i], len - i ) != FLASH_SUCCESS)
    {
    		flash_close();
    		//Something went wrong...
    		return 0xC6;
    }
    
    //Update the address offset in external flash
    binaryAddrOffset += len - i;
    
    //Keep track of OTA element bytes received
    zclOTA_ElementPos += len - i;

  • Hi behold,

    Thank you for providing your findings which will be further evaluated. Please note that changes to flash_interface.h macros may be required to support external flash memory devices which have not been evaluated by TI.  The EXTFLASH_PAGE_MASK is only to ensure that the binaryAddrOffset does not go beyond the allowed EFL_PAGE_SIZE

    Regards,
    Ryan