forked from jeremyherbert/stm32-templates
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
69 lines (44 loc) · 1.49 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
# put your *.o targets here, make should handle the rest!
#SRCS = main.c stm32f4xx_it.c system_stm32f4xx.c
SRCS = main.c system.c
# all the files will be generated with this name (main.elf, main.bin, main.hex, etc)
PROJ_NAME=main
# Put your stlink folder here so make burn will work.
STLINK=/mnt/share/Programming/embedded/stm32/stlink
# that's it, no need to change anything below this line!
###################################################
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
CFLAGS = -g -Wall -Tstm32_flash.ld
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
###################################################
vpath %.c src
vpath %.a lib
ROOT=$(shell pwd)
CFLAGS += -Iinc -Ilib -Ilib/inc
CFLAGS += -Ilib/inc/core -Ilib/inc/peripherals
SRCS += lib/startup_stm32f4xx.s # add startup file to build
OBJS = $(SRCS:.c=.o)
###################################################
.PHONY: lib proj
all: lib proj
again: clean all
# Flash the STM32F4
burn:
$(STLINK)/flash/st-flash write $(PROJ_NAME).bin 0x8000000
# Create tags; assumes ctags exists
ctags:
ctags -R --exclude=*cm0.h --exclude=*cm3.h .
lib:
$(MAKE) -C lib
proj: $(PROJ_NAME).elf
$(PROJ_NAME).elf: $(SRCS)
$(CC) $(CFLAGS) $^ -o $@ -Llib -lstm32f4
$(OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin
clean:
rm -f *.o *.i
rm -f $(PROJ_NAME).elf
rm -f $(PROJ_NAME).hex
rm -f $(PROJ_NAME).bin