blob: c6673a97bd2e3f6eb3eb30bb2adba5b26401d8de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#/* 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=i2stest
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 -Werror -O0 --std=gnu99 -fgnu89-inline -mcpu=cortex-m3 -mthumb
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -I${DRV} -I${LPC}
ASFLAGS =
LDFLAGS = --gc-sections
STDLIB_LDFLAGS =
CPFLAGS =
ODFLAGS = -x --syms
PRFLAGS ?=
# Source files
LINKER_SCRIPT = ${LPC}/LPC17xx.ld
CSRCS = \
${LPC}/system_LPC17xx.c \
${LPC}/startup_LPC17xx.c \
${DRV}/led.c \
${DRV}/cli.c \
${DRV}/uart.c \
${DRV}/i2s.c \
../test.c
CSRCS += ${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'
flash: $(EXECNAME)
$(CP) -O binary $(EXECNAME) $(PROJ).bin
../../fix-lpcchecksum $(PROJ).bin
openocd -f ../../openocd.cfg \
-c 'flash write_image erase $(PROJ).bin' \
-c 'verify_image $(PROJ).bin' \
-c 'reset run' || (sleep 1; openocd -f ../../openocd.cfg \
-c 'flash write_image erase $(PROJ).bin' \
-c 'verify_image $(PROJ).bin' \
-c 'reset run')
-include $(CSRCS:.c=.d)
|