Skip to content

Commit 6cb7fc4

Browse files
committed
added a makefile, testing it
1 parent 33c67fb commit 6cb7fc4

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build STM32 Project
22

33
on:
44
push:
5-
branches: ["*"]
5+
branches: ["master", "workflows"]
66
pull_request:
7-
branches: ["*"]
7+
branches: ["master", "workflows"]
88

99
jobs:
1010
build:

makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
PROJECT := Team2_DART_Firmware
2+
BUILD_DIR := build
3+
SRC_DIR := Src
4+
INC_DIR := Inc
5+
6+
CC := arm-none-eabi-gcc
7+
CP := arm-none-eabi-objcopy
8+
SZ := arm-none-eabi-size
9+
10+
CPU := -mcpu=cortex-m7
11+
FPU := -mfpu=fpv5-d16
12+
FLOAT_ABI := -mfloat-abi=hard
13+
MCU_FLAGS := $(CPU) -mthumb $(FPU) $(FLOAT_ABI)
14+
15+
CFLAGS := $(MCU_FLAGS) -g -O2 -Wall -ffunction-sections -fdata-sections --specs=nano.specs -static -fno-common
16+
CDEFS := -DSTM32H743xx -DUSE_HAL_DRIVER
17+
CINCLUDES := -I$(INC_DIR)
18+
19+
LDSCRIPT := STM32H743VITX_FLASH.ld
20+
LDFLAGS := $(MCU_FLAGS) -T$(LDSCRIPT) -Wl,-Map=$(BUILD_DIR)/$(PROJECT).map,--gc-sections
21+
22+
C_SOURCES := $(wildcard $(SRC_DIR)/*.c)
23+
OBJ_FILES := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SOURCES))
24+
25+
all: $(BUILD_DIR)/$(PROJECT).elf
26+
27+
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | prepare_build
28+
@echo "[CC] $<"
29+
mkdir -p $(dir $@)
30+
$(CC) $(CFLAGS) $(CDEFS) $(CINCLUDES) -c $< -o $@
31+
32+
$(BUILD_DIR)/$(PROJECT).elf: $(OBJ_FILES)
33+
@echo "[LD] $@"
34+
$(CC) $^ $(LDFLAGS) -o $@
35+
$(SZ) $@
36+
37+
prepare_build:
38+
mkdir -p $(BUILD_DIR)
39+
40+
clean:
41+
rm -rf $(BUILD_DIR)
42+
43+
.PHONY: all clean prepare_build

0 commit comments

Comments
 (0)