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.
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
Hello,
I just wanted to follow up on that question. Has anyone an answer to that?
best regards,
Sven
Hi Sven,
Apologies for the delay in the late response, i was stuck with other issues.
I am working on your issue now and will try to post my updates by Tuesday.
--
Thanks & regards,
Jagadish.
Hi Jagadish,
please be aware of the things already discussed here: Performance Issues using newer FreeRTOS V10.4.6 ,10.5.0 with TMS570LC4357 - Kernel - FreeRTOS Community Forums
Meanwhile I managed to optimize the code in V10.5.0 a bit. With using portIS_PRIVILEGED as a non SWI function, the idle time got up to 38%. See the current version attached.
Kind regards,
Sven
Hi Sven,
Can you please refer below two threads once, these threads might be helpful in this context.
--
Thanks & regards,
Jagadish.
Hi Jagadish,
Yes these threads are related to the topic.
(+) TMS570LC4357: What is the rationale behind ulPortCountLeadingZeros when __clz exists? - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums
Yes, these two versions look at assembler level pretty much the same. They are just different registers.
(+) RM46L852: FreeRTOS on RM46 - Missing function in portASM.asm file - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums
If you look into the code, I have implemented these two functions or used the inline assembler command. However, this does not the performance loss.
Kind regards,
Sven
Hi Sven,
If you look into the code, I have implemented these two functions or used the inline assembler command. However, this does not the performance loss.
I don't have any other suggestions from my side,
Maybe i should need to discuss with RTOS expert on our side.
--
Thanks & regards,
Jagadish.