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?