-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
72 lines (55 loc) · 1.37 KB
/
Makefile
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
SRC=host/main.c loader.c arm/fault.c
ASRC=arm/startup_ARMCM4.S
TARGET=elfloader
CROSS=arm-none-eabi-
CC=$(CROSS)gcc
AS=$(CROSS)gcc
LD=$(CROSS)gcc
CFLAGS=-O0 -ggdb3 -mcpu=cortex-m3 -mthumb \
-flto -ffunction-sections -fdata-sections \
-Iarm/CMSIS/include -I. -Ihost
LDFLAGS=--specs=rdimon.specs \
-g \
-Wl,--start-group -lgcc -lc -lc -lm -lrdimon -Wl,--end-group \
-Wl,--gc-sections \
-L ldscripts -T gcc.ld \
-mcpu=cortex-m4 -mthumb
OBJS=$(SRC:.c=.o) $(ASRC:.S=.o)
DEPS=$(SRC:.c=.d)
all: $(TARGET)
-include $(DEPS)
%.o: %.c
@echo " CC $<"
@$(CC) -MMD $(CFLAGS) -o $@ -c $<
%.o: %.S
@echo " AS $<"
@$(AS) $(CFLAGS) -o $@ -c $<
.PHONY: clean all debug app
$(TARGET): $(OBJS)
@echo " LINK $@"
@$(LD) -o $@ $(LDFLAGS) $^
app:
@$(MAKE) -C app clean all list
app-cpp:
@$(MAKE) -C app-cpp clean all list
clean:
@echo " CLEAN"
@rm -fR $(OBJS) $(DEPS) $(TARGET)
debug: $(TARGET) app app-cpp
@echo " Debuggin..."
@$(CROSS)gdb $(TARGET) \
-ex 'target remote :3333' \
-ex 'monitor reset halt' \
-ex 'load' \
-ex 'monitor arm semihosting enable'
run: $(TARGET) app app-cpp
@echo " Debuggin..."
@$(CROSS)gdb $(TARGET) \
-ex 'target remote :3333' \
-ex 'monitor reset halt' \
-ex 'load' \
-ex 'monitor arm semihosting enable' \
-ex 'continue'
oocd: app app-cpp
@echo " Launch OpenOCD for stm32f4discovery"
openocd -f board/stm32f4discovery.cfg -l oocd.log