TMS570LS3137: FreeRTOS Porting to TMS570LS3137

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN, , C2000WARE

Hi,

I would like to port a recently released FreeRTOS kernel to the TMS570LS3137 MCU. HALCoGen currently generates a project based on FreeRTOS v9.0.0, which is quite outdated.

I am looking for the most effective and maintainable approach to perform this port. My initial idea is to replace the FreeRTOS kernel source files in the HALCoGen-generated project with the newer FreeRTOS sources, while keeping the existing port-specific files (port.c, port.h, and portASM.asm) unchanged. However, I am not fully confident that this approach is correct or sufficient.

I would appreciate any guidance, best practices, or references from those who have performed a similar update or port on TMS570 (ARM Cortex-R4/R5) devices.

Thank you in advance.

Best regards,

  • Hi, 

    Please expect a delay in response as the expert may be out-of-office due to the holidays.

    Kind regards,
    AJ Favela 

  • Hi Berat,

    We have one internal TI AI which can analyze all the old e2e database as well as documents related to this controller, and i got below suggestions after feeding this question to it, could you please try this method once:

    1. Core Kernel Files - Safe to Replace

    You can replace the following FreeRTOS core kernel files with newer versions:

    • tasks.c
    • queue.c
    • list.c
    • timers.c
    • event_groups.c
    • stream_buffer.c
    • All header files in the include/ directory

    These files are architecture-independent and should work across versions.

    2. Port-Specific Files - Requires Careful Review

    The ARM Cortex-R4 port files (port.c, portmacro.h, and portASM.asm) should NOT be blindly kept from v9.0.0. Here's why:

    Key Considerations:

    • FreeRTOS has made improvements to the ARM_CR4 port between v9.0.0 and recent versions
    • The official FreeRTOS repository contains an ARM_CR4 port that may have bug fixes and optimizations
    • HALCoGen's port may have TI-specific customizations for the TMS570 hardware

    Recommended Strategy:

    1. Compare the ports: Download the latest FreeRTOS kernel from the official FreeRTOS GitHub repository and compare the portable/CCS/ARM_CR4/ (or equivalent) port files with HALCoGen's version
    2. Check for TI-specific modifications: Look for any TMS570-specific initialization or hardware configuration in HALCoGen's port files
    3. Test incrementally: Start with the newer port files and verify basic functionality before adding complexity

    3. FreeRTOSConfig.h - Must Be Carefully Migrated

    This file is device and application-specific and requires manual review:

    • New FreeRTOS versions may introduce new configuration options
    • Some configuration macros may have changed or been deprecated
    • You'll need to merge your existing configuration with any new required settings
    • Important: Add extern "C" guards if mixing C and C++ code

    4. Memory Management

    • Choose an appropriate heap implementation (heap_1.c through heap_5.c)
    • Newer FreeRTOS versions may have improved heap implementations
    • Ensure the heap size is appropriate for your application

    5. Testing Strategy

    Phase 1 - Basic Validation:

    1. Start with a minimal FreeRTOS application (single task with LED blink)
    2. Verify task creation and scheduling
    3. Test context switching

    Phase 2 - Feature Validation:

    1. Test queues, semaphores, and mutexes
    2. Verify interrupt handling (critical for real-time performance)
    3. Test timer functionality
    4. Validate any hardware-specific features (VIM, RTI, etc.)

    Phase 3 - Integration:

    1. Gradually add your application code
    2. Monitor stack usage and heap allocation
    3. Perform stress testing

    6. Potential Issues to Watch For

    Interrupt Configuration:

    • The TMS570 uses the Vectored Interrupt Manager (VIM)
    • Ensure interrupt priorities are correctly configured for FreeRTOS
    • Verify configMAX_SYSCALL_INTERRUPT_PRIORITY is set appropriately

    MPU Configuration:

    • If using the Memory Protection Unit, ensure compatibility with the new kernel

    Compiler Compatibility:

    • Verify your TI ARM compiler version is compatible with the newer FreeRTOS
    • Check for any compiler-specific pragmas or attributes

    7. Alternative Approaches

    Option A: Official FreeRTOS Port

    • Use the official ARM_CR4 port from FreeRTOS GitHub
    • Adapt it for TMS570-specific hardware initialization
    • This gives you the most up-to-date and well-tested port

    Option B: Hybrid Approach

    • Keep HALCoGen's hardware initialization
    • Replace only the core scheduling and context switch code
    • This minimizes risk while gaining newer features

    Option C: Contact TI Support

    • Open a support ticket on e2e.ti.com requesting guidance
    • Ask if TI has plans to update HALCoGen's FreeRTOS version
    • Request any internal documentation on FreeRTOS porting for TMS570

    8. Documentation and Resources

    FreeRTOS Resources:

    TI Resources:

    • TMS570LS3137 Technical Reference Manual
    • HALCoGen User's Guide
    • Hercules Safety MCU documentation

    9. Best Practices

    1. Version Control: Use Git or another VCS to track all changes
    2. Document Changes: Keep detailed notes of modifications made to port files
    3. Maintain Separate Branches: Keep the original HALCoGen project and your modified version separate
    4. Automated Testing: Develop unit tests for critical RTOS functionality
    5. Code Review: Have another engineer review port-specific changes

    10. Known Compatibility Notes

    From my search, I found that TI has successfully ported FreeRTOS to newer versions on other platforms:

    • C2000Ware recently updated to FreeRTOS v11.2.0
    • The porting process involved updating port files and configuration
    • TI maintains device-specific FreeRTOSConfig.h files

    --
    Thanks & regards,
    Jagadish.

  • Hi  

    Thank you for your response.

    Are you planning to update the FreeRTOS version integrated into HalCoGen, or do you plan to share a common TMS570LS3137 project where FreeRTOS has already been ported?

  • Hi Berat,

    Are you planning to update the FreeRTOS version integrated into HalCoGen,

    No currently there is no plan to update.

    There is no active development going on Hercules devices. The team focuses on new or next generation functional safety devices like AM26x series.

    --
    Thanks & regards,
    Jagadish.