blob: ec9fcd69cbf9ac88231703ff8c36002191af20ca (
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
|
# setup
COMPILE_OPTS = -mcpu=cortex-m3 -mthumb -Wall -g -O0
INCLUDE_DIRS = -I . -I lib/inc
LIBRARY_DIRS = -L lib
CC = arm-none-eabi-gcc
CFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS)
CXX = arm-none-eabi-g++
CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS)
AS = arm-none-eabi-gcc
ASFLAGS = $(COMPILE_OPTS) -c
LD = arm-none-eabi-gcc
LDFLAGS = -Wl,--gc-sections,-Map=$@.map,-cref,-u,Reset_Handler $(INCLUDE_DIRS) $(LIBRARY_DIRS) -T stm32.ld
OBJCP = arm-none-eabi-objcopy
OBJCPFLAGS = -O binary
AR = arm-none-eabi-ar
ARFLAGS = cr
MAIN_OUT = main
MAIN_OUT_ELF = $(MAIN_OUT).elf
MAIN_OUT_BIN = $(MAIN_OUT).bin
# all
all: $(MAIN_OUT_ELF) $(MAIN_OUT_BIN)
# main
$(MAIN_OUT_ELF): main.o stm32f10x_it.o lib/libstm32.a
$(LD) $(LDFLAGS) main.o stm32f10x_it.o lib/libstm32.a --output $@
$(MAIN_OUT_BIN): $(MAIN_OUT_ELF)
$(OBJCP) $(OBJCPFLAGS) $< $@
# flash
# this is key, copy the .elf file under a new name into the jtag dir
# run openocd, and load the chip all in one step.
flash: $(MAIN_OUT)
@cp $(MAIN_OUT_ELF) jtag/flash
@cd jtag; openocd -f flash.cfg
# @rm jtag/flash
# libstm32.a
LIBSTM32_OUT = lib/libstm32.a
LIBSTM32_OBJS = \
lib/src/stm32f10x_adc.o \
lib/src/stm32f10x_bkp.o \
lib/src/stm32f10x_can.o \
lib/src/stm32f10x_dac.o \
lib/src/stm32f10x_dma.o \
lib/src/stm32f10x_exti.o \
lib/src/stm32f10x_flash.o \
lib/src/stm32f10x_gpio.o \
lib/src/stm32f10x_i2c.o \
lib/src/stm32f10x_iwdg.o \
lib/src/stm32f10x_lib.o \
lib/src/stm32f10x_nvic.o \
lib/src/stm32f10x_pwr.o \
lib/src/stm32f10x_rcc.o \
lib/src/stm32f10x_rtc.o \
lib/src/stm32f10x_spi.o \
lib/src/stm32f10x_systick.o \
lib/src/stm32f10x_tim.o \
lib/src/stm32f10x_usart.o \
lib/src/stm32f10x_wwdg.o
$(LIBSTM32_OUT): $(LIBSTM32_OBJS)
$(AR) $(ARFLAGS) $@ $(LIBSTM32_OBJS)
$(LIBSTM32_OBJS): stm32f10x_conf.h
clean:
-rm *.o lib/src/*.o $(LIBSTM32_OUT) $(MAIN_OUT_ELF) $(MAIN_OUT_BIN)
|