2009-11-30 05:19 AM
Problems with math.h and Codesourcery
2011-05-17 04:28 AM
Hi,
I've to use some functions of the math-library. Therefore, I included the math.h and added the linker option -lm. Compiling and linking works without an error or warning, but when the controller (STM32F103RE) reaches the first instruction of the math-library, an hardfault-exception occurs. Has anyone a solution for this problem? I'm using the codesourcery compiler and linker. Best regards, Christoph2011-05-17 04:28 AM
recently I had similar problems with other GCC and lib. If there are no warnings in compile, this means, that app and lib are compiled in same manner but does not make shure this is correct for STM32.
E.g. the -mfpu=vfp switch instructs the compiler to use instructions for hardware floating point. There is no impact to your app until compiler really uses such instruction (what will end in a exception for STM32) Make shure, your app (and lib) has been compiled for software float point. If no default, it is either the -msoft-float or -mfloat-abi=soft switch. Probably there are further diffrent stack orders and float formats possible with the GCC. Make shure, your search path in the linker file points to directory of correct version of libm.a what should be normally the version compiled for ARMv7, Thumb2, no interwork, little endian, software float to be compatible for STM32. If you have the things workig, it would be interesting how much the lib code contributes using printf with integer and / or float conversion.2011-05-17 04:28 AM
Hi,
I think I have the same problem Can you help me what I have to change in the makefile. Many thanks! Regards, Thorsten2011-05-17 04:28 AM
Thanks for your answer, although I found a different solution: I added the MCU and the Thumb-Mode to the linker options, compiled it using the codesourcery-gcc, and it runs. Without these options, the wrong libraries are linked.