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.

osal_start_system() Causing Flash Corruption on CC2541F128

Other Parts Discussed in Thread: CC2541

I designed some hardware that uses the 128KB version of the CC2541. The firmware I am programming is a modified version of the SensorTag firmware. My problem does not occur on the SensorTag reference hardware, which uses the 256KB chip. 

What I find is that if the firmware enters osal_start_system() the flash becomes corrupted. So if I program the chip, and then power cycle, it will boot up, enter osal_start_system() and start running my code. However, if I power cycle again, it will no longer boot up. If I comment out osal_start_system(), this problem does not occur, and the device will boot up no matter how many power cycles occur.

Therefore, it appears that something that is executing from within osal_start_system() is causing flash damage. I also know that I had to comment out osal_snv_init() to get my modified SensorTag firmware to run on the 128KB chip (otherwise, it returned FAILED and crashed). Does osal_start_system() run some type of code that compresses/organizes/modifies the NV memory, and may be designed to work only on the 256KB chip?

My feeling is that there is something hard-coded in the SensorTag firmware that will actually corrupt the firmware on the 128KB chip if the system enters osal_start_system(). Does anybody have some suggestions, thoughts or experience with this?

  • Hello Jonathan,

    Have you changed the linker file? The linker file (*.xcl) used for your project (ti_51ew_cc2540b.xcl) has segment definitions like BLENV_ADDRESS_SPACE_START, BANK addresses, etc which is wrong for the 128k chip. Change this to ti_51ew_cc2540f128b.xcl.

    Also make sure the following is done:

    1. IAR project options-> General Options-> Code Bank, change "Number of banks" to 0x03.

    2. Edit hal_board_cfg.h file, change HAL_NV_PAGE_END from 126 to 62.

    Maybe there is more to take into considerations as well that I have not considered. Note that the OAD feature will not work with flash sizes smaller than 256 KB so you might want to disable any OAD feature in the code as well.

  • Thanks a lot! That solved the problem. That would have been a hard one to figure out otherwise because the behavior was so strange.

    Also, thanks for the note about the F128's inability to do the OAD. I'll eventually need that.