1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-18 22:52:08 +00:00
stmbl/Makefile

309 lines
7.5 KiB
Makefile
Raw Permalink Normal View History

2016-01-09 16:09:19 +00:00
# Optimization level, can be [0, 1, 2, 3, s].
2015-12-30 07:14:51 +00:00
# 0 = turn off optimization. s = optimize for size.
2016-01-09 16:09:19 +00:00
#
2017-01-03 21:51:05 +00:00
OPT = -O1
2015-12-30 07:14:51 +00:00
# OPT = -O1 # for debugging
# Object files directory
# Warning: this will be removed by make clean!
#
OBJDIR = obj_app
# Target file name (without extension)
TARGET = $(OBJDIR)/stmbl
# Define all C source files (dependencies are generated automatically)
INCDIRS += inc
INCDIRS += shared
SOURCES += src/main.c
SOURCES += src/stm32f4xx_it.c
2017-01-18 13:38:39 +00:00
SOURCES += src/system_stm32f4xx.c #TODO: update this, system file from cmsis
2015-12-30 07:14:51 +00:00
SOURCES += src/setup.c
SOURCES += src/usb_cdc.c
2017-04-14 08:34:16 +00:00
# SOURCES += src/hal_conf.c
SOURCES += src/hal_tbl.c
2017-07-01 00:48:57 +00:00
COMPS += src/comps/hw/io4.c
COMPS += src/comps/encm.c
COMPS += src/comps/hv.c
COMPS += src/comps/adc.c
COMPS += src/comps/enc_fb.c
2017-07-28 01:49:04 +00:00
COMPS += src/comps/enc_cmd.c
COMPS += src/comps/o_fb.c
2017-07-01 00:48:57 +00:00
COMPS += src/comps/conf.c
2017-07-02 17:00:55 +00:00
COMPS += src/comps/res.c
2017-07-02 18:22:19 +00:00
COMPS += src/comps/sserial.c
2017-07-01 00:48:57 +00:00
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/vel.c
COMPS += shared/comps/rev.c
COMPS += shared/comps/hal_test.c
COMPS += shared/comps/dc.c
COMPS += shared/comps/ypid.c
COMPS += shared/comps/fault.c
COMPS += shared/comps/pid.c
COMPS += shared/comps/pmsm_limits.c
2017-07-01 03:21:03 +00:00
COMPS += shared/comps/pmsm_ttc.c
2017-07-01 00:48:57 +00:00
COMPS += shared/comps/uvw.c
COMPS += shared/comps/fanuc.c
COMPS += shared/comps/fb_switch.c
2017-07-01 01:18:25 +00:00
COMPS += shared/comps/reslimit.c
2017-07-01 03:21:03 +00:00
COMPS += shared/comps/iit.c
2017-07-01 01:18:25 +00:00
COMPS += shared/comps/vel_int.c
2017-07-02 16:44:26 +00:00
COMPS += shared/comps/linrev.c
2017-07-02 17:42:53 +00:00
COMPS += shared/comps/psi.c
COMPS += shared/comps/stp.c
2017-07-01 00:48:57 +00:00
SOURCES += $(COMPS)
2017-04-14 08:34:16 +00:00
2017-07-19 11:04:47 +00:00
# SOURCES += src/eeprom.c
2017-04-14 08:34:16 +00:00
# SOURCES += src/link.c
2015-12-30 07:14:51 +00:00
SOURCES += src/version.c
SOURCES += src/syscalls.c
SOURCES += shared/crc8.c
2016-07-18 03:52:50 +00:00
SOURCES += shared/crc16.c
2017-01-05 22:28:09 +00:00
SOURCES += shared/angle.c
SOURCES += shared/hal.c
SOURCES += shared/commands.c
2017-07-12 20:11:18 +00:00
SOURCES += shared/config.c
SOURCES += src/conf_templates.c
2017-04-14 08:34:16 +00:00
# SOURCES += shared/hal_term.c
# SOURCES += shared/scanf.c
2017-01-10 00:56:32 +00:00
SOURCES += shared/ringbuf.c
2015-12-30 07:14:51 +00:00
USB_VCP_DIR = lib/STM32_USB_Device_VCP-1.2.0
CPPFLAGS += -DUSBD_PRODUCT_STRING='"STMBL Virtual ComPort"'
CPPFLAGS += -DCDC_IN_FRAME_INTERVAL=1
CPPFLAGS += -DAPP_RX_DATA_SIZE=4096
INCDIRS += $(USB_VCP_DIR)/inc
SOURCES += $(USB_VCP_DIR)/src/usbd_desc.c
USB_DEVICE_DIR = lib/STM32_USB_Device_Library-1.2.0
INCDIRS += $(USB_DEVICE_DIR)/Class/cdc/inc
SOURCES += $(USB_DEVICE_DIR)/Class/cdc/src/usbd_cdc_core.c
INCDIRS += $(USB_DEVICE_DIR)/Core/inc
SOURCES += $(USB_DEVICE_DIR)/Core/src/usbd_core.c
SOURCES += $(USB_DEVICE_DIR)/Core/src/usbd_ioreq.c
SOURCES += $(USB_DEVICE_DIR)/Core/src/usbd_req.c
USB_DRIVER_DIR = lib/STM32_USB_OTG_Driver-2.2.0
INCDIRS += $(USB_DRIVER_DIR)/inc
SOURCES += $(USB_DRIVER_DIR)/src/usb_core.c
SOURCES += $(USB_DRIVER_DIR)/src/usb_dcd.c
SOURCES += $(USB_DRIVER_DIR)/src/usb_dcd_int.c
2015-12-30 07:14:51 +00:00
# Standard peripheral library
CPPFLAGS += -DUSE_STDPERIPH_DRIVER
#CPPFLAGS += -DUSE_FULL_ASSERT
2016-01-09 16:09:19 +00:00
PERIPH_DRV_DIR = lib/STM32F4xx_StdPeriph_Driver-V1.6.0
INCDIRS += $(PERIPH_DRV_DIR)/inc
INCDIRS += lib/CMSIS/Include
INCDIRS += lib/CMSIS/Device/ST/STM32F4xx/Include
2016-01-09 16:09:19 +00:00
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_adc.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_crc.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_dma.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_flash.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_gpio.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_pwr.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_rcc.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_tim.c
SOURCES += $(PERIPH_DRV_DIR)/src/stm32f4xx_usart.c
SOURCES += $(PERIPH_DRV_DIR)/src/misc.c
SOURCES += lib/CMSIS/Device/ST/STM32F4xx/Source/startup_stm32f40_41xxx.s
CPPFLAGS += -DSTM32F40_41xxx
2016-01-02 21:11:42 +00:00
CPPFLAGS += -DHSE_VALUE=8000000
2015-12-30 07:14:51 +00:00
LDSCRIPT = stm32_flash.ld
#============================================================================
OBJECTS += $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SOURCES))))
2017-01-19 00:38:53 +00:00
# OBJECTS += hv_firmware.o
2015-12-30 07:14:51 +00:00
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
#
CPPFLAGS += -fsingle-precision-constant
CPPFLAGS += -g
# 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
2016-02-15 14:28:30 +00:00
CFLAGS += -Wfatal-errors
2015-12-30 07:14:51 +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
LDFLAGS += -T$(LDSCRIPT)
#============================================================================
2015-12-30 07:23:10 +00:00
POSTLD = tools/add_version_info.py # -q
2015-12-30 07:14:51 +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
#
2017-01-19 00:38:53 +00:00
all: gccversion boot build showsize
2015-12-30 07:14:51 +00:00
2017-02-27 20:37:21 +00:00
build: tbl elf hex bin lss sym
2015-12-30 07:14:51 +00:00
elf: $(TARGET).elf
hex: $(TARGET).hex
bin: $(TARGET).bin
lss: $(TARGET).lss
sym: $(TARGET).sym
2017-04-14 08:34:16 +00:00
inc/commandslist.h: tbl
inc/hal_tbl.h: tbl
src/hal_tbl.c: tbl
2017-07-12 22:50:54 +00:00
src/conf_templates.c: tbl
2017-02-27 20:37:21 +00:00
tbl:
2017-04-15 12:44:49 +00:00
@echo Generating tables
2017-07-01 00:48:57 +00:00
@tools/create_hal_tbl.py . $(COMPS)
2017-07-12 20:11:18 +00:00
@tools/create_config.py conf/template/* > src/conf_templates.c
2017-07-12 20:27:06 +00:00
@tools/create_cmd.py $(SOURCES) > inc/commandslist.h
2017-02-27 20:37:21 +00:00
2015-12-30 07:14:51 +00:00
boot:
$(MAKE) -f bootloader/Makefile
boot_clean:
$(MAKE) -f bootloader/Makefile clean
boot_flash: boot
$(MAKE) -f bootloader/Makefile flash
2015-12-30 10:52:36 +00:00
hv_flash: boot
$(MAKE) -f stm32f103/Makefile flash
2015-12-30 07:14:51 +00:00
boot_btflash: boot
$(MAKE) -f bootloader/Makefile btflash
hv:
$(MAKE) -f stm32f103/Makefile
# Display compiler version information
#
2016-01-09 16:09:19 +00:00
gccversion:
2015-12-30 07:14:51 +00:00
@$(CC) --version
# Show the final program size
#
showsize: build
@echo
@$(SIZE) $(TARGET).elf 2>/dev/null
2016-01-09 16:09:19 +00:00
# Flash the device
2015-12-30 07:14:51 +00:00
#
2017-01-19 00:38:53 +00:00
btburn: build showsize $(TARGET).dfu
2016-08-26 10:13:33 +00:00
@tools/bootloader.py
@sleep 1
@dfu-util -d 0483:df11 -a 0 -s 0x08010000:leave -D $(TARGET).dfu
2017-01-19 00:38:53 +00:00
flash: $(TARGET).bin
2016-07-06 16:51:17 +00:00
st-flash --reset write $(TARGET).bin 0x08010000
# Create a DFU file from bin file
%.dfu: %.bin
@cp $< $@
2016-08-26 10:13:33 +00:00
@dfu-suffix -v 0483 -p df11 -a $@
2013-12-09 22:04:24 +00:00
2015-12-30 07:14:51 +00:00
# Target: clean project
#
2013-12-09 22:04:24 +00:00
clean:
2015-12-30 07:14:51 +00:00
@echo Cleaning project:
2017-01-19 00:38:53 +00:00
# rm -rf hv_firmware.o
2015-12-30 07:14:51 +00:00
rm -rf $(OBJDIR)
2017-02-27 20:45:50 +00:00
rm -rf inc/commandslist.h
2017-07-12 22:50:54 +00:00
rm -rf src/conf_templates.c
2015-12-30 07:14:51 +00:00
@$(MAKE) -f bootloader/Makefile clean
@$(MAKE) -f stm32f103/Makefile clean
2015-12-30 07:14:51 +00:00
# Include the base rules
#
include base.mak
include toolchain.mak
2015-12-30 07:14:51 +00:00
# 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