-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Implement Cortex-R floating-point support #19979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@stephanosio I found your https://github.com/stephanosio/zephyr/commits/aarch32_non_m_fp_alt branch and pulled those changes. I wanted to see if you have done any more work on this issue, specifically have you implemented anything mentioned in the "Specifications 3-7" section above? |
@bbolen There is a Cortex-A (and -R) FP sharing implementation that sort of works here: |
@stephanosio thank you |
Can you elaborate on the description above with respect to items 5 and 6? I'm struggling to understand why the vfp registers would be saved on the exception stack and not the thread context in the normal case. I can see needing to temporarily put it on the exception stack in order for the exception handler to use the VFP unit, but I would assume they would be popped off that stack and pushed onto the thread context during the context switch. |
Here is a working implementation of floating point support for Cortex-R. It does lazy context switching. It is based on v2.3.0. There are some conflicts with HEAD, but it will be a while before I can get around to looking at those. I'm putting this out there in case others need a starting point for FPU support before I can get this merge worthy. https://github.com/bbolen/zephyr/commits/cortex_r_fpu |
Some of R4F socs have double precision. For example quote from TI Hercules brochure |
Hi @bbolen , I am working on supporting a cortex-r5f chip in zephyr, and I've spliced in your code from this post: #19979 (comment) I have it building, however when trying to flash it onto the board I am encountering the following error: When looking at the ARM documentation here: https://developer.arm.com/documentation/ddi0406/b/System-Level-Architecture/The-System-Level-Programmers--Model/Exceptions/Undefined-Instruction-exception?lang=en I found this section: software emulation of a coprocessor in a system that does not have the physical coprocessor hardware Do you know if my error is a coincidence, or related in the way described? If so, do you have a suggestion? |
It could be related. The FPU is usually disabled. When the code gets to a floating point instruction, an undefined instruction happens, the FPU gets enabled, and execution starts again on the floating point instruction that caused the fault. So one undefined instruction exception would be expected when using floating point, but it wouldn't crash anything. I'm unavailable for the rest of the week, but I'll look closer at your details above on Monday. |
`Open On-Chip Debugger 0.11.0+dev-00242-g7036ed509-dirty (2021-08-03-17:04) 0* tms570.cpu cortex_r4 big tms570.cpu running Info : JTAG tap: tms570.jrc tap/device found: 0x1b95a02f (mfg: 0x017 (Texas Instruments), part: 0xb95a, ver: 0x1) Info : XDS110: disconnected -- Application: /home/smith/zephyrproject/zephyr/samples/hello_world My local zephyr repo was cloned from your repo here: https://github.com/bbolen/zephyr/commits/cortex_r_fpu and I updated it to the latest version. |
At the time of writing, ARM Cortex-R port does not support the use of hardware floating-point unit (VFP and NEON).
Considering common application scenarios for Cortex-R (real-time processing), it is imperative that hardware floating-point unit support is available for it; otherwise, practical usability of the Cortex-R port becomes questionable.
Overview
An overview of the hardware floating-point unit for Cortex-R is as follows:
Specifications
ARM Cortex-R floating-point support feature shall:
support Unshared FP registers mode and Shared FP registers mode.
optionally support emulation of the VFP instructions that are unimplemented by hardware.
ARM Cortex-R floating-point support feature, for Shared FP registers mode, shall:
manage FP enable status at thread level, in conformance with the kernel FP interface.
K_FP_REGS
option shall be used to specify whether thread-wide floating-point support is enabled.K_FP_REGS
option may be (re-)enabled only for the threads that were initially created with the same option.disable FPU after a context switch and re-enable it upon exception.
K_FP_REGS
option is set for the thread.store s0-s15 and FPSCR in exception stack frame and s16-s31 in thread context.
implement lazy stacking of FP context.
preserve s16-s31 during context switch only when FPU is enabled.
Note
The text was updated successfully, but these errors were encountered: