SPMU373A March   2021  – August 2022 TM4C1230C3PM , TM4C1230D5PM , TM4C1230E6PM , TM4C1230H6PM , TM4C1231C3PM , TM4C1231D5PM , TM4C1231D5PZ , TM4C1231E6PM , TM4C1231E6PZ , TM4C1231H6PGE , TM4C1231H6PM , TM4C1231H6PZ , TM4C1232C3PM , TM4C1232D5PM , TM4C1232E6PM , TM4C1232H6PM , TM4C1233C3PM , TM4C1233D5PM , TM4C1233D5PZ , TM4C1233E6PM , TM4C1233E6PZ , TM4C1233H6PGE , TM4C1233H6PM , TM4C1233H6PZ , TM4C1236D5PM , TM4C1236E6PM , TM4C1236H6PM , TM4C1237D5PM , TM4C1237D5PZ , TM4C1237E6PM , TM4C1237E6PZ , TM4C1237H6PGE , TM4C1237H6PM , TM4C1237H6PZ , TM4C123AE6PM , TM4C123AH6PM , TM4C123BE6PM , TM4C123BE6PZ , TM4C123BH6PGE , TM4C123BH6PM , TM4C123BH6PZ , TM4C123FE6PM , TM4C123FH6PM , TM4C123GE6PM , TM4C123GE6PZ , TM4C123GH6PGE , TM4C123GH6PM , TM4C123GH6PZ , TM4C123GH6ZXR , TM4C1290NCPDT , TM4C1290NCZAD , TM4C1292NCPDT , TM4C1292NCZAD , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1297NCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C129CNCPDT , TM4C129CNCZAD , TM4C129DNCPDT , TM4C129DNCZAD , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129LNCZAD , TM4C129XKCZAD , TM4C129XNCZAD

 

  1.   Read This First
    1.     About This Manual
    2.     Glossary
    3.     Related Documentation From Texas Instruments
    4.     Support Resources
    5.     Trademarks
  2. 1Introduction to TivaWare SDK
    1. 1.1 TivaWare SDK Folder Breakdown
  3. 2TivaWare Example Projects
    1. 2.1 TivaWare Development Board Examples
    2. 2.2 TivaWare Peripheral Examples
    3. 2.3 How to Import an Example Project into CCS
  4. 3Linking Files and Libraries into a TivaWare Project in Code Composer Studio
    1. 3.1 Linking Files in CCS
    2. 3.2 Linking Libraries in CCS
  5. 4How to Debug a TivaWare Library
    1. 4.1 How to Direct Code Composer Studio to a Source File
    2. 4.2 How to Rebuild TivaWare Libraries
  6. 5How to Add TivaWare to an Existing CCS Project
    1. 5.1 Path Variables
    2. 5.2 Include Paths
    3. 5.3 Predefined Variables
    4. 5.4 Library Linking
  7. 6TivaWare Boot Loader
    1. 6.1 Modifying a TivaWare Project for Boot Loading in Code Composer Studio
    2. 6.2 How to Boot Load with LM Flash Programmer
  8. 7Software Best Practices
    1. 7.1 Stack / Heap Settings and Stack Overflow
    2. 7.2 Interrupt Service Routines
      1. 7.2.1 Best Practices
      2. 7.2.2 TivaWare Vector Tables and IntDefaultHandler
    3. 7.3 TivaWare Hardware Header Files
    4. 7.4 ROM and MAP TivaWare Prefixes
  9. 8TM4C Resources
  10. 9Revision History

Modifying a TivaWare Project for Boot Loading in Code Composer Studio

For this section, the TivaWare boot_serial example for the EK-TM4C123GXL LaunchPad Development Kit will be used as the boot loader firmware, and the hello example will be used for the application code.

The boot_serial example contains only a bl_config.h file as the flash boot loader itself is part of the TivaWare boot_loader folder. Any modifications to the boot loader are done through the bl_config file where the serial interface can be selected and modified, including selecting which modules and pins are used (unlike the ROM boot loader that is locked to specific pins). Another important feature is the ability to set the starting address. This is defined as APP_START_ADDRESS, and that determines where the application that is loaded by the boot loader starts in flash memory. This is required because the boot loader needs to be placed in flash memory starting at address 0x0000.0000. The size of APP_START_ADDRESS is defined based on the size of the boot loader code. It is used at the end of the boot loading process to jump to the start of the application code and begin executing it.

#define APP_START_ADDRESS       0x2800

The APP_START_ADDRESS differs between the TM4C123x devices and TM4C129x devices due differences in the flash architecture between the families. In general there are two key considerations for where to place the starting address. The first is that the vector table must be aligned to a 1024 byte page boundary. The second is that the boot loader should not be erased while programming the application code since flash memory is erased in sectors.

For TM4C123x devices, the flash sectors are 1kB in size, but for TM4C129x devices, they are 16kB in size. In order to avoid having the boot loader and applications in the same sector, the simplest solution is to start the application on the first sector boundary beyond the end of the boot loader. This will also meet the requirement for having the vector table aligned with a 1024 byte page boundary as well. For TM4C123x devices using the provided TivaWare flash boot loader, the starting address is set to be 0x2800, which is the first sector without any boot loader code present. For TM4C129x devices, the starting address is set to be 0x4000 because of the 16kB sector size.

After the starting address is defined, the next step is to compile the application code that will be boot loaded so the start address is reflected in the generated binary file. This is done by modifying the linker command file for the CCS project. After opening or importing the hello project into CCS, locate the hello_ccs.cmd file and double-click to open the file in the CCS linker command file editor. There are two important sections of code in this file, the address bases set by the #define statements, and the system memory map.

#define APP_BASE 0x00000000
#define RAM_BASE 0x20000000

/* System memory map */

MEMORY
{
     /* Application stored in and executes from internal flash */
     FLASH (RX) : origin = APP_BASE, length = 0x00040000
     SRAM (RWX) : origin = RAM_BASE, length = 0x00008000
}

To prepare hello for use with the boot loader, first update the APP_BASE memory address to reflect the APP_START_ADDRESS from bl_config. Because the boot loader takes up the memory space from 0x0000.0000 to APP_BASE, the length field of the system memory map must be updated to reflect the available flash space for the application. The length field should be the total device flash memory minus the space needed for the boot loader. In this case, 0x0004.0000 – 0x0000.2800 would be 0x0003.D800. A simple and error minimizing way to reflect this is to simply subtract APP_BASE from the defined length value.

#define APP_BASE 0x00002800
#define RAM_BASE 0x20000000

/* System memory map */

MEMORY
{
     /* Application stored in and executes from internal flash */
     FLASH (RX) : origin = APP_BASE, length = 0x00040000 - APP_BASE
     SRAM (RWX) : origin = RAM_BASE, length = 0x00008000
}

After making these changes, save the updated .cmd file and then re-compile the project to generate the updated .out and .bin files in the Debug folder. Now the hello project is ready to be loaded in via the boot_serial­ boot loader.

The last step using Code Composer Studio is to now program the target device with the boot_serial project. Because the boot loader does not have a main function the IDE will not have an option to ‘run’ the firmware after programming and means that the boot loader was successful programmed.