1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-20 07:32:10 +00:00
stmbl/Makefile

403 lines
10 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
2018-03-16 02:25:00 +00:00
SOURCES += src/config.c
2017-04-14 08:34:16 +00:00
# SOURCES += src/hal_conf.c
SOURCES += src/hal_tbl.c
2017-10-30 00:39:05 +00:00
HWVERSION = v4
ifeq ($(HWVERSION),v3)
COMPS += src/comps/hw/io3.c
2017-10-30 02:26:47 +00:00
COMPS += src/comps/hvf1.c
2019-07-04 15:59:58 +00:00
COMPS += shared/comps/pmsm.c
COMPS += shared/comps/curpid.c
COMPS += shared/comps/dq.c
COMPS += shared/comps/idq.c
2017-10-30 02:26:47 +00:00
SOURCES += shared/common_f1.c
2017-10-30 01:58:09 +00:00
CFLAGS += -DV3
2017-10-30 00:39:05 +00:00
else
COMPS += src/comps/hw/io4.c
COMPS += src/comps/hv.c
#TODO: need backport to v3
COMPS += src/comps/enc_cmd.c
COMPS += src/comps/o_fb.c
COMPS += src/comps/sserial.c
2017-12-23 10:55:18 +00:00
COMPS += src/comps/yaskawa.c
2018-03-02 03:31:12 +00:00
COMPS += src/comps/encs.c
2018-03-24 22:36:18 +00:00
COMPS += src/comps/encf.c
2019-06-29 06:37:04 +00:00
COMPS += src/comps/endat.c
2017-10-30 01:58:09 +00:00
CFLAGS += -DV4
2017-10-30 00:39:05 +00:00
endif
2017-07-01 00:48:57 +00:00
COMPS += src/comps/encm.c
2018-10-05 16:19:52 +00:00
COMPS += src/comps/smartabs.c
2017-07-01 00:48:57 +00:00
COMPS += src/comps/adc.c
COMPS += src/comps/enc_fb.c
COMPS += src/comps/conf.c
2017-07-02 17:00:55 +00:00
COMPS += src/comps/res.c
2019-02-13 19:18:52 +00:00
COMPS += src/comps/hx711.c
2017-07-01 00:48:57 +00:00
COMPS += shared/comps/sim.c
COMPS += shared/comps/term.c
COMPS += shared/comps/svm.c
2019-07-04 15:59:58 +00:00
2017-07-01 00:48:57 +00:00
COMPS += shared/comps/vel.c
COMPS += shared/comps/rev.c
COMPS += shared/comps/hal_test.c
2019-07-04 15:59:58 +00:00
# COMPS += shared/comps/dc.c
2017-07-01 00:48:57 +00:00
COMPS += shared/comps/ypid.c
COMPS += shared/comps/fault.c
COMPS += shared/comps/pid.c
2017-09-03 18:49:24 +00:00
COMPS += shared/comps/spid.c
2017-09-06 00:01:26 +00:00
COMPS += shared/comps/pe.c
2017-07-01 00:48:57 +00:00
COMPS += shared/comps/pmsm_limits.c
2017-07-01 03:21:03 +00:00
COMPS += shared/comps/pmsm_ttc.c
2017-10-16 00:07:28 +00:00
COMPS += shared/comps/dc_limits.c
COMPS += shared/comps/dc_ttc.c
2017-09-03 03:01:39 +00:00
COMPS += shared/comps/acim_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
2018-10-04 19:13:01 +00:00
#COMPS += shared/comps/uf.c
COMPS += shared/comps/uf2.c
2017-10-16 00:07:28 +00:00
COMPS += shared/comps/ramp.c
COMPS += shared/comps/scale.c
2017-10-23 16:17:59 +00:00
COMPS += shared/comps/idx_home.c
2017-12-05 15:50:08 +00:00
COMPS += shared/comps/move.c
2018-09-19 19:55:23 +00:00
# COMPS += shared/comps/ac.c
2018-04-06 08:40:20 +00:00
COMPS += shared/comps/not.c
2018-07-21 20:55:17 +00:00
COMPS += shared/comps/and.c
COMPS += shared/comps/or.c
2018-03-18 22:33:52 +00:00
COMPS += shared/comps/jog.c
2018-09-16 18:15:06 +00:00
COMPS += shared/comps/velbuf.c
2018-09-19 19:55:23 +00:00
COMPS += shared/comps/avg.c
2018-09-20 01:09:01 +00:00
COMPS += shared/comps/mux.c
2018-12-16 17:30:52 +00:00
COMPS += shared/comps/veltopos.c
2019-05-29 22:02:53 +00:00
# COMPS += shared/comps/wobl.c
2018-12-16 17:30:52 +00:00
COMPS += shared/comps/debounce.c
2019-04-29 17:36:11 +00:00
COMPS += shared/comps/pos_filter.c
2019-05-01 20:39:36 +00:00
COMPS += shared/comps/rl.c
2019-05-09 17:05:25 +00:00
COMPS += shared/comps/mad.c
2019-05-29 22:02:53 +00:00
COMPS += shared/comps/sensorless.c
2019-05-30 02:30:32 +00:00
COMPS += shared/comps/field.c
2019-06-27 20:43:24 +00:00
COMPS += shared/comps/gain.c
2019-06-29 06:37:04 +00:00
COMPS += shared/comps/rlpsij.c
2019-12-11 09:22:44 +00:00
COMPS += shared/comps/veltime.c
COMPS += shared/comps/mpid.c
COMPS += shared/comps/fmove.c
COMPS += shared/comps/home.c
COMPS += shared/comps/en.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
2018-02-08 17:09:48 +00:00
SOURCES += shared/yaskawa_crc16.c
2019-07-01 11:53:31 +00:00
SOURCES += shared/endat.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-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/stm32f4xx_spi.c
2016-01-09 16:09:19 +00:00
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))))
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
2018-03-16 05:38:33 +00:00
CFLAGS += -Wmaybe-uninitialized
CFLAGS += -Wuninitialized
2015-12-30 07:14:51 +00:00
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)
#============================================================================
2018-04-07 00:00:04 +00:00
POSTLD = $(PYTHON) 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)
2018-04-07 01:44:49 +00:00
ADDRESS = 0x08010000
2015-12-30 07:14:51 +00:00
# Default target
#
all: gccversion tbl boot build showsize
2015-12-30 07:14:51 +00:00
2018-04-09 11:33:41 +00:00
build: tbl elf hex bin lss sym f3_boot
2015-12-30 07:14:51 +00:00
elf: $(TARGET).elf
hex: $(TARGET).hex
bin: tbl $(TARGET).bin
2015-12-30 07:14:51 +00:00
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
#generate hal and command tables
2017-02-27 20:37:21 +00:00
tbl:
2017-04-15 12:44:49 +00:00
@echo Generating tables
2018-04-07 00:00:04 +00:00
@$(PYTHON) tools/create_hal_tbl.py . $(COMPS)
@$(PYTHON) tools/create_config.py conf/template/* > src/conf_templates.c
@$(PYTHON) tools/create_cmd.py $(SOURCES) > inc/commandslist.h
2017-02-27 20:37:21 +00:00
2018-04-09 11:33:41 +00:00
#build f4 bootloader
2015-12-30 07:14:51 +00:00
boot:
$(MAKE) -f bootloader/Makefile
2018-04-09 11:33:41 +00:00
#flash f4 bootloader using stlink
2015-12-30 07:14:51 +00:00
boot_flash: boot
$(MAKE) -f bootloader/Makefile flash
2018-04-09 11:33:41 +00:00
#flash f4 bootloader using df-util
2017-11-04 22:46:09 +00:00
boot_btburn: boot
2018-04-09 11:33:41 +00:00
$(MAKE) -f bootloader/Makefile btburn
2015-12-30 07:14:51 +00:00
2018-04-09 11:33:41 +00:00
#build f3 bootloader
f3_boot:
$(MAKE) -f f3_boot/Makefile
#flash f3 bootloader using stlink
f3_boot_flash:
$(MAKE) -f f3_boot/Makefile flash
#flash f3 bootloader using df-util
f3_boot_btburn:
$(MAKE) -f f3_boot/Makefile btburn
#build f3 firmware
2017-09-10 11:59:15 +00:00
f3:
$(MAKE) -f stm32f303/Makefile
2018-04-09 11:33:41 +00:00
#flash f3 firmware using stlink
2017-09-10 11:59:15 +00:00
f3_flash:
$(MAKE) -f stm32f303/Makefile flash
2018-04-09 11:33:41 +00:00
#flash f3 firmware using df-util
2017-11-04 22:46:09 +00:00
f3_btburn:
2017-09-10 11:59:15 +00:00
$(MAKE) -f stm32f303/Makefile btburn
2018-03-18 22:33:52 +00:00
2018-04-09 11:33:41 +00:00
#generate f3 firmware object from f3 bin
hv_firmware.o:
2018-04-06 22:45:24 +00:00
$(MAKE) -f stm32f303/Makefile all
2018-04-09 11:33:41 +00:00
#build f103 firmware for V3 hardware
f1:
$(MAKE) -f stm32f103/Makefile
#flash f103 firmware for V3 hardware using stlink
f1_flash: boot
$(MAKE) -f stm32f103/Makefile flash
2018-04-13 23:37:56 +00:00
f3_all_btburn:
2018-04-14 00:56:34 +00:00
@$(DFU-UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D f3.bin
2018-04-13 23:37:56 +00:00
all_btburn:
2018-04-16 23:18:47 +00:00
@$(PYTHON) tools/bootloader.py
@sleep 1
2018-04-14 00:56:34 +00:00
@$(DFU-UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D f4.bin
2018-04-13 23:37:56 +00:00
all_flash:
@$(ST-FLASH) --reset write f4.bin 0x08000000
f3_all_flash:
@$(ST-FLASH) --reset write f3.bin 0x08000000
2018-04-09 11:39:54 +00:00
deploy: f3_boot f3 boot build binall
2017-10-03 03:34:22 +00:00
binall:
cat obj_boot/blboot.bin /dev/zero | head -c 32768 > f4.bin
cat conf/festo.txt /dev/zero | head -c 32768 >> f4.bin
cat obj_app/stmbl.bin >> f4.bin
2018-03-23 03:52:57 +00:00
cat obj_f3_boot/f3_boot.bin /dev/zero | head -c 16384 > f3.bin
cat obj_hvf3/hvf3.bin >> f3.bin
2018-04-13 22:49:29 +00:00
$(PYTHON) tools/dfu-convert.py -b 0x08000000:f4.bin f4.dfu
$(PYTHON) tools/dfu-convert.py -b 0x08000000:f3.bin f3.dfu
$(PYTHON) tools/dfu-convert.py -b 0x08010000:obj_app/stmbl.bin stmbl.dfu
2017-09-05 22:11:32 +00:00
format:
2018-03-23 03:52:57 +00:00
find src/ f3_boot/ bootloader/ stm32f103/ stm32f303/ shared/ inc/ tools/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i
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:
rm -rf hv_firmware.o
2018-04-13 22:49:29 +00:00
rm -rf f3.bin f4.bin f3.dfu f4.dfu stmbl.dfu
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
2018-03-23 03:52:57 +00:00
@$(MAKE) -f f3_boot/Makefile clean
2015-12-30 07:14:51 +00:00
@$(MAKE) -f stm32f103/Makefile clean
2017-10-03 03:34:22 +00:00
@$(MAKE) -f stm32f303/Makefile clean
2015-12-30 07:14:51 +00:00
# Include the base rules
#
include base.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 \
2018-04-13 23:37:56 +00:00
showsize gccversion tbl f3_boot binall deploy format f3_all_btburn all_btburn f3_all_flash all_flash