-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (50 loc) · 2.07 KB
/
Copy pathMakefile
File metadata and controls
73 lines (50 loc) · 2.07 KB
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
# PROJECT DEFINITIONS
CPU = cortex-m3
CHIP = STM32F207xE
EXECUTABLE = main
SOURCES = $(wildcard src/*.c) \
$(wildcard src/*.s) \
$(wildcard FreeRTOS/port/*.c) \
$(wildcard FreeRTOS/*.c)
OBJECTS = $(patsubst %,build/%,$(patsubst %,%.o,$(SOURCES)))
INCLUDE = -Iinclude \
-IFreeRTOS/port \
-IFreeRTOS/include \
-I../STM32Cube_FW_F2_V1.4.0/Drivers/CMSIS/Device/ST/STM32F2xx/Include \
-I../STM32Cube_FW_F2_V1.4.0/Drivers/CMSIS/Include
LD = -T../STM32Cube_FW_F2_V1.4.0/Projects/STM32F207ZG-Nucleo/Templates/SW4STM32/STM32F207xG_Nucleo/STM32F207ZGTx_FLASH.ld
# PIPELINE DEFINITIONS
COMPILE_CMD = arm-none-eabi-gcc
OBJ_COPY_CMD = arm-none-eabi-objcopy
COMPILE_ARG = -Wall -mthumb -Os -std=c99 -g
LINK_ARG = -mlittle-endian -mthumb -Wl,--gc-sections -g
COMP = $(COMPILE_CMD) $(COMPILE_ARG) -mcpu=$(CPU) -D$(CHIP) $(INCLUDE) -c
LINK = $(COMPILE_CMD) $(LINK_ARG) -mcpu=$(CPU) -D$(CHIP) $(LD)
OBJ_COPY = $(OBJ_COPY_CMD) -Oihex
# Make all
.SECONDARY:
all: build_dir $(EXECUTABLE).hex
build_dir:
mkdir -p $(dir $(OBJECTS))
clean:
rm -r build/
rm -f $(EXECUTABLE).elf
rm -f $(EXECUTABLE).hex
# Compile
build/%.c.o: %.c
$(COMP) -o $@ $<
build/%.s.o: %.s
$(COMP) -o $@ $<
# Link
%.elf: $(OBJECTS)
$(LINK) $(OBJECTS) -o $(EXECUTABLE).elf
# Object Copy
%.hex: %.elf
$(OBJ_COPY_CMD) $^ $@
# arm-none-eabi-gcc -Wall -mcpu=cortex-m3 -mlittle-endian -mthumb -I../STM32Cube_FW_F2_V1.4.0/Drivers/CMSIS/Device/ST/STM32F2xx/Include -I../STM32Cube_FW_F2_V1.4.0/Drivers/CMSIS/Include -DSTM32F401xE -Os -c main.c -o main.o
# arm-none-eabi-gcc -mcpu=cortex-m3 -mlittle-endian -mthumb -DSTM32F207xE -T../STM32Cube_FW_F2_V1.4.0/Projects/STM32F207ZG-Nucleo/Templates/SW4STM32/STM32F207xG_Nucleo/STM32F207ZGTx_FLASH.ld -Wl,--gc-sections system.o main.o startup_stm32f207xx.o -o main.elf
# arm-none-eabi-objcopy -Oihex main.elf main.hex
program:
openocd -d0 -f openocd/st_nucleo_f207zg.cfg -c "init;targets;halt;flash write_image erase $(EXECUTABLE).hex;reset run;shutdown"
debug:
openocd -d0 -f openocd/st_nucleo_f207zg.cfg