ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.68k stars 2.98k forks source link

softfp does not work for Cortex-M33 #9142

Closed mmahadevan108 closed 5 years ago

mmahadevan108 commented 5 years ago

Description

Cortex-M33 is using softfp floating point implementation https://github.com/ARMmbed/mbed-os/blob/master/tools/toolchains/arm.py#L426

However the __FPU_USED flag is not set thereby the FPU is not enabled and crashes when executing floating point instructions.

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug
0xc0170 commented 5 years ago

@ARMmbed/mbed-os-tools Please review

kjbracey commented 5 years ago

Is this a CMSIS bug?

For ARMC6, core_cm33.h is checking __ARM_PCS_VFP, but that's a Procedure Calling Standard check. It's false because softfp is selected.

I believe it should be checking __ARM_FP ("hardware floating-point is available"), which is the equivalent of the __TARGET_FPU_VFP it uses for ARMC5.

I would expect the same failure to be seen on Cortex-M7F devices with ARMC6, which are also set to softfp. But M4F are set to hardfp, so avoids this problem. But it shouldn't - all devices should be using the same ABI, so that should be softfp.

JonatanAntoni commented 5 years ago

This has been fixed in https://github.com/ARM-software/CMSIS_5/commit/969822ae162539d50617d1e5a3634ee2fd3b60f6

kjbracey commented 5 years ago

I'll raise a CMSIS update PR. Just a cherry-pick for now, so we can send this to 5.11.1, but should look at a full update during 5.12 timeframe.

kjbracey commented 5 years ago

And I think we've got a real issue with FP ABI inconsistency on ARMC5, ARMC6 and IAR. GCC is the only one always setting softfp.

I guess the issue doesn't show up because we don't ever pass FP values in and out of precompiled binary libraries. I wonder whether we should resolve on consistent use of softfp, or let it vary based on hardware, and just say no FP passing to binary libraries.

I assume the linkers would warn if FP was used with a mismatch (as it isn't warning about any mismatch generally).

ciarmcom commented 5 years ago

Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-333

kjbracey commented 5 years ago

Raised #9153 about the FP ABI issue - I don't think we should ever be selecting softfp for ARMC6.