2017-10-04 02:55 AM
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 filesS_SRCS = CortexM4asmOps.s♯ Project namePROJ_NAME = blinkyOUTPATH = buildOUTPATH := $(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 compatibleifneq ($(FLOAT_TYPE), hard)ifneq ($(FLOAT_TYPE), soft)&sharpoverride FLOAT_TYPE = hardoverride FLOAT_TYPE = softendifendif♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯
AS=$(BINPATH)arm-none-eabi-as
CC=$(BINPATH)arm-none-eabi-gccLD=$(BINPATH)arm-none-eabi-gccOBJCOPY=$(BINPATH)arm-none-eabi-objcopyOBJDUMP=$(BINPATH)arm-none-eabi-objdumpSIZE=$(BINPATH)arm-none-eabi-sizeLINKER_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.specsifeq ($(FLOAT_TYPE), hard)
CFLAGS += -fsingle-precision-constant -Wdouble-promotionCFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hardelseCFLAGS += -msoft-floatendif♯ Default to STM32F40_41xxx if no device is passed
ifeq ($(DEVICE_DEF), )DEVICE_DEF = STM32F40_41xxxendifCFLAGS += -D$(DEVICE_DEF)
vpath %.a lib
♯ IncludesINCLUDE_PATHS = -I$(BASEDIR)/inc -I$(BASEDIR)/lib/cmsis/stm32f4xx -I$(BASEDIR)/lib/cmsis/include -I$(BASEDIR)INCLUDE_PATHS += -I$(BASEDIR)/lib/ConfINCLUDE_PATHS += -I$(BASEDIR)/lib/STM32F4xx_StdPeriph_Driver/inc♯ Library paths
LIBPATHS = -L$(BASEDIR)/lib/STM32F4xx_StdPeriph_Driver♯ Libraries to link
LIBS = -lstdperiph -lc -lgcc -lnosysOBJS = $(SRCS:.c=.o)
OBJS += $(S_SRCS:.s=.o)♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯
.PHONY: lib proj
all: dir lib proj
$(SIZE) $(OUTPATH)/$(PROJ_NAME).elflib:
$(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).disdir:
$(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 libflash:
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' failedmake: *** [dir] Error 2Full project here:
https://github.com/TDAbboud/STM32F4_Examples/tree/master/01_Blinky_btn
#arm-gcc #stm32f4-discovery #makefile2017-10-04 07:15 AM
It does not find the mkdir command
install e.g.
https://gnu-mcu-eclipse.github.io/windows-build-tools/
and add the path to your enviroment