threadx icon indicating copy to clipboard operation
threadx copied to clipboard

ThreadX Context Save/Restore of Floating Point Registers for Cortex-R5

Open austinawolf opened this issue 1 year ago • 6 comments

I'm working on setting up ThreadX with Cortex-R5F on Xilinx Ultrascale+ R5F. I've noticed some data corruption associated with using floating point registers on memcpy and now looking at _tx_thread_context_save for R5 port, it seems like it doesn't save context floating point registers.

There are some references to VFP support on other processor ports but isn't much documentation to go off.

Is it possible to use hard floating point math on R5 with ThreadX?

austinawolf avatar May 16 '24 22:05 austinawolf

Some of the other ARM ports seem to have support for using TX_ENABLE_VFP_SUPPORT then using tx_thread_vfp_enable to enable it, but the R5 is missing is the extension define here: https://github.com/eclipse-threadx/threadx/blob/master/ports/cortex_r5/gnu/inc/tx_port.h#L197

Like for the A9: https://github.com/eclipse-threadx/threadx/blob/master/ports/cortex_a9/gnu/inc/tx_port.h#L199

austinawolf avatar May 21 '24 15:05 austinawolf

Funny, seems related to our #382 two weeks before your report, we are on the same problematics

Our Quick and Dirty solution is , for now, building in softFP...

ted0xff avatar May 30 '24 07:05 ted0xff

@eclipse-threadx/iot-threadx-committers and @eclipse-threadx/iot-threadx-contributors: Please provide your feedback.

fdesbiens avatar Mar 19 '25 18:03 fdesbiens

It looks like all this is missing are the prototypes in tx_port.h, e.g., the VFP code and enable/disable APIs are in the assembly port files. You do need to build the assembly code with TX_ENABLE_VFP_SUPPORT defined though.

billlamiework avatar Mar 19 '25 18:03 billlamiework

@austinawolf Following suggestions from @billlamiework: (1) Add "#define TX_THREAD_EXTENSION_2 ULONG tx_thread_vfp_enable; " to your tx_port.h (2) Rebuild the ThreadX library and all the application code with the symbol TX_ENABLE_VFP_SUPPORT defined.

The ThreadX team will review a fix for the next release.

yuxinzhou5 avatar Apr 08 '25 17:04 yuxinzhou5

Got it, thanks @billlamiework @yuxinzhou5

austinawolf avatar Apr 09 '25 23:04 austinawolf