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.

CC2642R: FOTA Implementation using simple peripheral off-chip application

Part Number: CC2642R
Other Parts Discussed in Thread: SYSCONFIG

Hi ,

We are going to start implementing the FOTA using simple_peripheral_oad_offchip and, bim_offchip. and Already I developed my FW application using simple_peripheral example code which is available in SDK. Now we are planning to integrate the customised simple_peripheral application into the simple_peripheral_oad_offchip code. We did some changes in simple_peripheral application code for our requirement and those changes are listed below,

1) In syscfg -> Configure Genral BLE Setting -> Changed address mode as Public Address in syscfg file.
                                                                            Changed Max Size of PDU as 255
                                                                            Chnaged Max Number of Connections as 1

In syscfg -> Configure Peripheral Role Settings -> Changed Requested Min Conn. Interval (ms) as 10
                                                                                Changed Requested Max Conn. Interval (ms) as 20

In syscfg -> Broadcaster Configuration -> Advertisement set 1 -> Scan Response Data 1 -> Changed Min Connection Interval (ms) as 100
                                                                                                                                                  Changed Max Connection Interval (ms) as 130 (Scan Response Data 2 also changed the same)

2) We are using the Internal oscillator LF RCOSC

3) To change the device name device name, Changing the advertisement and scan response data in following arrays advData1, scanResData1, advData2

4) In simple_gatt_profile.c -> In function GATTServApp_ProcessCharCfg -> added the argument like below (SDK BLE stack changes)

Before Change :

GATTServApp_ProcessCharCfg( simpleProfileChar4Config, &simpleProfileChar4, FALSE,
simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
INVALID_TASK_ID, simpleProfile_ReadAttrCB );

After Change: (Here 3rd argument is added to send the length with data during sending notification from periupheral)

GATTServApp_ProcessCharCfg( simpleProfileChar4ConfigsimpleProfileChar4, length, FALSE,
simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
INVALID_TASK_ID, simpleProfile_ReadAttrCB );    //&simpleProfileChar4 - For 1 byte only


5) Changed the characterestic 4(notification characteristic) buffer length to 240
6) Changed the characterestic 5 permission from GATT_PERMIT_AUTHEN_READ to GATT_PERMIT_READ in gattAttribute_t SimpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] variable.

7) Using GAP_ADV_ENABLE_OPTIONS_USE_MAX option to enable the advertissment instead of GAP_ADV_ENABLE_OPTIONS_USE_DURATION in following API -> GapAdv_enable(gBLE_handle.advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX, 0);

   

While Integrating customised simple_peripheral application with simple_peripheral_oad_offchip application The above mentioned 7 points will affect the simple_peripheral_oad_offchip application or not ? As soon as possible please let us know this details.   If it affects How can we handle it ?

  • Hi,

    After looking through the provided changes, I don't believe will have an impact on your application. I would suggest incorporating these changes and testing to be sure. Let me know, if you observe any unexpected behavior or any errors when adding these changes and I would be more than happy to help.

    Best Regards,

    Jan

  • Hi Team,

    Chipset in our custom Hardware: CC2642R
    EVK : CC2642R1/CC2652R1 Developement kit
    SDK : simplelink_cc13x2_26x2_sdk_5_20_00_52
    SPI Flash in custom Hardware : MX25R1635FZNIH0


    1)Simple peripheral Off-Chip OAD is working in EVK. we will be using only BIM and Application. Persistent app is not used as it is not required .Same we are going to implement in our custom HW. In evk macronix 1Mb flash is been used but in our HW we are using macronix 2Mb flash(MX25R1635FZNIH0).We try to load the default simple peripheral off chip code in our HW. Now we are giving OAD upgrade request from TI Starter link Mobile app and when the new FW starts to download ,we know that the new image will be downloaded in the external flash memory and Already we have mapped the first 1Mb portion of SPI flash for our configuration data in our custom application. So we are planning to use the next one 1Mb portion of SPI flash for OAD image. When we checked the memory partion for the off chip application in your guide lines as below,

    We are planning to map the same for the next 1Mb. From BIM also we are accessing the external flash present in our custom hardware. In Bim off-chip whatever the sequence followed in example code, the same we are planning to use to access the next 1 MB in custom hardware SPI flash. Can you please ensure us by telling whether this will not create any problem.

    While accessing the SPI in our custom hardware from Bim off-chip application, the already existing API's which is used in example Bim off-chip code is not working for our custom HW SPI flash ,then shall we can use either default SPI API or shall we implement our custom SPI APIs

    2) Is Factory image loading in external SPI flash is mandatory ?

  • Hi,

    Can you clarify which APIs are not working in your custom HW? I will look into if there is an issue with your approach and get back to you as soon as possible.

    Best Regards,

    Jan

  • Hi Jan,

    No upto now it is working with sample off-chip code and EVK. For my custom hardware shall we can use the default SPI API or shall we implement our custom SPI APIs ?

  • Hey Mohan,

    I don't see any issue with using the default SPI APIs. Since the external flash part is changed you will have to configure it for your the new flash part (i.e. any changes in pin assignments). This should be done using SysConfig.

  • Hi Ammar,

    We are having one query on implementing OAD off-chip.

    Step 1: I loaded the OAD_offchip and bim_off chip codes

    Step 2: I connected the device with starter link mobile app and I clicked the "TI OAD Service" from mobile app as per the image given below

    Step 3:  Now In Simple peripheral OAD off_chip application It is calling the "OAD_ProcessQueue" function -> Now It is entering into the "OAD_IDLE" State -> Now It is entering into the "OAD_WRITE_IDENTIFY_REQ" event -> Now it is calling the function "oadImgIdentifywrite" -> Now In this function it is entering into the else case of if(!useExternalFlas) -> Now it is calling "oadFindExtFlMetaPage -> Inside this function they are reading data from external flash as mentioned like below

    for(uint8_t curPg = EFL_FACT_IMG_META_PG; curPg < OAD_EFL_MAX_META; ++curPg)    

    {

    // Read in the metadata from ExtFl        

    readFlashPg(curPg, 0, (uint8_t *)&extFlMetaHdr, sizeof(ExtImageInfo_t));

    Here we are reading from external flash using "extFlMetaHdr" structure.

    But Here query is  actually where we are writing into the external flash in our code ? because if somewhere we written this data to external flash then only we can read right ? so please provide the details like from code where we are writing these header details into the external flash. 

    Why we are asking is -> We are using SPI flash in our project so same thing we have to write on my SPI flash and we have to read back while calling these  "oadFindExtFlMetaPage" function.

  • But Here query is  actually where we are writing into the external flash in our code ?

    The image is downloaded with the OAD_WRITE_BLOCK_REQ event, after the state machine switches to the OAD_DOWNLOAD state. The state is switched after the image is validated. The OAD_WRITE_BLOCK_REQ calls oadImgBlockWrite to do the task.

    Why we are asking is -> We are using SPI flash in our project so same thing we have to write on my SPI flash and we have to read back while calling these  "oadFindExtFlMetaPage" function.

    Can you clarify the use case? You should not need to change the OAD files, just the flash interface. The specific logic behind the OAD state machine should not need to be modified. For information, checkout the flash_interface.h file.

  • Hi Ammar,

    We checked on OAD_WRITE_BLOCK_REQ oadImgBlockWrite the data we are expecting is not writing on that place .

    We included the header structure print in "oadFindExtFlMetaPage" function in oad.c file. While using evk external flash then we received the below data which is received from external flash,

    curPg:0 
    extFlMetaHdr.extFlAddr:de000
    extFlMetaHdr.counter: 85 
    extFlMetaHdr.bimVer:3 
    extFlMetaHdr.crc32:986029725 
    extFlMetaHdr.crcStat:254 
    extFlMetaHdr.hdrLen:44 
    extFlMetaHdr.imgCpStat:255 
    extFlMetaHdr.imgEndAddr:132960 
    extFlMetaHdr.imgID:O A D N V M 1 
    extFlMetaHdr.imgNo:1 
    extFlMetaHdr.imgType:5
    extFlMetaHdr.imgVld:4294967295 
    extFlMetaHdr.len:132960 
    extFlMetaHdr.metaVer:1 
    extFlMetaHdr.prgEntry:144 
    extFlMetaHdr.rfu:65535 
    extFlMetaHdr.softVer:536888036 
    extFlMetaHdr.techType:65534

    Our doubt is that this data read from external flash should be written somewhere in the code right?

    1) When we tried to put the above prints for our custom HW, we are getting the data as 0 for all, from this we understood the header data is not already written in external flash. So we are trying to find that piece of code to handle the header write on my custom external flash hardware but not able to find that part of code. Can you please tell us which part of the code handles this write? and during which state it is writing into the external flash?

    2) In our custom HW we are using different external flash part and  because of some issues we faced earlier we are using the spi_open , spi_write in our implementation.
    Now in OAD they are using nvs_write, nvs_open calls. Whether we can use spi_open, spi_write instead of nvs calls. Can you please confirm on this also ?

     

  • Can you please tell us which part of the code handles this write? and during which state it is writing into the external flash?

    You can track the calls to writeFlashPg to see when data is written to the external flash.

    2) In our custom HW we are using different external flash part and  because of some issues we faced earlier we are using the spi_open , spi_write in our implementation.
    Now in OAD they are using nvs_write, nvs_open calls. Whether we can use spi_open, spi_write instead of nvs calls. Can you please confirm on this also ?

    Take a look at flash_interface.h. In theory you should be able to replace the flash_interface_ext_rtos_NVS.c file with flash_interface_ext_rtos (which uses just spi writes). Additional steps may be required. Our launchpad uses the an MX25R8035F SPI Flash, which is passed in to the NVS driver under the "Use Hardware" field (I would take a look at the generated ti_drivers_config.c file for the code).

    Taking a step back, have you tried to just remap the SPI hardware lines to match your custom part? Again, changes at the oad level should not be required and you should be able to use a different external flash part by remapping the SPI hardware and reconfiguring the flash_interface.

  • Hi Ammar

    We tracked all writeFlashPg calls and also OAD_WRITE_BLOCK_REQ this call, But still we are not to find the exact location where it is writing to the external flash. In oad_image_header.h we find a structure with const having the same as the header structure. Is it anything relatable?

    It would be more helpful if you mention with the piece of the code where the image header in the external flash is written

     

  • Hey Mohan,

    I think I may be misunderstanding the question.

    Do you want to know where in the external flash the image is written to?

    writeFlashPg() is the function used to perform the task to write to the external flash. When we write to flash, we pass in the page number (i.e.  "imagePage" the location in the external flash).

    Specifically, the image header should be written to in line ~1167, see below excerpt.

                    // Write a OAD_BLOCK to Flash.
                    status = writeFlashPg(imagePage, 0,
                                            (uint8_t * ) &candidateImageHeader,
                                            sizeof(imgHdr_t));