FILE: lfu_singlebank.c
This example demonstrates how to perform a live firmware update with use of the Live Device Firmware Update (Live DFU or LDFU) command; it is to be used with the Serial Flash Programmer as well as the SCI Flash Kernel.
In the example, an SCI autobaud lock is performed and the byte used for autobaud 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. LED1 is toggled for the BANK0_FLASH build configuration and LED2 is toggled for the BANK1_FLASH and configuration. 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 located inside of the SCI Flash Kernel for the corresponding bank.
The project contains the following build configuration:
- BANK0_FLASH: Links the program sections to the appropriate locations in Bank 0 of flash and uses the Flash API library that links the Flash API functions to flash. The 'codestart' section is linked to the alternative flash entry point for Bank 0 (0x8EFF0) and the rest of the sections are linked to 0x082008 or above. Bank 0 configurations of the flash kernel reserve sector 0, sector 1, and the first 128 bits of sector 2 of Bank 0; therefore, sections must be linked to 0x082008 or higher. After building the configuration, the C2000 Hex Utility will output the program in the appropriate SCI boot hex format for the flash kernel and serial flash programmer in a file named 'flashapi_ex2_liveFirmwareUpdateBANK0FLASH.txt'.
To use the example, make sure line 867 is commented in the Serial Flash Programmer project in order to be able to load the kernel through CCS. Configure the device to boot to flash at 0x80000 and follow the steps below:
- Place the output files of the C2000 Hex Utility tool for the build configurations to be used (one for each bank) in the 'hex' directory of the Serial Flash Programmer project.
- Load LDFU build configurations of the SCI Flash Kernel (one for each bank) to flash through CCS. If a debug session is launched in order to load a build configuration of the flash kernel to flash, go to Tools -> On-Chip Flash -> Erase Settings in order to ensure that 'Necessary Sectors Only (for Program Load)' is selected. This allows only the sectors where the flash kernel is linked to be erased when it is loaded. If 'Entire Flash' was selected, ensure that both build configurations are in flash.
- Run the bank 0 build configuration of the flash kernel in CCS, ensuring that the bank 1 build configuration is not erased.
- In the Serial Flash Programmer project, make sure the command arguments of the debug properties (Debug -> serial_flash_programmer Properties -> Debugging -> Command Arguments) contains the path to the hex formatted file of the bank 1 configuration of this example. Refer to the 'README.txt' file in the Serial Flash Programmer project to understand the command arguments of the debug properties. Verify that the correct COM port is selected.
- Run the Serial Flash Programmer project. A menu should appear inside a terminal.
- In the terminal, enter '8' to send the Live DFU command. The bank 1 build configuration of the example will start loading to the device and each byte that is sent will show in the terminal. Keep the terminal open until the file is done being loaded to the device, indicated by an "Application load successful!" message. Once the program is done loading, the bank 1 build configuration of the example will be running on the device.
- Exit the terminal and edit the command line arguments of the Serial Flash Programmer's debug properties so that it contains the path to the hex formatted file for the bank 0 build configuration of this example.
- Run the Serial Flash Programmer again in order to perform an autobaud lock and view the menu in the terminal. LED2 should be blinking to indicate that code is running on bank 1.
- Enter '8' in the terminal to send the Live DFU command to the device. The bank 0 build configuration of the example will start loading to the device. Again, each byte that is sent will be shown in the terminal; the end of the loading is marked by an "Application load successful!" message. When the program is done loading, the bank 0 build configuration of this example should be running on the device.
- Exit the terminal and edit the command arguments of Serial Flash Programmer's debug properties so that it includes the path to the hex formatted file of the bank 1 configuration of this example.
Run the Serial Flash Programmer to perform an autobaud lock and view the menu. LED1 should be blinking to indicate that code is running on bank 0.
- Restart from step 6.
If BANK1_FLASH and BANK0_FLASH build configurations are used for the example, then the corresponding build configurations of the flash kernel must be loaded to flash: BANK1_LDFU and BANK0_LDFU respectively.
External Connections
- Connect GPIO28 (SCI Rx) and GPIO29 (SCI Tx) to a COM port of the computer running the Serial Flash Programmer project
Watch Variables