SPRUIU8A March 2020 – August 2021 TMS320F280040-Q1 , TMS320F280040C-Q1 , TMS320F280041 , TMS320F280041-Q1 , TMS320F280041C , TMS320F280041C-Q1 , TMS320F280045 , TMS320F280048-Q1 , TMS320F280048C-Q1 , TMS320F280049 , TMS320F280049-Q1 , TMS320F280049C , TMS320F280049C-Q1
C2000, Code Composer Studio, are trademarks of Texas Instruments.
All trademarks are the property of their respective owners.
In applications like server power supply, metering, and so forth. the system is desired to be run continuously to reduce downtime. But typically during firmware upgrades due to bug fixes, new features, and/or performance improvements, the system is removed from service causing downtime for associated entities as well. This can be handled with redundant modules but with increase in total system cost. An alternate approach, called Live Firmware Update (LFU), allows firmware to be updated while the system is still operating. Switching to new firmware can be done either with or without resetting the device, with the latter being more complex.
LFU is feasible when the device has enough resources of various kinds – CPU bandwidth, Memory, and Peripheral availability:
LFU is easier to implement in devices with multiple Flash banks. In this document and the reference example, it is assumed that the device has 2 Flash banks. The device considered is TMS320F28004x, which has dual flash banks. Their address space is 64K x 16 each, with addresses ranging from 0x80000-0x8FFFF, and 0x90000-0x9FFFF.
The Flash memory has been partitioned as shown in Figure 3-1.
Assuming each Flash bank has 16 sectors, two sectors have been allocated to Static code (code that will not change between applications). This is described in Section 4.
A few locations in sector 2 have been reserved to store the below entries:
The rest of sector 2 and sectors 3-15 can be used to store the application image. This allows the static code in sectors 0 and 1 to be programmed once, and remain unchanged during LFU.
Static code that is used to support LFU consists of:
The static code is configured as a single example - flashapi_ex2_sci_kernel project (included in C2000Ware at <C2000Ware>\driverlib\f28004x\examples\flash). This example supports multiple build configurations, of which those relevant to LFU are listed below:
For more details, see the flashapi_ex2_sciKernel.c in the flashapi_ex2_sci_kernel project (included in C2000Ware at <C2000Ware>\driverlib\f28004x\examples\flash).
This example (flashapi_ex3_live_firmware_update project) is designed to demonstrate LFU with the LED blinking periodically. This is achieved using the Live Device Firmware Update (Live DFU or LDFU) command, which is part of SCI kernel. This is to be used with the Serial Flash Programmer (PC tool).
In this example, an SCI auto baud lock is performed and the byte used for auto baud lock is echoed back. Two interrupts are initialized and enabled: SCI Rx FIFO interrupt and CPU Timer 0 interrupt. The CPU Timer 0 interrupt occurs every 1 second; the interrupt service routine (ISR) for CPU Timer 0 toggles an LED based on the build configuration that is running.
The application images generated by building the above build configurations are the ones that will be used to illustrate LFU in this document. Note that other than the changes described above between the two build configurations, there are no other differences between the two application images. Hence, this is a relatively simple example for LFU illustration.
The SCI Rx FIFO interrupt is set for a FIFO interrupt level of 10 bytes. The number of bytes in a packet from the Serial Flash Programmer (when using the LDFU command) is 10. When a command is sent to the device from the Serial Flash Programmer, the SCI Rx FIFO ISR receives a command from the 10 byte packet in the FIFO. If the command matches the Live Device Firmware Update (Live DFU) command, then the code branches to the Live DFU function (liveDFU()) located inside of the SCI Flash Kernel (flashapi_ex2_ldfu.c) for the corresponding bank. So if the application on Bank0 is executing, control will pass to liveDFU() on Bank0, located at 0x81000. If the application on Bank1 is executing, control will pass to liveDFU() on Bank1, located at 0x91000. Within this function, execution passes to the ldfuLoad() function in order to erase the appropriate bank, load a hex formatted program (in the appropriate SCI boot format) into flash, and verify the program. Then the watchdog is configured for a reset. At the end, the watchdog is enabled in order for a reset to occur. When the device resets, it boots and loads the new Firmware.
Figure 5-1 depicts the flow of the code at a high level after the code enters main() of the application. For more details, see the flashapi_ex3_live_firmware_update.c located in the flashapi_live_firmware_update project (included in C2000Ware at <C2000Ware>\driverlib\f28004x\examples\flash).