diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-06-02 18:25:46 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-06-02 18:25:46 +0200 |
commit | b2df34e622ddee5d51beb1e9e93d4ecbb1745e55 (patch) | |
tree | 88822c96df5c98c74130ae532936f5d2f034c5b6 /firmware/Makefile | |
parent | f547775b5a8c60f655bcdb0d10bbcdb1417f3890 (diff) |
Initial experiments with SPI.
Diffstat (limited to 'firmware/Makefile')
-rw-r--r-- | firmware/Makefile | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/firmware/Makefile b/firmware/Makefile new file mode 100644 index 0000000..ef9b0e1 --- /dev/null +++ b/firmware/Makefile @@ -0,0 +1,97 @@ +#/* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED +# * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF +# * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. +# * THE AUTHORS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR +# * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. USE IT AT YOUR OWN RISK */ + +ARCH = arm-none-eabi +top_srcdir=${PWD} +LPC=${top_srcdir}/lpc17xx +DRV=${top_srcdir}/drivers +SRC=${top_srcdir}/src + +PROJ=p2m +EXECNAME=$(PROJ).elf + +# Tool definitions +CC = $(ARCH)-gcc +LD = $(ARCH)-ld +AR = $(ARCH)-ar +AS = $(ARCH)-as +CP = $(ARCH)-objcopy +OD = $(ARCH)-objdump +SIZE = $(ARCH)-size +RM = rm +Q = # @./quiet "$@" + +# Flags +CFLAGS = -W -Wall -O0 --std=gnu99 -fgnu89-inline -mcpu=cortex-m3 -mthumb +CFLAGS += -ffunction-sections -fdata-sections +CFLAGS += -I${LPC} -I${DRV} +ASFLAGS = +LDFLAGS = --gc-sections + +STDLIB_LDFLAGS = +#STDLIB_LDFLAGS += -L/home/deva/lib/arm/arm-toolchain/lib/gcc/arm-none-eabi/4.6.2/ +#STDLIB_LDFLAGS += -L/home/deva/lib/arm/arm-toolchain/arm-none-eabi/lib/ +#STDLIB_LDFLAGS += -lc -lgcc + +CPFLAGS = +ODFLAGS = -x --syms +PRFLAGS ?= + +# Source files +LINKER_SCRIPT = ${LPC}/LPC17xx.ld +CSRCS = \ + ${LPC}/startup_LPC17xx.c \ + $(wildcard ${CMSIS}/*.c) \ + $(wildcard ${LPC}/*.c) \ + $(wildcard ${DRV}/*.c) \ + $(wildcard ${SRC}/*.c) +CSRCS += ${SRC}/${PROJ}.c +ASRCS = + + +OBJS = $(CSRCS:.c=.o) $(ASRCS:.s=.o) + +.PHONY: all size clean nuke + +all: ${PROJ}.bin ${PROJ}.hex + +size: ${PROJ}.elf + @$(SIZE) $< + +%.hex: %.elf + $Q $(CP) $(CPFLAGS) -O ihex $< $*.hex + +%.bin: %.elf + $Q $(CP) $(CPFLAGS) -O binary $< $*.bin + +${PROJ}.elf: $(LINKER_SCRIPT) $(OBJS) + $Q $(LD) -Map $(@:.elf=.map) $(LDFLAGS) -T $^ -o $@ $(STDLIB_LDFLAGS) + $Q $(OD) $(ODFLAGS) $@ > $(@:.elf=.dump) + @$(SIZE) $@ + +%.o: %.c + @$(CC) -MM $< -MF $*.d -MP + $Q $(CC) -c $(CFLAGS) $< -o $@ + +%.o: %.S + $Q $(AS) $(ASFLAGS) $< -o $@ + +clean: + @-$(RM) -f *.elf + @-\ +for D in "." "**"; do \ + $(RM) -f $$D/*.o $$D/*.d $$D/*.lst $$D/*.dump $$D/*.map; \ +done + +nuke: clean + -$(RM) -f *.hex *.bin + +.PHONY : flash +flash: $(EXECNAME) + $(CP) -O ihex $(EXECNAME) $(PROJ).hex + openocd -f openocd.cfg -c 'flash write_image erase $(PROJ).hex' -c 'verify_image $(PROJ).hex' -c 'reset run' + +-include $(CSRCS:.c=.d) |