TARGET=main all: burn PREFIX=arm-none-eabi CC=$(PREFIX)-gcc LD=$(PREFIX)-gcc AS=$(PREFIX)-as CP=$(PREFIX)-objcopy OD=$(PREFIX)-objdump OBJCOPYFLAGS = -O binary BIN=$(CP) -O ihex #XXX TODO: Is _LD or use _ld_vl.s? DEFS = -DSTM32F10X_LD -DSTM32F10X -DHSE_VALUE=24000000 -DSYSCLK_FREQ_HSE STARTUP = lib/startup_stm32f10x_ld.s MCU = cortex-m4 MCFLAGS = -mcpu=$(MCU) -mthumb -mlittle-endian -mthumb-interwork STM32_INCLUDES = -Ilib -I. -ISTM32F10x_StdPeriph_Driver/inc OPTIMIZE = -Ofast -mfloat-abi=hard -mfpu=fpv4-sp-d16 -flto -ffunction-sections -fdata-sections -Wl,--relax CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) \ -I. \ $(STM32_INCLUDES) \ -I../embeddedcommon \ -Wl,-T,lib/stm32f103.ld CFLAGS+=-DDEBUG CFLAGS+=-I. AFLAGS = $(MCFLAGS) SRC = main.c \ lib/system_stm32f10x.c \ lib/systems.c \ lib/core_cm3.c \ main.c \ STM32F10x_StdPeriph_Driver/src/stm32f10x_dma.c \ STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c \ STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c \ burn : $(TARGET).bin openocd -f flash.cfg #-d3 terminal : openocd -f terminal.cfg $(TARGET).bin : $(TARGET).out $(CP) $(OBJCOPYFLAGS) $< $@ $(TARGET).hex: $(EXECUTABLE) $(CP) -O ihex $^ $@ $(TARGET).out : $(SRC) $(STARTUP) $(CC) $(CFLAGS) $^ -lm -lc -lnosys -o $@ clean: rm -f $(TARGET).lst $(TARGET).out $(TARGET).hex $(TARGET).bin $(TARGET).map $(EXECUTABLE)