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.

CC2541 cant write flash lock bits

Other Parts Discussed in Thread: CC2541

I'm trying to write to the lock bits which occupy the upper 16 bytes of the upper flash page (page 127 or the 128th page).  The users guide says this is the only section of page 127 we can write to without entering debug mode, but I'm finding that I can not write the lock bits outside of  debug mode. Has anyone had any lock with this or found an odd quirk in the system. The code is straightforward:

uint16 Waddr = 0xfffC;    //word address of final 16 byte boundary

uint8 lockingBuff[16];       //initialize to some bitmapped value

HalFlashWrite(Waddr, lockingBuff, 4);

This code should write the lock bits to the value. 

  • Perhaps you can quote the text from the user's guide that implies that programmatically writing the lock bits should be possible? In 2.2.3 Physical Memory, it is clear that it should not be possible:

    There is one lock bit for each page, except the lock-bit page which is implicitly locked when not in debug mode.
    When the lock bit for a page is 0 <or when the page is implicitly locked>, it is impossible to erase or write that page.

  • Yes I was referring to section 3.4.1 The exact wording is "The [lock-bit] structure  starts at address 0x7FF0 [...] when the upper flash bank is mapped in, and occupies 16 bytes. The rest of the lock-bit page can be used to store code/constants, but cannot be changed without entering debug mode."

    I gathered that this implies  the "cannot be changed" refers to everything but the 16 bytes. Maybe the "used to store code/constants" is the factor that refers to everything but the 16 bytes? The  wording isn't as finite as section 2.2.3

    My root problem is a few devices back not working. IAR and the TI flash programmer state that they are locked. If the chip can't lock itself then what can? I made this post due to my inability to recreate the issue. 

  • Perhaps the environmental stress that caused the device to fail in the field has also caused the condition that the CC debugger can no longer talk to the CC2541? Perhaps ohm out the debug clock and data lines and vcc and ground and/or scrub the pcb with alcohol and bake it and try again?

  • It doesn't appear to be a physical issue. I was able to erase the flash and reprogram. Now they work fine.

  • Peter Borenstein said:

    Yes I was referring to section 3.4.1 The exact wording is "The [lock-bit] structure  starts at address 0x7FF0 [...] when the upper flash bank is mapped in, and occupies 16 bytes. The rest of the lock-bit page can be used to store code/constants, but cannot be changed without entering debug mode."

    I gathered that this implies  the "cannot be changed" refers to everything but the 16 bytes. Maybe the "used to store code/constants" is the factor that refers to everything but the 16 bytes? The  wording isn't as finite as section 2.2.3

    I can see that this can easily be misunderstood. Actually, the entire page cannot be changed without entering debug mode. The rationale behind the sentence is probably to emphasize that this also applies to the part of the page not used for lock bits. In fact, the statement from Section 2.2.3 ("There is one lock bit for each page, except the lock-bit page which is implicitly locked when not in debug mode.") applies to the entire flash page, both the flash lock bits and the part available for data.

  • Thank you for your clarification. I think my problem was most likely selecting the "Block debug commands" on the TI SmartRF Flash programmer. The hitbox for selecting that option is the entire title so I could have reasonably clicked it accidentally 

    Edit: This is purely a hunch. Its the only thing that makes sense