cancel
Showing results for 
Search instead for 
Did you mean: 

smt32f4 - arm-none-eabi makefile

sarraciro
Associate II
Posted on September 23, 2013 at 11:19

Hi all,

I'm trying to write a makefile for arm-none-eabi toolchain (Menthor arm-2013.05-23-arm-none-eabi-i686-pc-linux-gnu). The file compile all project without error but I have several questions about this procedure.

The first question is about CFLAG. I have set this parameters:

CFLAGS  = -g -O2 -Wall -Tstm32_flash.ld

CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork

CFLAGS += -mfloat-abi=soft -mfpu=fpv4-sp-d16.

I want to change -mfloat-abi=soft in =hard... but the the compiler returns an error:

/tmp/ccW1HQgE.o uses VFP register arguments, main.elf does not

How to include the HARD FPU support ?

The building strucure:

.

??? doc

??? inc

?   ??? stm32f4xx_conf.h

??? lib

?   ??? inc

?   ??? libstm32f4.a

?   ??? Makefile

?   ??? src

?   ??? startup_stm32f4xx.s

??? list.txt

??? Makefile

??? src

?   ??? main.c

?   ??? system_stm32f4xx.c

??? stm32_flash.ld

Another question is about a warning that occurs when I try to include the CMIS library (Math DSP libraries).

When I've included the library (for example arm_abs) in the structure compiled by the Makefile the compiler returns:

arm-none-eabi-gcc -g -O2 -Wall -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=soft -mfpu=fpv4-sp-d16 -ffreestanding -nostdlib -Iinc -Iinc/core -Iinc/peripherals -Iinc/private -c -o arm_abs_f32.o src/core/BasicMathFunctions/arm_abs_f32.c

In file included from src/core/BasicMathFunctions/arm_abs_f32.c:36:0:

inc/core/arm_math.h: In function 'arm_pid_q15':

inc/core/arm_math.h:5316:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

For your considerations I attach the makefile included in the compilation of libraries (not the main makefile)... the file include the last line (of SRC section) in which I pass the argument ''arm_abs_f32.c'' (but the problem extist also with other DSP libraries)...

Another thing that I did is that I had to define a constant in a main.c in which I declare :

&sharpdefine ARM_MATH_CM4.

If not the building compilation break because it don't find ARMCM4.h (and I have not).

Anyone know how to fix these problems??

Thank you for your attention & your time.

#makefile #sm32f4 #arm-none
6 REPLIES 6
frankmeyer9
Associate II
Posted on September 23, 2013 at 15:17

CFLAGS += -mfloat-abi=soft -mfpu=fpv4-sp-d16.

That doesn't make too much sense together. ''soft'' means ''no FPU'', so you don't need to specify the FPU then ...

You don't use any libs, so perhaps you just forgot a ''clean'' after changening this flag, before the ''make''. But generally, you need to translate all parts of your application with the same kind of float ABI, as soft/softfp uses other ways of passing parameters than hard. To use the FPU, you can use softfp instead, the loss of performance is most often insignificant.

The ''soft'' and ''softfp'' settings are compatible and can be freely intermixed - on targets with FPU.

inc/core/arm_math.h:5316:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

 

You might want to look at the offending source code here, probably it is just not C99 conforming (

http://blog.qt.digia.com/blog/2011/06/10/type-punning-and-strict-aliasing/

).

If not the building compilation break because it don't find ARMCM4.h (and I have not).

 

Have you added the path to this header to the include list, and did you check for case issues ?

I had some projects which broke on linux systems, because the sloppy include file naming in ST examples collided with the case-sensitive file system.

sarraciro
Associate II
Posted on September 24, 2013 at 12:32

Thank for reply,

The change of CFLAG from soft to softfp produced the follow message:

In file included from inc/core/arm_math.h:263:0,

from src/core/BasicMathFunctions/arm_abs_f32.c:36:

inc/core/core_cm4.h:133:8: warning: #warning ''Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)'' [-Wcpp]

I'm looking for the C99 compliance..  I hope to fix it...

Also thanks for very intersting article regarding for....

frankmeyer9
Associate II
Posted on September 24, 2013 at 12:51

inc/core/core_cm4.h:133:8: warning: #warning ''Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)'' [-Wcpp]

 

The usual procedure in the supplied (IDE) examples is to add this #define(s) to the project settings. With a make file, this should be even simpler. There are several such defines on ''meta'' level, which should not be set/changed in the source files, but provided by the project settings. For instance, you might want to set the macro ''__FPU_USED'' to ''1'', too.

I'm looking for the C99 compliance..  I hope to fix it...

 

I never checked this for the ST driver lib, nor for the DSP_Lib (which is supplied from ARM). Advanced features and techniques sometimes take longer to penetrate the embedded world ...

sarraciro
Associate II
Posted on September 24, 2013 at 13:30

Yes you're right, the macro is required. For now I've added it in the core_cm4.h... (I have to move in another appropriate place)... In this moment the warning of FPU_PRESENT is solved....

Also I'm agree with you when say that solve the other warning is not simple...(probably require more time of write a new functions ... maybe).

Thank for support and kindness.

frankmeyer9
Associate II
Posted on September 24, 2013 at 16:24

Also I'm agree with you when say that solve the other warning is not simple...(probably require more time of write a new functions ... maybe).

 

I believe you mean this ''type-punned pointer breaks strict aliasing rules'' issue.

I generally hesitate to hack foreign sources (as the offending source code was supplied by ARM). Usually serious maintainance issues arise, at least with the next version (of the DSP_Lib, in this case).

But I understand your point in insisting on C99. My employer requires our code to build with ''-Werror'', except for foreign sources.

Posted on September 24, 2013 at 17:33

If it's any help this is how I built DSP library files with GNU/GCC (Yagarto)

arm-none-eabi-gcc -c -mthumb -gdwarf-2 -MD -Wall -O3 -mapcs-frame -mthumb-interwork -I../../../Include -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -fno-strict-aliasing -ffunction-sections -IC:/Keil453/ARM/CMSIS/Include -IC:/TOOLS/yagarto462/arm-none-eabi/include -DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=''1'' -o ./intermediateFiles/arm_abs_f32.o ../BasicMathFunctions/arm_abs_f32.c
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..