主题中讨论的其他器件:HALCOGEN、 TI-CGT、、 RM46L852
工具与软件:
您好!
我们在 TMS570CL435上使用 FreeRTOS。 该处理器基于 ARM R5。 由于没有用于这一用途的 FreeRTOS 端口、我们将根据 R4端口和提供的 HalCoGen 代码来编写我们自己的端口。 由于 HalCoGen 只支持较旧的 FreeRTOS 版本、我们 必须 自行调整。
目前、我们正在从10.4.5版升级。 更新至最新版本。 我们通过测量空闲时间发现了显著的性能损失。
修补程序版本 |
空闲% |
10.4.5. |
44% |
10.4.6. |
40% |
10.5.0 |
33% |
通过跟踪此问题、我们注意到 portasm.asm 和 portmacro.h 文件中有一处更改。
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_HIGTH_PRIORITY ( uxTopPriority、uxReadyPriorities ) uxTopPriority =( 31 -__clz ( uxReadyPriority )))
当我们在不调用的情况下返回汇编器代码时、性能恢复为 V10.4.5的值。 然而,如果将其集成到 V10.5.0中,性能会下降。 我们使用的是 TI-CGT 20.2.7编译器、默认使用-o3优化。 如果没有对-o0进行编译器优化、V10.4.5和 V10.4.6之间的差异将消失、但 V10.5.0的问题仍然存在。
在 V10.5.0版中、FreeRTOS 在 MPU_wrappers.c 中引入了 if 语句、用于检查我们是否处于特权模式:
#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 */
在该查询之前、swiRaisePrivilege 的汇编代码使其更加高效。
其他人是否遇到过同样的问题、或者有人知道 MPU_wrappers 发生变化的原因吗?
我附加了3个 FreeRTOS 版本的代码。
此致、谢谢。
斯文
e2e.ti.com/.../freertosV10.4.5.zipe2e.ti.com/.../freertosV10.4.6.zipe2e.ti.com/.../freertosV10.5.0.zip