first commit

This commit is contained in:
fewikay committed 2026-10-16 13:08:06 +02:00
commit 92cbe97616
1978 files changed
+1688498

No files matched your search

+205
View File
@@ -0,0 +1,205 @@
##########################################################################################################################
# Author: Thorsten Kimmel
# Project: DHBW-Embedded-Systems-TES
##########################################################################################################################
# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
# 2026-09-25 - first version
# ------------------------------------------------
######################################
# target
######################################
TARGET = Stepper-H7-CM7
MK_CORE := M7
LDFLAGS :=
CFLAGS :=
C_SOURCES :=
C_INCLUDES :=
ASM_SOURCES :=
C_DEFS :=
AS_DEFS :=
# cpu
CPU = -mcpu=cortex-m7
#######################################
# additional common includes
#######################################
include ../common.mk
######################################
# building variables
######################################
# debug build? 1 = -g, 2 = -g3
DEBUG = 2
# optimization
OPT = -O0
# stack size limit of single function (warning)
SLIMIT = 2048
#######################################
# paths
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
# C sources
C_SOURCES += Core/Src/main.c \
Core/Src/newlib_abs.c \
Core/Src/stm32h7xx_hal_msp.c \
Core/Src/stm32h7xx_it.c \
$(wildcard Core/Src/Console/*.c) \
$(wildcard Core/Src/IPC/*.c) \
$(wildcard Core/Src/Spindle/*.c) \
$(wildcard Core/Src/Stepper/*.c) \
$(wildcard OPENAMP/*.c) \
# ASM sources
ASM_SOURCES += Core/Startup/startup_stm32h755zitx.s
#######################################
# CFLAGS
#######################################
# fpu
# NONE for Cortex-M0/M0+/M3
# float-abi
FPU = -mfpu=fpv5-d16
FLOAT-ABI = -mfloat-abi=hard
# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# macros for gcc
# AS defines
AS_DEFS +=
# C defines
C_DEFS += -DCORE_CM7 \
-DDEBUG \
-DVIRTIO_MASTER_ONLY
# AS includes
AS_INCLUDES +=
# C includes
C_INCLUDES += -ICore/Inc \
-ICore/Inc/Console \
-ICore/Inc/IPC \
-ICore/Inc/Spindle \
-ICore/Inc/Stepper \
-IOPENAMP
# compile gcc flags
ASFLAGS += $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -fstack-usage -Wstack-usage=$(SLIMIT) -Wno-unused-parameter -Wall -Wextra -Wundef -Wshadow -fno-common -fdata-sections -ffunction-sections
CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -fstack-usage -Wstack-usage=$(SLIMIT) -Wno-unused-parameter -Wall -Wextra -Wundef -Wshadow -fno-common -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
ifeq ($(DEBUG), 2)
CFLAGS += -g3 -gdwarf-2
endif
ifeq ($(OS),Windows_NT)
EXEPOSTFIX = .exe
else
EXEPOSTFIX =
endif
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32H755ZITX_FLASH.ld
# libraries
LIBS = -lc -lm -lnosys
LIBDIR =
# -specs=nano.specs
LDFLAGS += -lc -lrdimon -u _printf_float -Wa,-adhln -g $(MCU) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref,--gc-sections
# default action: build all
.PHONY: all
all: $(BUILD_DIR)/$(TARGET).elf #$(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin $(BUILD_DIR)/$(TARGET).S
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
@echo " $(MK_CORE)-CC $<"
@$(CC)$(EXEPOSTFIX) -c $(CFLAGS) -MMD -MP -MF"$(@:%.o=%.d)" $< -o $@
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
@echo " $(MK_CORE)-AS $<"
@$(AS)$(EXEPOSTFIX) -c $(CFLAGS) $< -o $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
@echo " $(MK_CORE)-ELF $(BUILD_DIR)/$(TARGET).elf"
@$(CC)$(EXEPOSTFIX) $(OBJECTS) $(LDFLAGS) -o $@
@$(SZ)$(EXEPOSTFIX) $@
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
@echo " $(MK_CORE)-OBJ $<"
@$(HEX)$(EXEPOSTFIX) $< $@
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
@echo " $(MK_CORE)-OBJ $<"
@$(BIN)$(EXEPOSTFIX) $< $@
$(BUILD_DIR)/%.S: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
@echo " $(MK_CORE)-OBJ $<"
$(OD)$(EXEPOSTFIX) -l -m armv7e-m --disassemble-all $< > $@
$(BUILD_DIR):
mkdir $@
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)
#######################################
# clean up
#######################################
setup:
@echo 'installation only works on linux and on linux subsystem for windows 10'
@sudo apt-get update
@sudo apt-get install clang clang-tools gcc-multilib g++-multilib build-essential gcc-arm-none-eabi binutils-arm-none-eabi -y
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)
include ../sca.mk
# *** EOF ***