Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


FPU float in functions calls

Hello,

I recently started with OpenSTM32 to program my STM32F4 Discovery board. I’ve already programmed it under Windows with CooCox IDE. So I had some program examples to test under Linux and sw4stm32. But, I was surprised that one of them didn’t run correctly and hanged. After spending some time with the debugger, I noticed that the problem was due to float variable declaration and function call with float variables as parameters. The program went in an infinite loop.
First, I took a look at the compiler options in order to verify that the FPU was correctly set, and yes it was. Second, I searched on internet about this problem and found some ideas like changing float to double. So I did it but it wasn’t sufficient : the FPU was in fact not activated !

Here what the original code looks like :

factor(float, float);
int main(void)
{
float a = 10.0f, b = -1.5f;

while(1)
{
factor(a, b);
}
}



This code needs the corrections below to run correctly :

factor(double, double); // float -> double
int main(void)
{
// NOTE: Important: Enable full access to FPU:
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */

double a = 10.0f, b = -1.5f; // float -> double

while(1)
{
factor(a, b);
}
}

Another thing to do in factor() is to cast the double variable to float because there is a slowdown in the calculation using double. Why ? Does the FPU only compute float numbers in simple precision ?

So, can someone explain what’s the difference between my original program and the modified one ? Is it a normal behaviour of OpenSTM32 or GCC compiler ?
Thanks

After taking a look to the STM32F4 documentation redface, I can confirm that the FPU only supports float variables in simple precision. That explains the slowdown with double variables I had before. rolleyes. But what can explain the fact that it is impossible to use float vaiables as parameters in a function call ?