# Problem whith makefile about double and float

**URL:** <https://forums.freertos.org/t/problem-whith-makefile-about-double-and-float/5089>\
**Category:** Kernel\
**Created:** [March 17, 2014, 1:37pm UTC](https://forums.freertos.org/t/problem-whith-makefile-about-double-and-float/5089 "2014-03-17T13:37:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 17, 2014, 1:37pm UTC](https://forums.freertos.org/t/problem-whith-makefile-about-double-and-float/5089/1 "2014-03-17T13:37:44Z")

</div>

**[kamran99kamran](https://sourceforge.net/u/kamran99kamran/)** wrote on [Monday, March 17, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/e1e7c099/#2f65):

Hello,

i have some problem about double!  
Through terminal there is some query, that i should give some number.  
for example how much delay in per hour.  
if i give through terminal a number 1.1 h then it printed about -1173000!  
It shall print only 1.1.  
And i think, maybe there is some problem about makefile from FreeRTOS.  
( because it doesn’t compiler through FreeRTOS to STM32F407 Processor! )

And I believe something throug this line shall be solved!

– CPU = -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16

Please I need help, thanks

here is the fully Code of Makefile:

# Optimization level, can be [0, 1, 2, 3, s].

# 0 = turn off optimization. s = optimize for size.

# 

OPT = 0

# Object files directory

# Warning: this will be removed by make clean!

# 

OBJDIR = obj

# Target file name (without extension)

#TARGET = $(OBJDIR)/main  
TARGET = $(OBJDIR)/STM32F4\_Test

# Define all C source files (dependencies are generated automatically)

# 

SOURCES += src/uart.c  
SOURCES += src/ustime.c  
SOURCES += src/main.c  
SOURCES += src/startup\_stm32f4xx.S  
SOURCES += src/system\_stm32f4xx.c  
SOURCES += src/syscalls.c  
SOURCES += src/modbus.c  
SOURCES += src/test.c  
SOURCES += src/get.c  
SOURCES += src/heap\_2.c

SOURCES += FreeRTOS/Source/tasks.c  
SOURCES += FreeRTOS/Source/queue.c  
SOURCES += FreeRTOS/Source/list.c  
SOURCES += FreeRTOS/Source/croutine.c  
SOURCES += FreeRTOS/Source/portable/GCC/ARM\_CM4F/port.c

SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/misc.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_adc.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_can.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_crc.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_cryp.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_cryp\_aes.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_cryp\_des.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_cryp\_tdes.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_dac.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_dbgmcu.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_dcmi.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_dma.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_exti.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_flash.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_fsmc.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_gpio.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_hash.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_hash\_md5.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_hash\_sha1.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_i2c.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_iwdg.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_pwr.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_rcc.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_rng.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_rtc.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_sdio.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_spi.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_syscfg.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_tim.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_usart.c  
SOURCES += libs/STM32F4xx\_StdPeriph\_Driver/src/stm32f4xx\_wwdg.c

OBJECTS = $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SOURCES))))

# Place -D, -U or -I options here for C and C++ sources

CPPFLAGS += -Isrc  
CPPFLAGS += -IFreeRTOS/Source/include  
CPPFLAGS += -Ilibs/CMSIS/Include  
CPPFLAGS += -Ilibs/Device/STM32F4xx/Include  
CPPFLAGS += -Ilibs/STM32F4xx\_StdPeriph\_Driver/inc

#---------------- Compiler Options C ----------------

# -g\*: generate debugging information

# -O\*: optimization level

# -f…: tuning, see GCC documentation

# -Wall…: warning level

# -Wa,…: tell GCC to pass this to the assembler.

# -adhlns…: create assembler listing

CFLAGS = -O$(OPT)  
CFLAGS += -std=gnu99  
CFLAGS += -gdwarf-2  
CFLAGS += -ffunction-sections  
CFLAGS += -fdata-sections  
CFLAGS += -Wall  
#CFLAGS += -Wextra  
#CFLAGS += -Wpointer-arith  
#CFLAGS += -Wstrict-prototypes  
#CFLAGS += -Winline  
#CFLAGS += -Wunreachable-code  
#CFLAGS += -Wundef  
CFLAGS += -Wa,-adhlns=$(OBJDIR)/$(\*F).lst

# Optimize use of the single-precision FPU

# 

# CFLAGS += -fsingle-precision-constant

# This will not work without recompiling libs

# 

# CFLAGS += -fshort-double

#---------------- Compiler Options C++ ----------------

# 

CXXFLAGS = $(CFLAGS)

#---------------- Assembler Options ----------------

# -Wa,…: tell GCC to pass this to the assembler

# -adhlns: create listing

# 

ASFLAGS = -Wa,-adhlns=$(OBJDIR)/$(\*F).lst

#---------------- Linker Options ----------------

# -Wl,…: tell GCC to pass this to linker

# -Map: create map file

# –cref: add cross reference to map file

LDFLAGS += -lm  
LDFLAGS += -Wl,-Map=$(TARGET).map,–cref  
LDFLAGS += -Wl,–gc-sections  
LDFLAGS += -Tsrc/stm32\_flash.ld

#============================================================================

# Define programs and commands

TOOLCHAIN = d:/Programme/CodeSourcery/Sourcery\_2011\_09\_ARM\_EABI/bin/arm-none-eabi  
CC = $(TOOLCHAIN)-gcc  
OBJCOPY = $(TOOLCHAIN)-objcopy  
OBJDUMP = $(TOOLCHAIN)-objdump  
SIZE = $(TOOLCHAIN)-size  
NM = $(TOOLCHAIN)-nm  
OPENOCD = D:\Tools\openocd-0.7.0\bin\openocd-0.7.0.exe  
DOXYGEN = doxygen  
STLINK = tools/ST-LINK\_CLI.exe  
MKDIR = d:\tools\unxutils\bin\mkdir.exe

ifeq (AMD64, $(PROCESSOR\_ARCHITEW6432))  
SUBWCREV = tools/SubWCRev64.exe  
else  
SUBWCREV = tools/SubWCRev.exe  
endif

# Compiler flags to generate dependency files

GENDEPFLAGS = -MMD -MP -MF $(OBJDIR)/$(\*F).d

# Combine all necessary flags and optional flags

# Add target processor to flags.

# 

#CPU = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft  
#CPU = -mcpu=cortex-m4 -mthumb

# 

// kannst du mal nach dem problem suchen? Und dich ueber floating point probleme informieren?  
// auf der ARM cpu oder spezielle dieser F407 cpu

CPU = -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16  
#CPU = -mcpu=cortex-m4 -mthumb

CFLAGS += $(CPU)  
CXXFLAGS += $(CPU)  
ASFLAGS += $(CPU)  
LDFLAGS += $(CPU)

# Default target.

all: setup gccversion build showsize

setup:  
$(MKDIR) -p $(OBJDIR)  
$(MKDIR) -p $(OBJDIR)\src  
$(MKDIR) -p $(OBJDIR)\FreeRTOS\Source  
$(MKDIR) -p $(OBJDIR)\FreeRTOS\Source\portable\GCC\ARM\_CM4F  
$(MKDIR) -p $(OBJDIR)\libs\STM32F4xx\_StdPeriph\_Driver\src

build: elf hex lss sym bin

elf: $(TARGET).elf  
hex: $(TARGET).hex  
bin: $(TARGET).bin  
lss: $(TARGET).lss  
sym: $(TARGET).sym

doxygen:  
@echo  
@echo Creating Doxygen documentation  
@$(DOXYGEN)

# Display compiler version information

gccversion:  
@$(CC) --version

# Show the final program size

showsize: elf  
@echo  
@$(SIZE) $(TARGET).elf

# debug level

OOCD\_CL=-d2  
#OOCD\_CL=-d3

# interface and board/target settings (using the OOCD target-library here)

## OOCD\_CL+=-c “fast enable”

OOCD\_CL+=-f interface/signalyzer.cfg -f openocd/stm32f4x.cfg  
OOCD\_CL+=-f openocd/config.cfg  
OOCD\_CL+=-c init -c targets

# commands to prepare flash-write

OOCD\_CL+=-c “halt”

# flash-write and -verify

OOCD\_CL+=-c “flash write\_image erase $(TARGET).elf” -c “verify\_image $(TARGET).elf”

# reset target

OOCD\_CL+=-c “reset run”

# terminate OOCD after programming

# OOCD\_CL+=-c shutdown

# Flash the device

flash: hex

# $(OPENOCD) -f “interface/signalyzer.cfg” -f “openocd/stm32f4x.cfg” -f “openocd/config.cfg” -c “flash\_image $(TARGET).elf; shutdown”

```
$(OPENOCD) $(OOCD_CL)

```

# $(STLINK) -c SWD -P $(TARGET).hex -Run

# Target: clean project

clean:  
@echo Cleaning project:  
rm -rf $(OBJDIR)  
rm -rf docs/html

# Create extended listing file from ELF output file

%.lss: %.elf  
@echo  
@echo Creating Extended Listing: $@  
$(OBJDUMP) -h -S -z $\< \> $@

# Create a symbol table from ELF output file

%.sym: %.elf  
@echo  
@echo Creating Symbol Table: $@  
$(NM) -n $\< \> $@

# Link: create ELF output file from object files

.SECONDARY: $(TARGET).elf  
.PRECIOUS: $(OBJECTS)  
$(TARGET).elf: $(OBJECTS)  
@echo  
@echo Linking: $@  
$(CC) $^ $(LDFLAGS) --output $@

# Create final output files (.hex, .eep) from ELF output file.

%.hex: %.elf  
@echo  
@echo Creating hex file: $@  
$(OBJCOPY) -O ihex $\< $@

# Create bin file :

%.bin: %.elf  
@echo  
@echo Creating bin file: $@  
$(OBJCOPY) -O binary $\< $@

# Compile: create object files from C source files

$(OBJDIR)/%.o : %.c  
@echo  
@echo Compiling C: $\<  
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(GENDEPFLAGS) $\< -o $@

# Compile: create object files from C++ source files

$(OBJDIR)/%.o : %.cpp  
@echo  
@echo Compiling CPP: $\<  
$(CC) -c $(CPPFLAGS) $(CXXFLAGS) $(GENDEPFLAGS) $\< -o $@

# Assemble: create object files from assembler source files

$(OBJDIR)/%.o : %.s  
@echo  
@echo Assembling: $\<  
$(CC) -c $(CPPFLAGS) $(ASFLAGS) $\< -o $@

# Include the dependency files

-include $(wildcard $(OBJDIR)/\*.d)

# Listing of phony targets

.PHONY: all build flash clean   
doxygen elf lss sym   
showsize gccversion   
build elf hex bin lss sym clean clean\_list setup program

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 17, 2014, 2:42pm UTC](https://forums.freertos.org/t/problem-whith-makefile-about-double-and-float/5089/2 "2014-03-17T14:42:35Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, March 17, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/e1e7c099/#b308):

There are few things that can effect printing of floating point numbers, only one of which is FreeRTOS related.

In the past we have found that stacks must be 8 byte aligned to use optimised floating point printf() functions - this is inline with the official ABI from ARM but we had been reliably informed 4 was enough but evidentially not! All FreeRTOS Cortex-M ports have had the correct 8 byte alignment for a long time now, so it should not be an issue, but just to double check try using printf() on a double before starting the scheduler, so the stack is exactly the stack setup by the tools for use by main() and not the task stack.

If it fails from main() too then you need to look at your compiler options and the support for floating point in your library build. Many libraries come in multiple versions, with full, partial or no floating point support to save code space. The easiest thing to do with regards to compiler options is look in the ARM GCC FAQs, and other example projects.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 18, 2014, 10:02am UTC](https://forums.freertos.org/t/problem-whith-makefile-about-double-and-float/5089/3 "2014-03-18T10:02:42Z")

</div>

**[kamran99kamran](https://sourceforge.net/u/kamran99kamran/)** wrote on [Tuesday, March 18, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/e1e7c099/#4b40):

It is the true, that it even failed from main() too.  
I am using CodeSourcery!  
I have looked in ARM GCC FAQs, but there is not some solution to my problem.  
I am using STM32F407ZGT6.

please show me the linking to website!

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 18, 2014, 10:09am UTC](https://forums.freertos.org/t/problem-whith-makefile-about-double-and-float/5089/4 "2014-03-18T10:09:23Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, March 18, 2014](https://sourceforge.net/p/freertos/discussion/382005/thread/e1e7c099/#d8f0):

Please contact CodeSourcery about this issue. They should be able to tell you the command line options or the libraries needed, or at least have some documentation they can point you to.

Regards.
