-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (49 loc) · 1.63 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
# variable to store cross compiler name
CC=arm-none-eabi-gcc
# machine or target name
MACH=cortex-m0
# compiler flags:
# -c: to only create objects files and not link them i.e. do not run the linker
# -O0: No optimizations
CFLAGS= -c -mcpu=$(MACH) -mthumb -std=gnu11 -Wall -O0
# Linker flags
# -Wl is a special flag that lets the compiler know that following is a linker specific command
# -Map=final.map: allows linker to create a memory map file called final.map
LDFLAGS= -nostdlib -T stm32f0_ls.ld -Wl,-Map=final.map
# default port for serial comm
port= COM7
# command:<targets>
# 'make all' will build all the given targets
# currently we have only one target
all: main.o gpio.o stm32f0_startup.o systick.o usart.o kernel.o final.elf
# NOTES ON SYNTAX etc.
# target: dependency
# shorthands:
# $^: dependency
# $@: target
# syntax transformations: main.c -o main.o => $^ -o $@ => -o $@ $^
# run compiler
gpio.o:gpio/gpio.c
$(CC) $(CFLAGS) -o $@ $^
main.o:main.c
$(CC) $(CFLAGS) -o $@ $^
stm32f0_startup.o:stm32f0_startup.c
$(CC) $(CFLAGS) -o $@ $^
systick.o:systick.c
$(CC) $(CFLAGS) -o $@ $^
usart.o:uart/usart.c
$(CC) $(CFLAGS) -o $@ $^
kernel.o:kernel/kernel.c
$(CC) $(CFLAGS) -o $@ $^
# build target from linker
final.elf: main.o gpio.o systick.o usart.o kernel.o stm32f0_startup.o
$(CC) $(LDFLAGS) -o $@ $^
# load command to download target on board
load:
# wt allows running commands in a new terminal window(on windows only)
wt openocd -f board_cfg_files/stm32f0discovery.cfg
wt putty.exe -load "openocd"
# wt putty.exe -load "serial"
# wt putty.exe -serial $(port) -sercfg 9600,8,n,1,N
clean:
rm -rf *.o *.elf