C语言 有麻烦与制作文件



我对double有一些问题!通过终端有一些查询,我应该给出一些数字(例如每小时延误多少)。如果我在终端输入一个数字,比如1.1 h,那么它会打印出-1173000!它应该只输出1.1。

我想,可能是FreeRTOS的Makefile有问题。(因为它不能通过FreeRTOS编译到STM32F407处理器!)

我认为这一行的某些东西应该被修复!

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

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:Toolsopenocd-0.7.0binopenocd-0.7.0.exe
DOXYGEN   = doxygen
STLINK    = tools/ST-LINK_CLI.exe
MKDIR           = d:toolsunxutilsbinmkdir.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)FreeRTOSSource
    $(MKDIR) -p $(OBJDIR)FreeRTOSSourceportableGCCARM_CM4F
    $(MKDIR) -p $(OBJDIR)libsSTM32F4xx_StdPeriph_Driversrc

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

我不相信Sourcery CodeBench 2011.09 ARM EABI编译器支持这种配置。特别是,您的FPU设置似乎使用单精度,我很确定该工具链中包含的所有库都期望双精度FPU。

并不是编译器不能生成你想要的代码。问题是工具链不包含兼容的库。

有可能我弄错了,FreeRTOS的人已经构建并捆绑了缺失的部分,但怀疑没有。

相关内容

  • 没有找到相关文章

最新更新