2020-12-14 15:21:17 +00:00
|
|
|
TARGET = firmware
|
|
|
|
|
|
|
|
DEBUG = 1
|
|
|
|
OPT = -O0
|
|
|
|
|
|
|
|
BUILD_DIR = build
|
|
|
|
|
|
|
|
C_SOURCES = \
|
|
|
|
Core/Src/main.c \
|
|
|
|
Core/Src/stm32g0xx_it.c \
|
|
|
|
Core/Src/stm32g0xx_hal_msp.c \
|
|
|
|
Core/Src/system_stm32g0xx.c \
|
|
|
|
Core/Src/syscalls.c \
|
|
|
|
Core/Src/sysmem.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_iwdg.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c \
|
2021-07-05 13:08:37 +00:00
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_i2c.c \
|
|
|
|
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_i2c_ex.c
|
2020-12-14 15:21:17 +00:00
|
|
|
|
|
|
|
ASM_SOURCES = \
|
2021-07-05 13:08:37 +00:00
|
|
|
Core/Startup/startup_stm32g031y8yx.s
|
2020-12-14 15:21:17 +00:00
|
|
|
|
|
|
|
PREFIX = arm-none-eabi-
|
|
|
|
CC = $(PREFIX)gcc
|
|
|
|
AS = $(PREFIX)gcc -x assembler-with-cpp
|
|
|
|
CP = $(PREFIX)objcopy
|
|
|
|
SZ = $(PREFIX)size
|
|
|
|
|
|
|
|
CPU = -mcpu=cortex-m0plus
|
|
|
|
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
|
|
|
|
|
|
|
|
C_DEFS = \
|
|
|
|
-DUSE_HAL_DRIVER \
|
|
|
|
-DSTM32G071xx
|
|
|
|
|
|
|
|
C_INCLUDES = \
|
|
|
|
-ICore/Inc \
|
|
|
|
-IDrivers/STM32G0xx_HAL_Driver/Inc \
|
|
|
|
-IDrivers/STM32G0xx_HAL_Driver/Inc/Legacy \
|
|
|
|
-IDrivers/CMSIS/Device/ST/STM32G0xx/Include \
|
|
|
|
-IDrivers/CMSIS/Include
|
|
|
|
|
|
|
|
|
|
|
|
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
|
|
|
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -ggdb3
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
|
|
|
|
|
2021-07-05 13:08:37 +00:00
|
|
|
LDSCRIPT = STM32G031Y8YX_Flash.ld
|
2020-12-14 15:21:17 +00:00
|
|
|
|
|
|
|
LIBS = -lc -lm -lnosys
|
|
|
|
LIBDIR =
|
|
|
|
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
|
|
|
|
|
|
|
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
|
|
|
|
|
|
|
|
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
|
|
|
vpath %.c $(sort $(dir $(C_SOURCES)))
|
|
|
|
|
|
|
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
|
|
|
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
|
|
|
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
|
|
|
$(AS) -c $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
|
|
|
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
|
|
|
$(SZ) $@
|
|
|
|
|
|
|
|
$(BUILD_DIR):
|
|
|
|
mkdir $@
|
|
|
|
|
|
|
|
clean:
|
2021-07-05 13:08:37 +00:00
|
|
|
-rm -rf $(BUILD_DIR)
|
2020-12-14 15:21:17 +00:00
|
|
|
|
|
|
|
-include $(wildcard $(BUILD_DIR)/*.d)
|