1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-20 23:52:15 +00:00
stmbl/stm32f303/Makefile

278 lines
7.5 KiB
Makefile
Raw Permalink Normal View History

2017-01-05 16:13:11 +00:00
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
#
2017-01-14 03:36:21 +00:00
OPT = -O3 -flto
2017-01-05 16:13:11 +00:00
# OPT = -O1 # for debugging
# Object files directory
# Warning: this will be removed by make clean!
#
OBJDIR = obj_hvf3
# Target file name (without extension)
TARGET = $(OBJDIR)/hvf3
# Define all C source files (dependencies are generated automatically)
2017-02-18 22:24:38 +00:00
INCDIRS += stm32f303/inc
2017-01-05 16:13:11 +00:00
SOURCES += stm32f303/src/main.c
SOURCES += stm32f303/src/adc.c
SOURCES += stm32f303/src/dac.c
SOURCES += stm32f303/src/opamp.c
SOURCES += stm32f303/src/stm32f3xx_hal_msp.c
SOURCES += stm32f303/src/tim.c
SOURCES += stm32f303/src/stm32f3xx_it.c
SOURCES += stm32f303/src/usb_device.c
SOURCES += stm32f303/src/usbd_cdc_if.c
SOURCES += stm32f303/src/usbd_conf.c
SOURCES += stm32f303/src/usbd_desc.c
2017-01-18 13:38:39 +00:00
SOURCES += stm32f303/src/version.c
2017-01-05 16:13:11 +00:00
2017-02-26 20:47:18 +00:00
SOURCES += stm32f303/src/hal_tbl.c
2017-07-01 00:48:57 +00:00
2017-07-17 17:46:46 +00:00
CFLAGS += -DHAL_MAX_CTX=1024
2017-07-01 00:48:57 +00:00
COMPS += stm32f303/src/comps/hv.c
COMPS += stm32f303/src/comps/hvdc.c
COMPS += stm32f303/src/comps/io.c
COMPS += stm32f303/src/comps/ls.c
COMPS += stm32f303/src/comps/enc.c
COMPS += shared/comps/sim.c
COMPS += shared/comps/term.c
COMPS += shared/comps/curpid.c
COMPS += shared/comps/svm.c
COMPS += shared/comps/dq.c
COMPS += shared/comps/idq.c
# COMPS += shared/comps/rev.c
# COMPS += shared/comps/vel.c
# COMPS += shared/comps/hal_test.c
# COMPS += shared/comps/dc.c
# COMPS += shared/comps/ypid.c
SOURCES += $(COMPS)
2017-02-26 20:47:18 +00:00
2017-01-10 08:48:07 +00:00
INCDIRS += shared
SOURCES += shared/ringbuf.c
SOURCES += shared/crc8.c
2017-02-03 23:48:20 +00:00
SOURCES += shared/crc16.c
2017-01-10 08:48:07 +00:00
SOURCES += shared/angle.c
2017-04-13 16:02:32 +00:00
SOURCES += shared/hal.c
2017-04-15 18:54:21 +00:00
SOURCES += shared/commands.c
2017-04-12 02:05:46 +00:00
#SOURCES += shared/hal_term.c
2017-01-05 16:13:11 +00:00
#USB Driver
USB_DEVICE_DIR = lib/STM32_USB_Device_Library-2.4.2
2017-01-05 16:13:11 +00:00
#USB class
INCDIRS += $(USB_DEVICE_DIR)/Class/CDC/Inc/
SOURCES += $(USB_DEVICE_DIR)/Class/CDC/Src/usbd_cdc.c
2017-01-05 16:13:11 +00:00
#USB core
INCDIRS += $(USB_DEVICE_DIR)/Core/Inc/
SOURCES += $(USB_DEVICE_DIR)/Core/Src/usbd_core.c
SOURCES += $(USB_DEVICE_DIR)/Core/Src/usbd_ctlreq.c
SOURCES += $(USB_DEVICE_DIR)/Core/Src/usbd_ioreq.c
2017-01-05 16:13:11 +00:00
#CMSIS
CPPFLAGS += -DSTM32F303xC
INCDIRS += lib/CMSIS/Include/
INCDIRS += lib/CMSIS/Device/ST/STM32F3xx/Include/
SOURCES += lib/CMSIS/Device/ST/STM32F3xx/Source/Templates/gcc/startup_stm32f303xc.s
SOURCES += lib/CMSIS/Device/ST/STM32F3xx/Source/Templates/system_stm32f3xx.c
#stm32f3 HAL Driver
HAL_DRV_DIR = lib/STM32F3xx_HAL_Driver/
INCDIRS += $(HAL_DRV_DIR)/Inc
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_adc.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_adc_ex.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_cortex.c
2017-06-02 18:41:21 +00:00
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_crc.c
2017-01-19 01:24:59 +00:00
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_dac.c
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_dac_ex.c
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_dma.c
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_flash.c
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_flash_ex.c
2017-01-05 16:13:11 +00:00
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_gpio.c
2017-01-19 01:24:59 +00:00
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_i2c.c
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_i2c_ex.c
2017-01-05 16:13:11 +00:00
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_opamp.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_opamp_ex.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_pcd.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_pcd_ex.c
2017-01-19 01:24:59 +00:00
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_pwr.c
# SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_pwr_ex.c
2017-01-05 16:13:11 +00:00
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_rcc.c
2017-01-20 22:44:58 +00:00
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_rcc_ex.c
2017-01-05 16:13:11 +00:00
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_tim.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_tim_ex.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_uart.c
SOURCES += $(HAL_DRV_DIR)/Src/stm32f3xx_hal_uart_ex.c
LDSCRIPT = stm32f303/STM32F303CBTx_FLASH.ld
#============================================================================
OBJECTS += $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SOURCES))))
CPPFLAGS += $(addprefix -I,$(INCDIRS))
#---------------- Preprocessor Options ----------------
# -fsingle... make better use of the single-precision FPU
# -g generate debugging information
# -save-temps preserve .s and .i-files
#
2017-06-02 18:41:21 +00:00
#CPPFLAGS +=
2017-01-19 01:24:59 +00:00
# CPPFLAGS += -g
2017-01-05 16:13:11 +00:00
# CPPFLAGS += -save-temps=obj
#---------------- C Compiler Options ----------------
# -O* optimization level
# -f... tuning, see GCC documentation
# -Wall... warning level
#
CFLAGS += $(OPT)
CFLAGS += -std=gnu11
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
CFLAGS += -Wall
CFLAGS += -fno-builtin ## from old
CFLAGS += -nostartfiles
CFLAGS += -Wfatal-errors
2017-01-23 08:11:36 +00:00
CFLAGS += -Wno-pointer-sign #for usb lib...
2017-06-02 18:41:21 +00:00
#CFLAGS += -Wdouble-promotion
CFLAGS += -Wfloat-conversion
CFLAGS += -fsingle-precision-constant
# CFLAGS += -ffast-math
CFLAGS += -ffinite-math-only
CFLAGS += -fno-trapping-math
CFLAGS += -fno-signaling-nans
CFLAGS += -fno-rounding-math
CFLAGS += -fno-signed-zeros
CFLAGS += -fno-math-errno
2017-01-05 16:13:11 +00:00
#CFLAGS += -Wstrict-prototypes
#CFLAGS += -Wextra
#CFLAGS += -Wpointer-arith
#CFLAGS += -Winline
#CFLAGS += -Wunreachable-code
#CFLAGS += -Wundef
# Use a friendly C dialect
CPPFLAGS += -fno-strict-aliasing
CPPFLAGS += -fwrapv
#---------------- C++ Compiler Options ----------------
#
CXXFLAGS += $(OPT)
CXXFLAGS += -ffunction-sections
CXXFLAGS += -fdata-sections
CXXFLAGS += -Wall
#---------------- Assembler Options ----------------
# -Wa,... tell GCC to pass this to the assembler
#
#---------------- Linker Options ----------------
# -Wl,... tell GCC to pass this to linker
# -Map create map file
# --cref add cross reference to map file
#
LDFLAGS += $(OPT)
LDFLAGS += -lm
LDFLAGS += -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -Wl,--gc-sections
# LDFLAGS += -specs=nano.specs -u _printf_float -u _scanf_float
2017-01-10 08:48:07 +00:00
LDFLAGS += -lc -specs=nosys.specs #fixes sbrk missing? present in eclipse?
2017-01-05 16:13:11 +00:00
LDFLAGS += -T$(LDSCRIPT)
#============================================================================
2017-01-18 13:38:39 +00:00
POSTLD = tools/add_version_info.py # -q
2017-01-05 16:13:11 +00:00
# Compiler flags to generate dependency files
#
GENDEPFLAGS = -MMD -MP
# Combine all necessary flags and optional flags
# Add target processor to flags.
#
CPU = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += $(CPU)
CXXFLAGS += $(CPU)
ASFLAGS += $(CPU)
LDFLAGS += $(CPU)
# Default target
#
all: gccversion build showsize
2017-02-27 20:37:21 +00:00
build: tbl elf hex bin lss sym
2017-01-05 16:13:11 +00:00
elf: $(TARGET).elf
hex: $(TARGET).hex
bin: $(TARGET).bin
lss: $(TARGET).lss
sym: $(TARGET).sym
# Display compiler version information
#
2017-02-27 20:37:21 +00:00
stm32f303/inc/commandslist.h: tbl
stm32f303/inc/hal_tbl.h: tbl
stm32f303/src/hal_tbl.c: tbl
tbl:
2017-04-15 18:54:21 +00:00
@echo Generating tables
2017-07-01 00:48:57 +00:00
@tools/create_hal_tbl.py stm32f303/ $(COMPS)
2017-04-15 18:54:21 +00:00
#shared/comps/*.c src/comps/hw/*.c src/comps/*.c
@tools/create_cmd.py $(SOURCES) > stm32f303/inc/commandslist.h
2017-02-27 20:37:21 +00:00
2017-01-05 16:13:11 +00:00
gccversion:
@$(CC) --version
# Show the final program size
#
showsize: build
@echo
@$(SIZE) $(TARGET).elf 2>/dev/null
# Flash the device
#
2017-01-05 22:28:37 +00:00
btburn: build showsize $(TARGET).dfu
2017-01-05 16:13:11 +00:00
@tools/bootloader.py
@sleep 1
2017-01-18 13:38:39 +00:00
@dfu-util -d 0483:df11 -a 0 -s 0x8004000:leave -D $(TARGET).dfu
2017-01-05 16:13:11 +00:00
2017-01-05 22:28:37 +00:00
flash: $(TARGET).bin
2017-01-18 13:38:39 +00:00
st-flash --reset write $(TARGET).bin 0x8004000
2017-01-05 16:13:11 +00:00
# Create a DFU file from bin file
%.dfu: %.bin
@cp $< $@
@dfu-suffix -v 0483 -p df11 -a $@
# Target: clean project
#
clean:
@echo Cleaning project:
rm -rf $(OBJDIR)
2017-02-27 20:37:21 +00:00
rm -rf stm32f303/inc/commandslist.h
rm -rf stm32f303/inc/hal_tbl.h
rm -rf stm32f303/src/hal_tbl.c
2017-01-05 16:13:11 +00:00
# Include the base rules
#
include base.mak
include toolchain.mak
# Include the dependency files
#
-include $(OBJECTS:.o=.d)
# Listing of phony targets
#
.PHONY: all build flash clean \
boot boot_clean boot_flash btburn boot_btflash boot_flash\
elf lss sym \
2017-02-27 20:37:21 +00:00
showsize gccversion tbl