This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: Performance Issues using newer FreeRTOS versions

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN, TI-CGT, , RM46L852

Tool/software:

Hi,

We are using FreeRTOS on a TMS570CL435. This processor is arm R5-based. As there is no FreeRTOS port for this we are writing our own based on the R4 port and the provided HalCoGen code. As HalCoGen only supports older FreeRTOS versions we had to adapt it ourselves.
Currently, we are upgrading from version 10.4.5. to the latest version in steps. There we have recognized a significant performance loss by measuring the idle time.

Version

IDLE %

10.4.5

44%

10.4.6

40%

10.5.0

33%

 

By tracking down this Problem, we noticed one change in the portasm.asm and portmacro.h files.

 

FreeRTOS v10.4.5. portasm.asm:

 

; start: required for Cortex-R5 MPU port - generated by TI HALCoGen - see src/os/freertos/README.ti-halcogen.md for details

;-------------------------------------------------------------------------------

        .def ulPortCountLeadingZeros

        .asmfunc

ulPortCountLeadingZeros

        CLZ     R0, R0

        BX      LR

        .endasmfunc

 

FreeRTOS v10.4.5. portmacro.h:

/* Generic helper function. */

    unsigned long ulPortCountLeadingZeros( unsigned long ulBitmap );

    #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    uxTopPriority = ( 31 - ulPortCountLeadingZeros( ( uxReadyPriorities ) ) )

 

FreeRTOS v10.4.6. portasm.asm:

 ; Function removed

 

FreeRTOS v10.4.6. portmacro.h:

 #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities )    uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )

When we just put back the assembler code without calling it, the performance is back at the value of V10.4.5. However, when integrating this also in V10.5.0 the performance worsens. We are using the TI-CGT 20.2.7 compiler and default with -o3 optimization. With no compiler optimizations to -o0, the difference between V10.4.5 and V10.4.6 disappears, but the problem with V10.5.0 remains. 
In version V10.5.0, FreeRTOS introduces an if statement in mpu_wrappers.c to check whether the we are in the privileged mode or not:

 

 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )

        TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,

                                            const char * const pcName,

                                            const uint32_t ulStackDepth,

                                            void * const pvParameters,

                                            UBaseType_t uxPriority,

                                            StackType_t * const puxStackBuffer,

                                            StaticTask_t * const pxTaskBuffer ) /* FREERTOS_SYSTEM_CALL */

        {

            TaskHandle_t xReturn;

            if( portIS_PRIVILEGED() == pdFALSE )

            {

                portRAISE_PRIVILEGE();

                portMEMORY_BARRIER();

                uxPriority = uxPriority & ~( portPRIVILEGE_BIT );

                portMEMORY_BARRIER();

                xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );

                portMEMORY_BARRIER();

                portRESET_PRIVILEGE();

                portMEMORY_BARRIER();

            }

            else

            {

                xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );

            }

            return xReturn;

        }

    #endif /* configSUPPORT_STATIC_ALLOCATION */

 

Before this query was inside the assembler code of swiRaisePrivilege which made it more efficient.
 
Has someone else encountered the same problems, or does anyone know the reason for the change in mpu_wrappers?

I attached the code for the 3 FreeRTOS versions.

Kind regards and thank you, 
Sven

 freertosV10.4.5.zipfreertosV10.4.6.zipfreertosV10.5.0.zip