AM335x Starterware to RTOS Porting Procedures

Introduction The Processor SDK RTOS package for AM335x contains legacy Starterware bare-metal examples (applicable to only AM335x and AM437x devices) that can be ported to use TI-RTOS. This document discusses the components of a TI-RTOS based example and considerations in converting a Starterware example to use TI-RTOS.

Below is a description of this porting process and things to consider. The DCAN example located in the AM335x PDK Starterware (\packages\ti\starterware\examples\dcan) will be used as an example. The ported project is located at \packages\MyExampleProjects\DCAN_LoopbackExample_evmAM335x_armTestProject Please note that prior to beginning development, consult the Processor SDK RTOS MyExampleProjects directory located at \packages\MyExampleProjects to ensure that a TI-RTOS example for the peripheral of interest does not exists that can be used for your application development.

Also, peruse the TI-RTOS application development training guide located at https://training.ti.com/application-development-using-processor-sdk-rtos. This training guide provides invaluable information in starting your TI-RTOS based application development for Sitara products.

Configuring Interrupts A significant difference between the StarterWare examples compared to RTOS enabled examples, is the way interrupts are configured and dispatched. StarterWare baremetal examples configure the interrupts using INTC and GIC modules. This needs to be updated to use the RTOS APIs to add support for TI RTOS. The TI OSAL library should be used to configure the interrupts. All the functions doing the interrupt configuration shall be updated to use OSAL library APIs. For applications that utilize EDMA, edma_utils.c will need to be modified as needed.

In the TI-RTOS based DCAN example, the source file dcan_app.c contains an interrupt configuration routine in DcanAppIntrConfig. This function has configuration for a project based on TI-RTOS and another based on Starterware. Please see below for the relevant sections.

Cache and MMU settings The cache and MMU settings can be re-used from If you are building a TI-RTOS (SYS/BIOS kernel) example, then the Cache and MMU are automatically enabled by default. As stated in the MMU module cdoc By default, the MMU translation table is initialized with cache-enabled entries for every memory segment defined in the platform. Cache-disabled entries are also added for the peripheral addresses used by SYS/BIOS (i.e. Timers, Interrupt controller).

You can always modify (add/remove) MMU table entries at build or run time. Typically, you would need to add entries for the memory mapped registers of peripherals that are being used in the application. For example, if the app uses UART, the memory mapped regs of UART need to be mapped as non-cacheable device memory in the MMU table. The MMU cdoc shows examples of how to do this. Please keep in mind that the MMU addresses will vary according to the peripheral being used. Consult the technical reference manual for details on the addresses to use.

For a working example of cache and MMU configuration for an AM335x TI-RTOS .cfg file, please see the example at \ \packages\MyExampleProjects\UART_BasicExample_evmAM335x_armExampleProject

Using Tasks RTOS based examples can use tasks to exercise a peripheral. This is not a mandatory requirement but can be especially useful if multithread execution is needed. Create the tasks using TI RTOS API Task_create and start the RTOS execution by calling BIOS_start function. Refer to main function in loopback_app_main.c (\packages\ti\starterware\examples\dcan) for creating the tasks and invoking the BIOS execution. Refer to main function in haptics_motor_app_main.c (starterware/examples/epwm/haptics_motor) for creating the tasks and invoking the BIOS execution.

Creating RTOS config files All TI RTOS configurations are enabled using a config file (.cfg). TI RTOS config files am335x_app_dcan_evmam335x.cfg added for the DCAN example can be used as reference.

Creating CCS project setup files CCS project files can be created manually from CCS IDE or use the project configuration text files and pdkProjectCreate script to create the project. Project configuration text files (\packages\ti\starterware\examples\dcan\loopback\rtos) added for the DCAN example can be used for reference. The CCS project property symbols parameter need to be updated as needed for the relevant peripheral. In the case of DCAN, BUILDCFG_MOD_DCAN was added to CCS Properties>Build>GNU Compiler>Symbols This ensures the pinmux configuration gets picked up for the peripheral (See am335x_xxxxx_pinmux_data.c).

Header files Some of TI RTOS header files related to interrupts and tasks need to be included in order to build the project in RTOS environment. Refer to loopback_app_main.c (\packages\ti\starterware\examples\dcan\loopback) for the details of header files needed. All the code modifications done for enabling TI RTOS support for the DCAN loopback example are under the flag 'RTOS_BUILD'. Search for this flag in the StarterWare to see all the changes done for enabling RTOS support for DCAN example.

TI RTOS configuration files and project setup files for DCAN loopback example are available at \packages\ti\starterware\examples\dcan\loopback\rtos.

Pinmux Changes Ensure that the relevant pinmux changes have been made at \packages\ti\starterware\board\am335x to enable the corresponding peripheral and platform. The Starterware package has to be rebuilt after making the changes. See http://processors.wiki.ti.com/index.php/Rebuilding_The_PDK on how to rebuild components in the PDK.