Using Freescale Toolchain

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

  1. Create a stationary Kinetis project with Freescale option selected in the Language and Build Tools Options page.
  2. Add the sa_handle.c file to your project using the following steps:
    1. In the CodeWarrior Projects view, select the Sources folder of your project.
    2. Right-click and select the Add Files option form the context menu.
    3. Browse to the <MCU CW Installation Folder>\MCU\morpho_sa\sasdk\support\swtp location.
    4. Select the sa_handle.c file and click Open.
    5. In the File Operation dialog box, select the Copy Files option.
  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". And add this line in the interrupt vector section: (tIsrFunc)sa_interrupt_handler,.
    Figure 1. Interrupt Vector Section
    Interrupt Vector Section
  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.lcf file in the editor area.
    3. Add this statement in the memory section: .swtp (RX) : ORIGIN = AFTER(m_data), LENGTH = 0x400
      Figure 2. Memory Section of Linker File
      Memory Section of Linker File
    4. Add the .swtp section containing the following statements:
      .swtp_handler: {
        _swtp_addr = .;
          * (.swtp_table)
          _swtp_end =_swtp_addr + 0x200;
          . = ALIGN (0x4);
      } > .swtp
      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.
    5. Add this statement at the end of the file: __swtp_table = ADDR(.swtp_handler);. This will store the address of the software tracepoint handler.
      Figure 3. .swtp Section of Linker File When Freescale is Selected
      .swtp Section of Linker File When Freescale is Selected
    6. Save <project>_ram.lcf.
  7. Save and build the project.
  8. Enable Trace and Profile.
    1. Open the Debug Configurations dialog box, and select your project in the tree structure.
    2. Click the Trace and Profile tab, and check the Enable Trace and Profile checkbox.
    3. Keep Enable ETM Tracing checked.
    4. Check Enable Continuous Trace collection and uncheck all other checkboxes.
    5. Click Apply to save the settings, and close the Debug Configurations dialog box.
  9. Set start and stop software tracepoints.
    1. In the editor area, select this statement: int counter = 0;
    2. Right-click the marker bar, select the Toggle Trace Start Point > Software Trace Point option from the context menu. The same option is also used to remove the start tracepoint from the marker bar.

      The Software Tracepoints Support dialog appears. For more information on this dialog box, refer Setting Software Tracepoints Automatically.

    3. Click Cancel.
    4. In the editor area, select this statement: for(;;)
    5. Right-click the marker bar, select the Toggle Trace Stop Point > Software Trace Point option from the context menu.
      Note: It is recommended to set Inlining as Off before you debug the project. To set Inlining as Off , right-click your project and select the Properties option. The Properties page of you project appears. Expand C/C++ Build and select Settings . In the Tool Settings tab, expand ARM Compiler and select Optimization . Select Off from the Inlining drop-down list on the right-side of the tab.
  10. Debug the application.
  11. Collect trace and profile results.
    1. Click Resume.
    2. Click Suspend after a few seconds.
  12. In the Software Analysis view, expand the project name and click the Trace hyperlink.

    The Trace Data viewer appears. The following two figures display the data file generated by the application in which the data has been collected after setting start and stop software tracepoints in the source code.

    Figure 4. Trace Results After Setting Software Tracepoints - Beginning of Trace
    Trace Results After Setting Software Tracepoints - Beginning of Trace
    Figure 5. Trace Results After Setting Software Tracepoints - End of Trace
    Trace Results After Setting Software Tracepoints - End of Trace

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