Skip to content

Instantly share code, notes, and snippets.

@pidpawel pidpawel/Makefile_cmsis
Last active Aug 29, 2015

Embed
What would you like to do?
TARGET=main
ADDITIONAL=
LIBS=src/startup_stm32f10x_md.o src/core_cm3.o src/system_stm32f10x.o
PERIPH=src/stm32f10x_adc.o src/stm32f10x_bkp.o src/stm32f10x_can.o src/stm32f10x_cec.o src/stm32f10x_crc.o src/stm32f10x_dac.o src/stm32f10x_dbgmcu.o src/stm32f10x_dma.o src/stm32f10x_exti.o src/stm32f10x_flash.o src/stm32f10x_fsmc.o src/stm32f10x_gpio.o src/stm32f10x_i2c.o src/stm32f10x_iwdg.o src/stm32f10x_pwr.o src/stm32f10x_rcc.o src/stm32f10x_rtc.o src/stm32f10x_sdio.o src/stm32f10x_spi.o src/stm32f10x_tim.o src/stm32f10x_usart.o src/stm32f10x_wwdg.o
OBJS=$(LIBS) $(PERIPH) $(ADDITIONAL) $(TARGET).o
LD_SCRIPT=misc/stm32_flash.ld
INCPATH=inc/
OPTIMIZE = O2
TARGET_CPU=cortex-m3
CFLAGS = -$(OPTIMIZE) -g2
CFLAGS += -Wall
CFLAGS += -Wno-unused-result
CFLAGS += -Wno-write-strings
#CFLAGS += -Wnoimplicit-function-declaration
CFLAGS += -std=gnu99
CFLAGS += -mthumb -mcpu=$(TARGET_CPU)
CFLAGS += -Wl,--no-gc-sections
CFLAGS += -fno-builtin-printf -Wno-main
CFLAGS += -I$(INCPATH)
CFLAGS += -DSTM32F10X_MD
CFLAGS += -DUSE_STDPERIPH_DRIVER
CFLAGS += -I`pwd`
LDFLAGS = $(CFLAGS)
LDFLAGS += -nodefaultlibs
LDFLAGS += -nostartfiles
TOOLCHAIN_PREFIX=arm-none-eabi-
CC=$(TOOLCHAIN_PREFIX)gcc
LD=$(TOOLCHAIN_PREFIX)gcc
OBJCOPY=$(TOOLCHAIN_PREFIX)objcopy
OBJDUMP=$(TOOLCHAIN_PREFIX)objdump
all: $(TARGET).elf $(TARGET).bin $(TARGET).hex
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.S
$(CC) $(CFLAGS) -c $< -o $@
$(TARGET).elf: $(OBJS) $(STARTUP)
$(LD) $(LDFLAGS) -T$(LD_SCRIPT) $^ -o $@
%.hex: %.elf
$(OBJCOPY) -O ihex $< $@
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
dump: $(TARGET).elf
$(OBJDUMP) -d -S $<
dump_all: $(TARGET).elf
$(OBJDUMP) -D $<
clean:
rm -f $(OBJS) $(STARTUP) $(TARGET).elf $(TARGET).hex $(TARGET).bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.