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: Flash sector write/erase protection disable.

Part Number: CC1310


Hi,

I'm try to erase the flash sector with the address 0x1F000.

I call the function:

FlashProtectionSet(0x1F000, FLASH_NO_PROTECT);

and after this:

res = FlashProtectionGet(addr);

and this return FLASH_WRITE_PROTECT.

What I do wrong?

  • From flash.h:
    //! Sector protection can only be changed from \ref FLASH_NO_PROTECT to
    //! \ref FLASH_WRITE_PROTECT! After write protecting a sector this sector can
    //! only be set back to unprotected by a device reset.
  • If so why after device reset :
    res = FlashProtectionGet0x1F000);
    returns FLASH_WRITE_PROTECT?
    without previos calling
    FlashProtectionSet(0x1F000, FLASH_NO_PROTECT);?
  • The last page contains the ccfg section. This could be the reason you get a FLASH_WRITE_PROTECT in return. Have you tried the function on a different page?
  • I see I need to discribe my task more in details.  I'm need two non-volotile memory areas in my project that runs on cc1310f128. I've choice two last page in the flash that starts from addresses 0x1e000 and 0x1f000 respectivelly. I've change rfcm_CC1310DK_7XD.icf file this way

    define symbol __ICFEDIT_region_ROM_end__   = 0x0001DFFF;// instead 0x0001FFFF

    adn left unchanged

    place at end of FLASH_region { readonly section .ccfg };
    keep { section .ccfg };


    And I've really watch in IAR Debugger in memory view at addresss 0x1dfa8  the CCFG section looks just as at address 0x1ffa8 in the end of last page.

    I run this code in my project:

        for(addr = 0; addr < 0x1FFFF; addr += 4096){
          res = FlashProtectionGet(addr);
          if(res)
            break;
        }

    And I've watch that this loop stops when the address achives 0x1e000 value.

    The question: Wich way cun I to disable write protection on two last pages in flash?

    Thanks for sugesstion.

     

  • I've disable the write protection in all flash memory pages 0..31 by writing 0xFFFFFFFF in ccfg.h file
  • Hi,

    the last bytes in the last flash page are reserved for the Customer Configuration (CCFG). This area contains also flash protection configuration. You must ensure that the CCFG area is not overwritten by your application. Otherwise you may lock yourself out of the chip by disabling JTAG and enabling erase and write protect on all pages.

    In order to control flash write protection, you may set SET_CCFG_CCFG_PROT_XXX to 0:

    /*
     *  ======== ccfg.c ========
     *  Customer Configuration for CC26xx and CC13xx devices.  This file is used to
     *  configure Boot ROM, start-up code, and SW radio behaviour.
     *
     *  By default, driverlib startup_files/ccfg.c settings are used.  However, if
     *  changes are required there are two means to do so:
     *
     *    1.  Remove this file and copy driverlib's startup_files/ccfg.c file in
     *        its place.  Make all changes to the file.  Changes made are local to
     *        the project and will not affect other projects.
     *
     *    2.  Perform changes to driverlib startup_files/ccfg.c file.  Changes
     *        made to this file will be applied to all projects.  This file must
     *        remain unmodified.
     */
    
    // Set one of the bits to low to enable write protection on these flash pages.
    #define SET_CCFG_CCFG_PROT_127_96                       0xFFFFFFFF
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(startup_files/ccfg.c)
    

    In the IAR linker script file, the ccfg section is linked to the end of flash:

    /* Place the CCA area at the end of flash */
    place at end of FLASH_region { readonly section .ccfg };
    keep { section .ccfg };

    Flash_region is defined as follows:

    /* Define a region for the on-chip flash */
    define region FLASH_region   = mem:[from ROM_start__ to ROM_end__];

    Changing ROM_end__ will also cause the ccfg section being linked to a wrong address. Therefore, you cannot just change ROM_end__, but you have to introduce a new section for ccfg. For instance:

    define symbol CCFG_start__ = 0x0001FFA8;
    define symbol CCFG_end__   = 0x0001FFFF;
    
    /* Define a region for the ccfg */
    define region CCFG_region   = mem:[from CCFG_start__ to CCFG_end__];
    
    /* Place the CCA area at the end of flash */
    place at end of CCFG_region { readonly section .ccfg };
    keep { section .ccfg };

    I hope this makes things clear.

  • Hi Richard,
    First of all, just lot of thanks for your replay.
    I have two eval. boards sets Smartrf06+CC13xxEM-7XD-7793-4L rev.1.0
    I've worked with one of those and changed CCFG.C
    //#####################################
    // Flash sector write protection
    //#####################################
    #ifndef SET_CCFG_CCFG_PROT_31_0
    #define SET_CCFG_CCFG_PROT_31_0 0x3FFFFFFF//0xFFFFFFFF/* Igor 07/11/2017 */
    #endif
    in addition in IAR linker controll file(*.icf) I've change
    define symbol __ICFEDIT_region_ROM_end__ = 0x0001DFFF;
    and run my project.
    I've return CCFG.C file as previos but I still see last two pages protected.
    Now I took the second set and returned the CCFG.C as original
    #define SET_CCFG_CCFG_PROT_31_0 0xFFFFFFFF//0xFFFFFFFF/* Igor 07/11/2017 */
    And I've watched all flash pages unprotected. I'll try your sugestion in attempt to returm first module flash unprotected.
    In global, I'm need two non-volatail memory areas with independed write protection controll for each. I need also a protection from boot loader owerwriting this areas. Do you have any syggestion for me?
    BR,
    Igor.
  • Hi,

    wording:

    • A page is 4 KiB large. This is the minimum erasable unit
    • A sector is a small part of a page. Each sector can be erase and write protected

    I do not recommend to use the last 4 KiB page as a non-volatile data storage, but a page before. Although only few bytes are occupied by the CCFG, you cannot erase the whole page without losing CCFG information. Therefore, 

    • use the last 4 KiB page for the application or a bootloader or other data that does never change
    • use the 2 pages before that for you data
    • Create a separate memory segment for the CCFG section as I have described in my previous post. You need to do this, otherwise, your CCFG data is linked to the wrong address.

  • I've ported my project to Code Composer Studio. Which way I make some thinks in CCS?