-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
56 lines (40 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
CC=arm-none-eabi-gcc
override CFLAGS+=-Wall -Wextra -std=c99 -fno-common -Os -mthumb -mcpu=cortex-m7 -DSTM32H743xx -g -Isrc -Isrc/STM32H7xx_Nucleo_144
LD=arm-none-eabi-gcc
LDFLAGS=-TCANT.ld -nostartfiles -Wl,-Map=build/flash.map -mcpu=cortex-m7 -mthumb --specs=nosys.specs
AS=arm-none-eabi-as
ASFLAGS=-g
ODIR=build
LDIR=lib
SRCS=src
PERIPH_ODIR=STM32H7xx_Nucleo_144
_OBJS=startup_stm32h743xx.o main.o system_stm32h7xx.o stm32h7xx_it.o gpio.o can.o menu.o usart.o bsp.o
_PERIPH_OBJS=stm32h7xx_hal_cortex.o stm32h7xx_hal.o stm32h7xx_hal_rcc.o stm32h7xx_hal_rcc_ex.o stm32h7xx_hal_gpio.o stm32h7xx_hal_uart_ex.o stm32h7xx_hal_uart.o stm32h7xx_hal_dma.o stm32h7xx_hal_tim.o stm32h7xx_hal_tim_ex.o stm32h7xx_nucleo_144.o
PERIPH_OBJS = $(patsubst %,$(PERIPH_ODIR)/%,$(_PERIPH_OBJS))
_OBJS += $(PERIPH_OBJS)
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
all: CANT
flash_prebuilt: firmware/CANT.elf
scripts/flash_prebuilt.py
flash: CANT
scripts/flash.py
debug:
scripts/debug.py
flash_and_debug: CANT
scripts/flash_and_debug.py
$(ODIR)/startup_stm32h743xx.o: $(SRCS)/startup_stm32h743xx.s
@mkdir -p $(@D)
$(AS) src/startup_stm32h743xx.s -o $@ $(ASFLAGS)
$(ODIR)/%.o: $(SRCS)/%.c
@mkdir -p $(@D)
$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR)/$(PERIPH_ODIR)/%.o: $(SRCS)/$(PERIPH_ODIR)/src/%.c
$(CC) -c -o $@ $< $(CFLAGS)
CANT: $(OBJS)
$(LD) $(OBJS) $(LDFLAGS) $(CFLAGS) -o $(ODIR)/CANT.elf
arm-none-eabi-objcopy -Obinary $(ODIR)/CANT.elf $(ODIR)/CANT.bin
cp $(ODIR)/CANT.elf firmware/CANT.elf
cp $(ODIR)/CANT.bin firmware/CANT.bin
.PHONY: clean
clean:
rm -f $(ODIR)/CANT.* $(ODIR)/STM32H7xx_Nucleo_144/*.o $(ODIR)/*.o *~ core $(INCDIR)/*~ firmware/* $(ODIR)/flash.map