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.

TMS570LS1224: FreeRTOS with FPU support

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hi,

From what I see, the FreeRTOS code that is being generated by HalCoGen does not support FPU. The internal variable ulTaskHasFPUContext is permanently set to 0 in os_port.c file and the define "configUSE_FPU 1" in FreeRTOSConfig.h file is not used at all. This makes each task having no FPU context. The below link has a description of a problem:

https://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html#floating-point

"To prevent processor register corruption a task must not use any floating point registers unless it has a floating point context. Whether or not RTOS tasks are created with a floating point context by default depends on the compiler in use, and the configUSE_TASK_FPU_SUPPORT setting in FreeRTOSConfig.h."

Please correct me if I am wrong but i think this means I cannot use floating point instructions on this FreeRTOS port. Thus I cannot compile the source with rtsv7R4_T_be_v3D16_eabi.lib library. Which is not good :(

  • Hello,

    Due to the US holidays, responses may be delayed.

  • Hi, Ritchie,

    The link you provided is for ARM Cortex-A processor. TMS570LS12x is ARM-R4F. You may want to take a look at TI Hercules Port,

    https://www.freertos.org/Free_RTOS_for_TI_RM48_and_TMS570.html

    In Build Configurations, try with the TMS570 with FPU option to see if it does anything different.

    Rex

  • Hi, Ritchie,

    I took a closer look, and though there isn't existing FPU example for FreeRTOS. You can try to set ulTaskHasFPUContext to 1, and set the top of the stack when using FPU to include FPU registers.

    Or you can take a look at the TI example in CMSIS which is not FreeRTOS environment. The CMSIS can be downloaded from:

    http://www.ti.com/tool/HERCULES-DSPLIB

    Rex

  • Hi Rex,

    I don't think your answer is correct. I have analyzed TI's port of FreeRTOS more closely and my conclusion is that I think it is sufficient to call vPortTaskUsesFPU() function once before starting FPU calculations in the task and that's it.

    Ritchie

  • Ritchie,

    I believe that requires ulTaskHasFPUContext set to 1.

    Rex

  • Hi Rex,

    This is done in assembly file os_portasm.asm. There is a supervisor call swiPortTaskUsesFPU defined there which does that.

    I believe I am right ;)

    Cheers,

    Ritchie.

  • Hi, Ritchie,

    I suspect the value is reset to 0 in os_port.c and causes tasks not in FPU context. Can you verify that the value set in asm file stay at 1 later after system is up running? or can you verify if the tasks maintain the FPU context? 

    Rex

  • The value is just initialized to 0 in os_port.c file. It is a startup condition. After that, each task can set ulTaskHasFPUContext to 1 by calling vPortTaskUsesFPU() and that value remains set. Moreover, this may sound strange but this global variable is "task-specific". The port was written such that the value is stored on stack at each context switch and restored later. So each task has its version of ulTaskHasFPUContext  variable.

    Ritchie

  • Hi, Ritchie,

    So are you saying FPU is working now by calling vPortTaskUsesFPU() in the task which sets the ulTaskHasFPUContext to 1 in swivPortTaskUsesFPU()? I see the code generated by HalCoGen checks the value of ulFPUContextConst when saving the task context to see if FPU registers should be saved or not. 

    So back to your original question, HalCoGen does support FPU.

    Rex