SPRUJH3 April   2025 TMS320F2800132 , TMS320F2800133 , TMS320F2800135 , TMS320F2800137 , TMS320F2800152-Q1 , TMS320F2800153-Q1 , TMS320F2800154-Q1 , TMS320F2800155 , TMS320F2800155-Q1 , TMS320F2800156-Q1 , TMS320F2800157 , TMS320F2800157-Q1 , TMS320F280021 , TMS320F280023 , TMS320F280023C , TMS320F280025 , TMS320F280025C , TMS320F280034 , TMS320F280036-Q1 , TMS320F280036C-Q1 , TMS320F280037 , TMS320F280037C , TMS320F280038-Q1 , TMS320F280038C-Q1 , TMS320F280039 , TMS320F280039C , TMS320F280040-Q1 , TMS320F280040C-Q1 , TMS320F280041 , TMS320F280041C , TMS320F280045 , TMS320F280048-Q1 , TMS320F280048C-Q1 , TMS320F280049 , TMS320F280049C , TMS320F28076 , TMS320F28374D , TMS320F28374S , TMS320F28375D , TMS320F28375S , TMS320F28376D , TMS320F28376S , TMS320F28377D , TMS320F28377S , TMS320F28378D , TMS320F28378S , TMS320F28379D , TMS320F28379S , TMS320F28384D , TMS320F28384S , TMS320F28386D , TMS320F28386S , TMS320F28388D , TMS320F28388S , TMS320F28P550SG , TMS320F28P550SJ , TMS320F28P559SG-Q1 , TMS320F28P559SJ-Q1 , TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DH-Q1 , TMS320F28P659DK-Q1 , TMS320F28P659SH-Q1

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2Configuring the Boot Mode
    1. 2.1 Standalone Boot
      1. 2.1.1 Boot Mode Select Pins (BMSP)
      2. 2.1.2 Boot Definition Table (BOOTDEF)
      3. 2.1.3 Boot ROM OTP Configuration Registers
      4. 2.1.4 CPU2 Boot Flow
    2. 2.2 Emulation Boot
  6. 3Programming the Flash
    1. 3.1 Flash API
    2. 3.2 Flash Kernels
  7. 4Bootloading Code to Flash
    1. 4.1 C2000 Hex Utility
    2. 4.2 Common Boot Modes
      1. 4.2.1 Boot to Flash
      2. 4.2.2 SCI Boot
      3. 4.2.3 CAN Boot
      4. 4.2.4 CAN-FD Boot
      5. 4.2.5 USB Boot
  8. 5FAQ
    1. 5.1 Selecting the BMSP GPIOs with a Software-based Implementation
    2. 5.2 Running a Flash Kernel from the Flash Instead of the RAM
    3. 5.3 No Symbols Defined When Debugging Boot ROM
    4. 5.4 Writing Values in the OTP Using the On-Chip Flash Tool
    5. 5.5 Writing Values in the OTP Using the Flash API Plugin
  9. 6Summary
  10. 7References

Running a Flash Kernel from the Flash Instead of the RAM

Question: How to modify the flash kernels to run from the flash instead of the RAM?

Answer: On multibank devices, users can implement a custom bootloader in the flash to directly load application code onto the other flash banks. On single-bank devices, a custom bootloader in the flash can perform firmware upgrades on individual sectors within the same flash bank, but the Flash API must execute from RAM.

Note: Flash API functions and the application functions that call Flash API must not be executed from the same bank. Executing the Flash API on the same bank can introduce race conditions when programing and erasing data. The Flash API needs to be executed from the RAM or another flash bank (if another bank exists for the same core). [6]

Using a custom bootloader provides more flexibility to the user in the boot flow, allowing for different peripheral GPIOs to be used as opposed to only having access to a limited, predefined set of GPIO assignments in the boot ROM. Having a custom bootloader also effectively reduces the number of steps in the bootloading process as there's no need to load an intermediate flash kernel into the RAM to program the flash.

Moreover, having a flash-based bootloader can also act as a fail-safe if the firmware upgrade process fails. Booting to code that does not get upgraded (that is, the flash-based bootloader) minimizes the chance that the device tries to boot to corrupted code, since the bootloader can use multiple methods to verify the existing firmware (key value, checksum, and so forth.). The same can be achieved in a RAM-based flash kernel too, but it's not practical to load this in every time the device boots.

One way to implement a custom bootloader is to modify the existing flash kernel projects in C2000Ware to execute from the flash instead of the RAM. This requires modifications to the kernel's linker command file, which specifies where the application is loaded in memory, and adding a pre-defined symbol to be used by the compiler.

Note:

The following steps modify the F28P55x SCI flash kernel to execute from the flash, but the same flow can be applied to any C2000 device with an existing flash kernel project in C2000Ware.

  1. Right-click the project and select Add Files/Folders.

     Adding a File to a
                            Project into CCS
    Figure 5-1 Adding a File to a Project into CCS
  2. Navigate to the following path in C2000Ware and select the generic flash linker command file for the intended device.
    1. C2000Ware_X_XX_XX_XX\device_support\DEVICE_NAME\common\cmd
  3. Right-click the RAM linker command file and select Exclude from Build, so the flash linker command file is used in the compiler build.

     Excluding the RAM
                            Linker Command File from the Compiler Build
    Figure 5-2 Excluding the RAM Linker Command File from the Compiler Build
    Note:

    With the generic flash linker command file, the kernel is loaded into flash bank 0 (entry point at 0x80000). If users want to place the kernel in a different flash bank, then modify the SECTIONS allocated to flash bank 0 in the linker command file to the intended flash bank.

    Furthermore, in MEMORY portion of the linker command file, BEGIN must also be updated to the intended flash entry point location (codestart) as needed, including the flash bank origin and length specifications to account for the codestart allocation at the entry point.

    Refer to [33] for more details on linker command file directives.

  4. Create a new build configuration by right-clicking the project and navigating to Build Configurations > Manage...

     Creating a New Build
                            Configuration for the Project
    Figure 5-3 Creating a New Build Configuration for the Project
    1. Name the build configuration CPU1_FLASH and opt to copy settings from the CPU1_RAM configuration.

       Creating the
                                    CPU1_FLASH Build Configuration
      Figure 5-4 Creating the CPU1_FLASH Build Configuration
  5. Set the active build configuration to CPU1_FLASH.
  6. In device.c, the time critical code and flash setup code (called Ramfuncs) is copied to the RAM. Moreover, the flash initialization function to setup flash waitstates must reside in RAM. Since the kernel is executing in the flash now, the symbol _FLASH must be defined for these conditions to occur.
    1. Right-click and navigate to the Properties > Tools > C2000 Compiler > Predefined Symbols. Define the symbol _FLASH.

       Add the
                                    Predefined Symbol _FLASH to Initialize Flash Functions
      Figure 5-5 Add the Predefined Symbol _FLASH to Initialize Flash Functions
  7. Re-build the flash kernel project with the CPU1_FLASH build configuration. Now, the flash kernel is built to execute from the flash and can be programmed onto the device flash.
    Note: Since the kernel is already loaded onto the device, then the serial_flash_programmer_appIn.exe in C2000Ware must be used. This executable can be called with the same command line arguments as the normal serial flash programmer, but the kernel argument (-k) is not required.