ARCH = arm-none-eabi
# Tool definitions
CC = $(ARCH)-gcc
C++ = $(ARCH)-g++
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 -Os --std=gnu99 -fgnu89-inline -mcpu=cortex-m3 -mthumb
CFLAGS += -ffunction-sections -fdata-sections
ASFLAGS =
LDFLAGS = --gc-sections
CPFLAGS =
ODFLAGS = -x --syms
PRFLAGS ?=
# Source files
LINKER_SCRIPT = LPC17xx.ld
CSRCS = startup_LPC17xx.c $(wildcard *.c)
CSRCS += ./source/main.c \
./source/uart.c \
./SDLIB/src/FatFS/ff.c \
./SDLIB/src/FatFS/diskio.c \
./SDLIB/src/FatFS/cc932.c \
OBJS = $(CSRCS:.c=.o) $(ASRCS:.s=.o)
.PHONY: all size clean nuke
all: main.hex
size: main.elf
@$(SIZE) $<
%.hex: %.elf
$Q $(CP) $(CPFLAGS) -O ihex $< ./build/$*.hex
%.bin: %.elf
$Q $(CP) $(CPFLAGS) -O binary $< ./build/$*.bin
main.elf: $(LINKER_SCRIPT) $(OBJS)
$Q $(LD) -Map $(@:.elf=.map) $(LDFLAGS) -T $^ -o $@
$Q $(OD) $(ODFLAGS) $@ > $(@:.elf=.dump)
@$(SIZE) $@
%.o: %.c
@$(CC) -MM $< -MF $*.d -MP
$Q $(CC) -c $(CFLAGS) $< -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
-include $(CSRCS:.c=.d)
run :
/opt/lpc21isp/lpc21isp ./build/main.hex /dev/cu.SLAB_USBtoUART 115200 20000
BT :
/opt/lpc21isp/lpc21isp ./build/main.hex /dev/cu.SLAVE-DevB 115200 2000 |