Created
April 13, 2015 12:26
-
-
Save beriberikix/ee9a8d6795892e95b50d to your computer and use it in GitHub Desktop.
Hacky Makefile for Armstap's blinky sample. Forked from https://github.com/nitsky/stm32-example/blob/master/Makefile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUILDDIR = build | |
GCC_BIN = ../gcc-arm-none-eabi-4_9-2015q1/bin | |
#DEVICE = source | |
CORE = includes/CMSIS | |
PERIPH = includes/STM32F4xx_StdPeriph_Driver | |
STM = includes/STM32F4xx | |
#DISCOVERY = stm32/discovery | |
#SOURCES += $(DISCOVERY)/src/stm32f3_discovery.c | |
SOURCES += $(PERIPH)/src/stm32f4xx_gpio.c \ | |
$(PERIPH)/src/stm32f4xx_i2c.c \ | |
$(PERIPH)/src/stm32f4xx_rcc.c \ | |
$(PERIPH)/src/stm32f4xx_spi.c \ | |
$(PERIPH)/src/stm32f4xx_exti.c \ | |
$(PERIPH)/src/stm32f4xx_syscfg.c | |
SOURCES += startup_stm32f4xx.s | |
SOURCES += system_stm32f4xx.c | |
SOURCES += main.c | |
OBJECTS = $(addprefix $(BUILDDIR)/, $(addsuffix .o, $(basename $(SOURCES)))) | |
INCLUDES += -I$(CORE) \ | |
-I$(PERIPH)/inc \ | |
-I$(STM) \ | |
-I\ | |
ELF = $(BUILDDIR)/program.elf | |
HEX = $(BUILDDIR)/program.hex | |
BIN = $(BUILDDIR)/program.bin | |
CC = $(GCC_BIN)/arm-none-eabi-gcc | |
LD = $(GCC_BIN)/arm-none-eabi-gcc | |
AR = $(GCC_BIN)/arm-none-eabi-ar | |
OBJCOPY = $(GCC_BIN)/arm-none-eabi-objcopy | |
CFLAGS = -O0 -g -Wall -I.\ | |
-mcpu=cortex-m4 -mthumb \ | |
-mfpu=fpv4-sp-d16 -mfloat-abi=hard \ | |
$(INCLUDES) -DUSE_STDPERIPH_DRIVER | |
LDSCRIPT = scripts/stm32_flash.ld | |
LDFLAGS += -T$(LDSCRIPT) -mthumb -mcpu=cortex-m4 -nostdlib | |
$(BIN): $(ELF) | |
$(OBJCOPY) -O binary $< $@ | |
$(HEX): $(ELF) | |
$(OBJCOPY) -O ihex $< $@ | |
$(ELF): $(OBJECTS) | |
$(LD) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS) | |
$(BUILDDIR)/%.o: %.c | |
mkdir -p $(dir $@) | |
$(CC) -c $(CFLAGS) $< -o $@ | |
$(BUILDDIR)/%.o: %.s | |
mkdir -p $(dir $@) | |
$(CC) -c $(CFLAGS) $< -o $@ | |
flash: $(BIN) | |
st-flash write $(BIN) 0x8000000 | |
clean: | |
rm -rf build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment