I have a TI-RTOS based project that is capable of in-system firmware upgrade. Firmware upgrade operates as follows:
- Erase the upper half of FRAM
- Download the new firmware into the upper half of FRAM
- Authenticate the new firmware
- Run the firmware upgrade function from RAM
- Note in information memory that firmware upgrade is occurring
- Erase the bottom half of FRAM
- Copy the upper half of FRAM into the bottom half of FRAM
- Restart with the following code:
PMMCTL0_H = PMMPW_H; PMMCTL0_L |= SVSHE_1 | PMMSWPOR | PMMREGOFF; __bis_SR_register(LPM4_bits | GIE);
This has worked well for me in the past, but I had problems with my latest firmware change. I've been storing data in INFOA to track progress during and after firmware upgrade to confirm what is happening. I've determined that if the .text:_isr section moves (still in FRAM and near its old location), then the MSP430 locks up and does not even reach main() after the POR triggered at the end of firmware upgrade. When this happens, I need to enact a hard reset, after which the MSP430 is running the new firmware. However, if the .text:_isr section does not move, then the POR works as expected and the MSP430 is immediately running the new firmware.
I am storing the reset vector (contents of 0xFFFE) just before copying over the new firmware and just after. I have confirmed that 0xFFFE correctly points to the new reset vector location just before the POR at the end of firmware upgrade. From my understanding, the MSP430 should then read the new reset vector address after the POR and start running the new code. Is there anything else that I need to do if the .text:_isr section moves prior to forcing a POR so the MSP430 restarts properly?