K63F: no FPU?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K63F: no FPU?

2,206 Views
tselmeci
Contributor IV

Everywhere I look around I see K63F's Cortex M4 has an FPU. But there are two very disturbing facts:

 

1. KSDK uses this flag to compile itself for K63F:

-mfloat-abi=soft

This makes gcc generate software-floating point instructions, e.g. emulates the FPU (at a huge size and speed penalty).

 

2. If I use these compile options to utilize the FPU, the generated code simply doesn't run (I don't even see a single line of text on my serial console, but haven't gone deeper into the details):

-mfloat-abi=softfp -mfpu=fpv4-sp-d16

These are about to turn on FPU usage.

 

It's very suspicious to me that the information sources are wrong, and K63F in fact doesn't have an FPU.

 

I need some confirmation.

 

(However, I've checked the KSDK build flags for K64F too, and it includes -mfloat-abi=hard and -mfpu=fpv4-sp-d16, so it should have a working FPU.)

Labels (1)
Tags (2)
0 Kudos
7 Replies

1,530 Views
gabrielharrison
Contributor III

Hi,

I've had this issue in the past. Have you confirmed it is not a hardfault caused by the FPU being accessed but not initialised?

It is initialised at the start of SystemInit(). See:

#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1))

  SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2));    /* set CP10, CP11 Full Access */

#endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */

The two constants are defined in core_cm4.h based on your complier.

Regards,

Gabriel

1,530 Views
tselmeci
Contributor IV

Thanks for the suggestion.

I'm using KSDK-1.2.0. The startup code compile flags are located in lib/ksdk_startup_lib/armgcc/K63F12/CMakeLists.txt:

CMAKE_C_FLAGS_RELEASE. This is the default: "...-mcpu=cortex-m4  -mfloat-abi=soft..." so Freescale people have set it to emit softfloat instructions (doesn't make use of the FPU).

For K64F: lib/ksdk_startup_lib/armgcc/K64F12/CMakeLists.txt: CMAKE_C_FLAGS_RELEASE: "...-mcpu=cortex-m4  -mfloat-abi=hard  -mfpu=fpv4-sp-d16...", so it emits FPU instructions by default.

SystemInit(...) for K63F is in platform/devices/MK63F12/startup/system_MK63F12.c. With KSDK's default settings __FPU_USED__ == 0. Why? For the answer see platform/CMSIS/Include/core_cm4.h:

#elif defined ( __GNUC__ )

  #if defined (__VFP_FP__) && !defined(__SOFTFP__)

    #if (__FPU_PRESENT == 1)

      #define __FPU_USED       1

    #else

      #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"

      #define __FPU_USED       0

    #endif

  #else

    #define __FPU_USED         0

  #endif

Since gcc is passed -mfloat-abi=soft, __SOFTFP__ is defined and thus __FPU_USED becomes 0, so the code in SystemInit(...) doesn't compile/execute.

I've modified KSDK to use -mfloat-abi=softfp, so the code in SystemInit(...) compiles and executes. Moreover I've recompiled my whole project with -mfloat-abi=softfp and the result is the same: freezes on startup.

It's little bit like that KSDK developers at Freescale know that K63F hasn't got an FPU (or it's simply non-functional), but they haven't notified the tech-writer guys about this. Somebody correct me if I'm wrong, please!

0 Kudos

1,530 Views
gabrielharrison
Contributor III

What happens when you compile with the default H/W FPU settings in CMakeLists.txt but edit SystemInit() to always include the FPU setup line " SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2));    /* set CP10, CP11 Full Access */"?

0 Kudos

1,530 Views
tselmeci
Contributor IV

I haven't tried it yet and I don't see any point in doing so. In my opinion if K63F really had an FPU, then KSDK (developed by Freescale guys) would have an appropriate setting. Now it's set to emit soft-float instructions. Anyway, enabling the FPU and using soft-float instructions doesn't make too much sense to me.

This is not the first time I see that Freescale HW documentation is imprecise. Would be fine if somebody from Freescale confirm my finding or give me the explanation about the FPU.

0 Kudos

1,530 Views
gabrielharrison
Contributor III

Morning,

I am using this exact code in a different IDE (IAR) for our chip, the K60F via the KSDK and if is working fine so it is most likely a configuration issue.

Regards,

Gabriel

0 Kudos

1,530 Views
tselmeci
Contributor IV

In KSDK-1.2.0 K60D has the following settings:

-mcpu=cortex-m4

-mfloat-abi=soft

-mthumb

Basically appear to be the same as K63F. You you've patched KSDK to execute the FPU initialization routine despite the preprocessor macros. However, you still make KSDK emit soft-float instructions instead of real FPU instructions. I can imagine that K60/K63 have a broken FPU, which passed the initialization, but when it comes to executing an instruction, fails...

0 Kudos

1,530 Views
gabrielharrison
Contributor III

Hi,

I'm using IAR so the compiler is different but by default the FPU module is turned off as well in the project settings. All I did was choose Hardware FPU in the project settings which defines __ARMVFP__. No editing of the KSDK was needed.

Gabriel

0 Kudos