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.

cc1310: how to save user data in inner flash

Other Parts Discussed in Thread: CC1310

I want to save some system parameter in inner flash so it will works when repower the system. I know that maybe I need to take reference on "ti/drier/flash.h" or "ti/driver/NVS.h", but I have some question about cc1310 flash operation:
1.Is the operating steps as follows:
          if( FlashProtectionGet( Address_You_Want_To_Operate ) == FLASH_NO_PROTECT)
          {
                FlashSectorErase(Address_You_Want_To_Operate );
                FlashProgram( DataBuffer, Address_You_Want_To_Operate, DataLength)
          }
Is that right?
2. Is that any limit about the "Address_You_Want_To_Operate" ? I mean that whether it exist such situation: there exist a special address in flash that contains chip inner data or a piece of system code that shouldn't be modified? How to choose a suitable address to save user data?
Best Regards,
summery.

  • Your code looks correct for the flash driver. The NVS.h is higher level, it allows you to save Key/value pairs in flash. It gives a common API across TI MCU's, but it is not yet supported on CC13xx.

    You should avoid writing to the ccfg as this could result the device not functioning as expected. For placing the data in a certain location in flash this may help:
    e2e.ti.com/.../97988

    Regards,
    TC.
  • Thank you Topcat. But sorry I don't know what's the meaning of "You should avoid writing to the ccfg as this could result the device not functioning as expected. " What is the ccfg? I am trying to save the user data at 0x0, and set its' size as 0x200, and then modified the starting address of the application at 0x500. My new .cmd file will like this:

    /* The starting address of the application. Normally the interrupt vectors */
    /* must be located at the beginning of the application. */
    #define SAVEDATA_BASE 0x0
    #define SAVEDATA_SIZE 0x200
    #define FLASH_BASE 0x5000//0x0
    #define FLASH_SIZE 0x20000
    #define RAM_BASE 0x20000000
    #define RAM_SIZE 0x5000

    /* System memory map */

    MEMORY
    {
    SAVE_DATA : origin = SAVEDATA_BASE;, length = SAVEDATA_SIZE
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE
    }

    /* Section allocation in memory */

    SECTIONS
    {
    .text : > FLASH
    .const : > FLASH
    .constdata : > FLASH
    .rodata : > FLASH
    .cinit : > FLASH
    .pinit : > FLASH
    .init_array : > FLASH
    .emb_text : > FLASH
    .ccfg : > FLASH (HIGH)

    .data : > SRAM
    .bss : > SRAM
    .sysmem : > SRAM
    .stack : > SRAM (HIGH)
    .nonretenvar : > SRAM

    .usersavedata : > SAVE_DATA
    }

    Is there any problem? I am fear that the "ccfg" is located neer the address of 0x0, and doubt that the device won't work after I program it to the device. So I am really looking for your reply........
  • You basically have the answer in your post. If you look at the sections part of the linker file, .ccfg is mapped to the page with highest FLASH address. You will also see this if you look at end of the ccfg.c file.

    When we say say that you should be careful by writing the ccfg we mean the .ccfg section of the flash.
  • Thank you TER. But now I am traped in the function "FlashSectorErase" that it doesn't stop and return and the whole system is stucked. Take reference on the brief introduction of function "FlashSectorErase" in "Flash.h", it says:
    //! \note Please note that code can not execute in flash while any part of the flash
    //! is being programmed or erased. This function must only be executed from ROM
    //! or SRAM.
    Does it means that this function just only be used when the application is programed in ROM or SRAM???? But we just use the Flash Program 2 to load the application to the flash, how can I to realize erase operation in this situation???
  • Please note that you must not link your data section to address 0x00. This is the reset vector on ARM. You have to insert a memory segment after the application sections. You also need to make sure that there is enough space for the .ccfg section which must be located in the last flash page because the internal ROM bootloader expects it to be at a fixed address.

    The functions for Flash access in DriverLib are already included in the internal ROM. So you don't need to worry about that. Please find attached a CCS demo project.

    flashdemo_v1.0.0.zip

  • Hi, Richard W:
    Thank you for your reply. I have solved the problem to save data in flash and the data address is after the application section.
    But a new problem is how to realize the IAP(in application program) function on cc1310 through UART?
    Is there a demo project?
  • No, unfortunately we don't have a demo-project for that.
  • Maybe you can try to refer to e2e.ti.com/.../506551