添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Posted on October 04, 2017 at 11:55

Simply I am trying to program my stm32f4 discovery without any ide.Another word I want to use  make command on the terminal in Windows.I know this makefile wrote for macos I cant convert the code working under  Windows.

This is my Makefile:

♯ STM32F4-Discovery Makefile for Mac OSX

SRCS=$(wildcard *.c)

♯ Add assembly source files here or use $(wildcard *.s) for all .s files

S_SRCS = CortexM4asmOps.s

♯ Project name

PROJ_NAME = blinky

OUTPATH = build

OUTPATH := $(abspath $(OUTPATH))

BASEDIR := $(abspath ./)

MKDIR_P = Mkdir

♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯

♯ Check for valid float argument

♯ NOTE that you have to run make clan after

♯ changing these as hardfloat and softfloat are not

♯ binary compatible

ifneq ($(FLOAT_TYPE), hard)

ifneq ($(FLOAT_TYPE), soft)

&sharpoverride FLOAT_TYPE = hard

override FLOAT_TYPE = soft

endif

endif

♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯

AS=$(BINPATH)arm-none-eabi-as

CC=$(BINPATH)arm-none-eabi-gcc

LD=$(BINPATH)arm-none-eabi-gcc

OBJCOPY=$(BINPATH)arm-none-eabi-objcopy

OBJDUMP=$(BINPATH)arm-none-eabi-objdump

SIZE=$(BINPATH)arm-none-eabi-size

LINKER_SCRIPT = stm32_flash.ld

CPU = -mcpu=cortex-m4 -mthumb

CFLAGS = $(CPU) -c -std=gnu99 -g -O2 -Wall

LDFLAGS = $(CPU) -mlittle-endian -mthumb-interwork -nostartfiles -Wl,--gc-sections,-Map=$(OUTPATH)/$(PROJ_NAME).map,--cref --specs=nano.specs

ifeq ($(FLOAT_TYPE), hard)

CFLAGS += -fsingle-precision-constant -Wdouble-promotion

CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard

else

CFLAGS += -msoft-float

endif

♯ Default to STM32F40_41xxx if no device is passed

ifeq ($(DEVICE_DEF), )

DEVICE_DEF = STM32F40_41xxx

endif

CFLAGS += -D$(DEVICE_DEF)

vpath %.a lib

♯ Includes

INCLUDE_PATHS = -I$(BASEDIR)/inc -I$(BASEDIR)/lib/cmsis/stm32f4xx -I$(BASEDIR)/lib/cmsis/include -I$(BASEDIR)

INCLUDE_PATHS += -I$(BASEDIR)/lib/Conf

INCLUDE_PATHS += -I$(BASEDIR)/lib/STM32F4xx_StdPeriph_Driver/inc

♯ Library paths

LIBPATHS = -L$(BASEDIR)/lib/STM32F4xx_StdPeriph_Driver

♯ Libraries to link

LIBS = -lstdperiph -lc -lgcc -lnosys

OBJS = $(SRCS:.c=.o)

OBJS += $(S_SRCS:.s=.o)

♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯

.PHONY: lib proj

all: dir lib proj

$(SIZE) $(OUTPATH)/$(PROJ_NAME).elf

lib:

$(MAKE) -C lib FLOAT_TYPE=$(FLOAT_TYPE) BINPATH=$(BINPATH) DEVICE_DEF=$(DEVICE_DEF) BASEDIR=$(BASEDIR)

proj: $(OUTPATH)/$(PROJ_NAME).elf

.s.o:

$(AS) $(CPU) -o $(addprefix $(OUTPATH)/, $@) $<

.c.o:

$(CC) $(CFLAGS) -std=gnu99 $(INCLUDE_PATHS) -o $(addprefix $(OUTPATH)/, $@) $<

$(OUTPATH)/$(PROJ_NAME).elf: $(OBJS)

$(LD) $(LDFLAGS) -T$(LINKER_SCRIPT) $(LIBPATHS) -o $@ $(addprefix $(OUTPATH)/, $^) $(LIBS) $(LD_SYS_LIBS)

$(OBJCOPY) -O ihex $(OUTPATH)/$(PROJ_NAME).elf $(OUTPATH)/$(PROJ_NAME).hex

$(OBJCOPY) -O binary $(OUTPATH)/$(PROJ_NAME).elf $(OUTPATH)/$(PROJ_NAME).bin

$(OBJDUMP) -S --disassemble $(OUTPATH)/$(PROJ_NAME).elf > $(OUTPATH)/$(PROJ_NAME).dis

dir:

$(MKDIR_P) $(OUTPATH)

clean:

rm -f $(OUTPATH)/*.o

rm -f $(OUTPATH)/$(PROJ_NAME).elf

rm -f $(OUTPATH)/$(PROJ_NAME).hex

rm -f $(OUTPATH)/$(PROJ_NAME).bin

rm -f $(OUTPATH)/$(PROJ_NAME).dis

rm -f $(OUTPATH)/$(PROJ_NAME).map

♯ Remove the following line if you don't want to clean the Libraries as well

$(MAKE) clean -C lib

flash:

st-flash write build/$(PROJ_NAME).bin 0x08000000

<=====================================================================>

Gives me this error:

Mkdir C:/Users/As/Downloads/STM32F4_Examples-master/01_Blinky_btn/build

process_begin: CreateProcess(NULL, Mkdir C:/Users/As/Downloads/STM32F4_Examples-master/01_Blinky_btn/build, ...) failed.

Makefile:102: recipe for target 'dir' failed

make: *** [dir] Error 2

Full project here:

https://github.com/TDAbboud/STM32F4_Examples/tree/master/01_Blinky_btn

#arm-gcc #stm32f4-discovery #makefile STM32CubeMX project fails to build after project is re-named and configuration.ioc file changes in STM32 MCUs Embedded software makefile:##: *** multiple target patterns. Stop. in STM32CubeIDE (MCUs)