Using GCC Toolchain

To enable software tracepoints manually and collect trace data on the Kinetis target using the GCC toolchain:

  1. Create a stationary Kinetis project with the GCC option selected in the Language and Build Tools Options page..
  2. Add the sa_handler_gcc.c and sa_asm_handler_gcc.s files to your project as explained in Step 2 of Using Freescale Toolchain.
  3. Expand Project_Settings > Startup_Code in the CodeWarrior Projects view, and open the kinetis_sysinit.c file in the editor area.
  4. Edit the kinetis_sysinit.c file. Include this header file in the source code: #include "sa_handler.h". Include the definition of sa interrupt handler: extern void sa_interrupt_handler();. And add this line in the interrupt vector table: sa_interrupt_handler,.
    Figure 1. Interrupt Vector Table
    Interrupt Vector Table
  5. Save the kinetis_sysinit.c file.
  6. Edit the linker control file of your project.
    1. Expand Project_Settings > Linker_Files in the CodeWarrior Projects view.
    2. Open the <project>_ram.ld file in the editor area.
    3. Add this statement in the memory section: .swtp (RX) : ORIGIN = 0x20000000+32K, LENGTH = 0x400
      Figure 2. Memory Section of Linker File
      Memory Section of Linker File
      Note: Make sure that you do not change the section name because the Software Analysis tool looks for this exact name when software tracepoints are installed.
    4. Add the .swtp section containing the following statements:
      .swtp_handler: {
      
         . = ALIGN (0x4);
        PROVIDE ( _swtp_addr = . );
        KEEP(*(.swtp_table))
        . = . + 0x200;   /* reserve space for swtp_table */
      
        PROVIDE ( _swtp_end = . );
        . = ALIGN (0x4);
      } > .swtp
      Figure 3. .swtp Section of Linker File When GCC is Selected
      .swtp Section of Linker File When GCC is Selected
    5. Save <project>_ram.ld.
    6. Save and build the project.
    7. Follow steps 9 -13 of Using Freescale Toolchain to collect trace.

This is how you set software tracepoints manually on the Kinetis architecture using the GCC toolchain.