aboutsummaryrefslogtreecommitdiff
path: root/stm32f091/makefile
blob: fa289a903bb8f7bb00a6c821112d2f7779c0200f (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
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
OC = arm-none-eabi-objcopy
RM = rm -f

TARGET = main

SHARED_FLAGS += -g
SHARED_FLAGS += -D STM32F091xC
SHARED_FLAGS += -Wall
SHARED_FLAGS += -Wextra
# SHARED_FLAGS += -Wno-register
SHARED_FLAGS += -Wa,--defsym,CALL_ARM_SYSTEM_INIT=1
# SHARED_FLAGS += -I/usr/arm-none-eabi/include/
SHARED_FLAGS += -I./lib/STM32-base-STM32Cube/HAL/STM32F0xx/inc
SHARED_FLAGS += -I./lib/STM32-base-STM32Cube/CMSIS/ARM/inc
SHARED_FLAGS += -I./lib/STM32-base-STM32Cube/CMSIS/STM32F0xx/inc
SHARED_FLAGS += -I./lib/STM32-base/startup
SHARED_FLAGS += -I./lib/FreeRTOS-Kernel/include
SHARED_FLAGS += -I./lib/FreeRTOS-Kernel/portable/GCC/ARM_CM0/
SHARED_FLAGS += -I.
SHARED_FLAGS += -ffunction-sections
SHARED_FLAGS += -fdata-sections
SHARED_FLAGS += -mlittle-endian
SHARED_FLAGS += -mthumb
SHARED_FLAGS += -specs=nosys.specs
SHARED_FLAGS += -fno-exceptions
SHARED_FLAGS += -fno-unwind-tables
SHARED_FLAGS += -Wl,-L./lib/STM32-base/linker,-T./lib/STM32-base/linker/STM32F0xx/STM32F091xC.ld
SHARED_FLAGS += -mcpu=cortex-m0
SHARED_FLAGS += -march=armv6-m

CFLAGS += $(SHARED_FLAGS)
LFLAGS += $(SHARED_FLAGS)
AFLAGS += $(SHARED_FLAGS)

OBJS += $(patsubst %.c,%.o, $(wildcard *.c))
OBJS += lib/FreeRTOS-Kernel/croutine.o \
        lib/FreeRTOS-Kernel/event_groups.o \
        lib/FreeRTOS-Kernel/list.o \
        lib/FreeRTOS-Kernel/queue.o \
        lib/FreeRTOS-Kernel/stream_buffer.o \
        lib/FreeRTOS-Kernel/tasks.o \
        lib/FreeRTOS-Kernel/timers.o \
        lib/FreeRTOS-Kernel/portable/GCC/ARM_CM0/port.o \
        lib/FreeRTOS-Kernel/portable/MemMang/heap_4.o
OBJS += lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_gpio.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_cortex.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_flash.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2c.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_i2s.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_pwr.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_rtc.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_uart.o \
        lib/STM32-base-STM32Cube/HAL/STM32F0xx/src/stm32f0xx_hal_usart.o

OBJS += ./lib/STM32-base/startup/STM32F0xx/STM32F091xC.o
OBJS += ./lib/STM32-base-STM32Cube/CMSIS/STM32F0xx/src/system_stm32f0xx.o

.PHONY: flash clean

$(TARGET).bin: $(TARGET).elf
	$(OC) -O binary $< $@

%.o: %.s
	$(CC) -c $(AFLAGS) $< -o $@

%.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@

$(TARGET).elf: $(OBJS)
	$(LD) $(LFLAGS) $^ -o $@

flash: $(TARGET).bin
	st-flash write $(TARGET).bin 0x08000000

compile_commands: clean
	compiledb make
	../scripts/compiledb-full-path-mingw.sh compile_commands.json

clean:
	$(RM) $(TARGET).bin $(TARGET).elf $(OBJS)