2015-07-10 06:01:56 -07:00
|
|
|
##############################################################################
|
|
|
|
# Build global options
|
|
|
|
# NOTE: Can be overridden externally.
|
|
|
|
#
|
|
|
|
|
2019-03-20 05:45:15 -07:00
|
|
|
CHIBIOS = ChibiOS
|
2018-12-15 21:22:24 -08:00
|
|
|
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
|
|
|
|
RULESFILE = $(RULESPATH)/rules.mk
|
|
|
|
|
2019-03-29 07:29:01 -07:00
|
|
|
# Define project name here
|
|
|
|
PROJECT = rusefi
|
|
|
|
PROJECT_DIR = .
|
|
|
|
|
|
|
|
# Imported source files and paths
|
|
|
|
CHIBIOS_CONTRIB = ChibiOS-Contrib
|
|
|
|
|
2018-12-15 21:55:03 -08:00
|
|
|
include rusefi.mk
|
2018-12-13 18:29:24 -08:00
|
|
|
|
2017-04-02 08:50:05 -07:00
|
|
|
# by default EXTRA_PARAMS is empty and we create 'debug' version of the firmware with additional assertions and statistics
|
|
|
|
# for 'release' options see 'clean_compile_two_versions.bat' file
|
|
|
|
|
|
|
|
ifeq ($(DEBUG_LEVEL_OPT),)
|
|
|
|
# this value would be used by default. For 'release' configuration override with '-O2' or something along these lines
|
|
|
|
DEBUG_LEVEL_OPT = -O0 -ggdb -g3
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2019-04-20 18:31:24 -07:00
|
|
|
ifneq ($(CCACHE_DIR),)
|
|
|
|
$(info CCACHE_DIR is ${CCACHE_DIR})
|
|
|
|
CCPREFIX=ccache
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
# Compiler options here.
|
|
|
|
ifeq ($(USE_OPT),)
|
2019-04-14 15:09:58 -07:00
|
|
|
USE_OPT = $(EXTRA_PARAMS) $(DEBUG_LEVEL_OPT) $(RFLAGS) -Wno-error=implicit-fallthrough -Wno-error=bool-operation -fomit-frame-pointer -falign-functions=16 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Werror=missing-field-initializers -Werror=type-limits -Wno-error=strict-aliasing -Wno-error=attributes
|
2015-07-10 06:01:56 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
# C specific options here (added to USE_OPT).
|
|
|
|
ifeq ($(USE_COPT),)
|
|
|
|
USE_COPT = -fgnu89-inline -std=gnu99
|
|
|
|
endif
|
|
|
|
|
|
|
|
# C++ specific options here (added to USE_OPT).
|
|
|
|
ifeq ($(USE_CPPOPT),)
|
2019-01-06 17:48:15 -08:00
|
|
|
# constexpr float expf_taylor_impl probably needs just c++14 but why not go with 17?
|
2019-04-04 16:56:03 -07:00
|
|
|
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-threadsafe-statics -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits
|
2015-07-10 06:01:56 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Enable this if you want the linker to remove unused code and data
|
|
|
|
ifeq ($(USE_LINK_GC),)
|
|
|
|
USE_LINK_GC = yes
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Linker extra options here.
|
|
|
|
ifeq ($(USE_LDOPT),)
|
2017-03-22 16:16:45 -07:00
|
|
|
USE_LDOPT =
|
2015-07-10 06:01:56 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Enable this if you want link time optimizations (LTO)
|
|
|
|
ifeq ($(USE_LTO),)
|
2017-03-22 16:16:45 -07:00
|
|
|
USE_LTO = no
|
2015-07-10 06:01:56 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
# If enabled, this option allows to compile the application in THUMB mode.
|
|
|
|
ifeq ($(USE_THUMB),)
|
|
|
|
USE_THUMB = yes
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Enable this if you want to see the full log while compiling.
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),)
|
|
|
|
USE_VERBOSE_COMPILE = no
|
|
|
|
endif
|
|
|
|
|
2017-03-22 04:08:20 -07:00
|
|
|
# If enabled, this option makes the build process faster by not compiling
|
|
|
|
# modules not used in the current configuration.
|
|
|
|
ifeq ($(USE_SMART_BUILD),)
|
|
|
|
USE_SMART_BUILD = no
|
|
|
|
endif
|
|
|
|
|
2017-06-02 09:33:45 -07:00
|
|
|
ifeq ($(USE_BOOTLOADER),)
|
|
|
|
USE_BOOTLOADER = no
|
|
|
|
endif
|
|
|
|
|
2019-03-29 07:29:01 -07:00
|
|
|
ifeq ($(USE_FATFS),)
|
|
|
|
USE_FATFS = yes
|
|
|
|
endif
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#
|
|
|
|
# Build global options
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Architecture or project specific options
|
|
|
|
#
|
|
|
|
|
2017-03-22 04:08:20 -07:00
|
|
|
# Stack size to be allocated to the Cortex-M process stack. This stack is
|
|
|
|
# the stack used by the main() thread.
|
|
|
|
ifeq ($(USE_PROCESS_STACKSIZE),)
|
|
|
|
USE_PROCESS_STACKSIZE = 0x0600
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
|
|
|
|
# stack is used for processing interrupts and exceptions.
|
|
|
|
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
|
|
|
|
USE_EXCEPTIONS_STACKSIZE = 0x1000
|
|
|
|
endif
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
|
|
|
|
ifeq ($(USE_FPU),)
|
2018-12-28 18:43:46 -08:00
|
|
|
USE_FPU = hard
|
2015-07-10 06:01:56 -07:00
|
|
|
endif
|
|
|
|
|
2018-12-31 07:17:55 -08:00
|
|
|
# and this is not working for be :( See https://github.com/rusefi/rusefi/issues/638
|
|
|
|
# use -j4 unless some value was specified
|
|
|
|
NUMJOBS=${NUMJOBS:-" -j4 "}
|
|
|
|
|
|
|
|
MAKEFLAGS += ${NUMJOBS}
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
#
|
|
|
|
# Architecture or project specific options
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Project, sources and paths
|
|
|
|
#
|
|
|
|
|
2017-03-22 04:08:20 -07:00
|
|
|
# Startup files.
|
2019-03-29 07:29:01 -07:00
|
|
|
include $(CPU_STARTUP_DIR)
|
2017-03-22 04:08:20 -07:00
|
|
|
# HAL-OSAL files (optional).
|
2017-03-22 11:42:36 -07:00
|
|
|
include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
|
2019-03-29 07:29:01 -07:00
|
|
|
include $(CPU_PLATFORM_DIR)
|
2017-03-22 04:08:20 -07:00
|
|
|
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
|
|
|
|
# RTOS files (optional).
|
|
|
|
include $(CHIBIOS)/os/rt/rt.mk
|
2018-01-23 18:17:30 -08:00
|
|
|
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-03-29 07:29:01 -07:00
|
|
|
ifeq ($(USE_FATFS),yes)
|
2015-07-10 06:01:56 -07:00
|
|
|
include $(CHIBIOS)/os/various/fatfs_bindings/fatfs.mk
|
2019-03-29 07:29:01 -07:00
|
|
|
endif
|
2017-03-22 04:08:20 -07:00
|
|
|
include $(CHIBIOS)/os/various/cpp_wrappers/chcpp.mk
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
include console/binary/tunerstudio.mk
|
2019-03-29 07:29:01 -07:00
|
|
|
ifeq ($(USE_FATFS),yes)
|
2017-03-24 05:55:32 -07:00
|
|
|
include $(PROJECT_DIR)/ext/fatfs.mk
|
2019-03-29 07:29:01 -07:00
|
|
|
endif
|
2017-03-22 11:45:11 -07:00
|
|
|
|
2016-06-10 12:01:47 -07:00
|
|
|
include $(PROJECT_DIR)/hw_layer/hw_layer.mk
|
2019-03-12 07:12:37 -07:00
|
|
|
include $(PROJECT_DIR)/hw_layer/drivers/drivers.mk
|
2016-07-16 23:03:46 -07:00
|
|
|
include $(PROJECT_DIR)/hw_layer/sensors/sensors.mk
|
2016-06-10 12:01:47 -07:00
|
|
|
include $(PROJECT_DIR)/hw_layer/mass_storage/mass_storage.mk
|
2018-10-30 05:42:36 -07:00
|
|
|
include $(PROJECT_DIR)/development/development.mk
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
include $(PROJECT_DIR)/util/util.mk
|
2017-03-22 11:45:11 -07:00
|
|
|
include $(PROJECT_DIR)/config/boards/$(PROJECT_BOARD)/board.mk
|
2015-07-10 06:01:56 -07:00
|
|
|
include $(PROJECT_DIR)/config/engines/engines.mk
|
2019-04-04 22:41:24 -07:00
|
|
|
include $(PROJECT_DIR)/controllers/controllers.mk
|
2015-07-10 06:01:56 -07:00
|
|
|
include $(PROJECT_DIR)/controllers/algo/algo.mk
|
|
|
|
include $(PROJECT_DIR)/controllers/core/core.mk
|
|
|
|
include $(PROJECT_DIR)/controllers/math/math.mk
|
|
|
|
include $(PROJECT_DIR)/controllers/sensors/sensors.mk
|
|
|
|
include $(PROJECT_DIR)/controllers/system/system.mk
|
|
|
|
include $(PROJECT_DIR)/controllers/trigger/trigger.mk
|
|
|
|
include $(PROJECT_DIR)/console/console.mk
|
|
|
|
|
2019-03-31 23:51:34 -07:00
|
|
|
ifeq ($(BOOTLOADERINC),)
|
|
|
|
# include default bootloader code
|
|
|
|
BOOTLOADERINC= $(PROJECT_DIR)/bootloader/
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2017-06-02 09:33:45 -07:00
|
|
|
ifeq ($(USE_BOOTLOADER),yes)
|
|
|
|
include $(PROJECT_DIR)/bootloader/bootloader.mk
|
|
|
|
endif
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
# Define linker script file here
|
2017-04-17 08:22:09 -07:00
|
|
|
ifeq ($(LDSCRIPT),)
|
2017-07-28 12:17:45 -07:00
|
|
|
LDSCRIPT= config/stm32f4ems/STM32F407xG.ld
|
2017-04-17 08:22:09 -07:00
|
|
|
endif
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
|
|
|
# setting.
|
2017-03-22 04:08:20 -07:00
|
|
|
CSRC = $(STARTUPSRC) \
|
2015-07-10 06:01:56 -07:00
|
|
|
$(KERNSRC) \
|
2017-03-22 04:08:20 -07:00
|
|
|
$(PORTSRC) \
|
|
|
|
$(OSALSRC) \
|
|
|
|
$(HALSRC) \
|
|
|
|
$(PLATFORMSRC) \
|
|
|
|
$(BOARDSRC) \
|
2017-06-02 09:33:45 -07:00
|
|
|
$(BOOTLOADERSRC) \
|
2019-02-05 15:36:25 -08:00
|
|
|
$(CHIBIOS)/os/ex/ST/lis302dl.c \
|
2017-03-22 04:08:20 -07:00
|
|
|
$(CHIBIOS)/os/various/syscalls.c \
|
|
|
|
$(CHIBIOS)/os/hal/lib/streams/memstreams.c \
|
|
|
|
$(CHIBIOS)/os/hal/lib/streams/chprintf.c \
|
2016-06-10 12:01:47 -07:00
|
|
|
${HW_MASS_STORAGE_SRC_C} \
|
2015-07-10 06:01:56 -07:00
|
|
|
$(UTILSRC) \
|
|
|
|
$(ENGINES_SRC) \
|
|
|
|
$(CONSOLESRC) \
|
|
|
|
$(DEV_SRC) \
|
|
|
|
$(HW_LAYER_EMS) \
|
2019-03-12 07:12:37 -07:00
|
|
|
$(HW_LAYER_DRIVERS_CORE) \
|
|
|
|
$(HW_LAYER_DRIVERS) \
|
2015-07-10 06:01:56 -07:00
|
|
|
$(CONTROLLERSSRC) \
|
|
|
|
$(CONTROLLERS_ALGO_SRC) \
|
|
|
|
$(CONTROLLERS_CORE_SRC) \
|
|
|
|
$(CONTROLLERS_SENSORS_SRC) \
|
|
|
|
$(FATFSSRC) \
|
|
|
|
$(SYSTEMSRC)
|
|
|
|
|
|
|
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
|
|
|
# setting.
|
|
|
|
CPPSRC = $(CHCPPSRC) \
|
|
|
|
$(TRIGGER_SRC_CPP) \
|
|
|
|
$(TRIGGER_DECODERS_SRC_CPP) \
|
|
|
|
$(DEV_SRC_CPP) \
|
|
|
|
$(CONTROLLERS_ALGO_SRC_CPP) \
|
|
|
|
$(SYSTEMSRC_CPP) \
|
2017-05-02 10:34:01 -07:00
|
|
|
$(BOARDSRC_CPP) \
|
2015-07-10 06:01:56 -07:00
|
|
|
$(ENGINES_SRC_CPP) \
|
|
|
|
$(HW_LAYER_EMS_CPP) \
|
2019-03-25 12:08:32 -07:00
|
|
|
$(HW_LAYER_DRIVERS_CPP) \
|
2016-07-16 23:03:46 -07:00
|
|
|
$(HW_SENSORS_SRC) \
|
2015-07-10 06:01:56 -07:00
|
|
|
$(TUNERSTUDIO_SRC_CPP) \
|
|
|
|
$(CONSOLE_SRC_CPP) \
|
|
|
|
$(CONTROLLERS_SENSORS_SRC_CPP) \
|
|
|
|
$(CONTROLLERS_SRC_CPP) \
|
|
|
|
$(UTILSRC_CPP) \
|
|
|
|
$(CONTROLLERS_CORE_SRC_CPP) \
|
|
|
|
$(CONTROLLERS_MATH_SRC_CPP) \
|
|
|
|
rusefi.cpp \
|
|
|
|
main.cpp
|
|
|
|
|
|
|
|
# C sources to be compiled in ARM mode regardless of the global setting.
|
|
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
|
|
# option that results in lower performance and larger code size.
|
|
|
|
ACSRC =
|
|
|
|
|
|
|
|
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
|
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
|
|
# option that results in lower performance and larger code size.
|
|
|
|
ACPPSRC =
|
|
|
|
|
|
|
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
|
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
|
|
# option that results in lower performance and larger code size.
|
|
|
|
TCSRC =
|
|
|
|
|
|
|
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
|
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
|
|
# option that results in lower performance and larger code size.
|
|
|
|
TCPPSRC =
|
|
|
|
|
|
|
|
# List ASM source files here
|
2017-03-22 04:08:20 -07:00
|
|
|
# List ASM source files here
|
2018-01-23 18:17:30 -08:00
|
|
|
ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
|
2017-03-22 04:08:20 -07:00
|
|
|
|
2018-12-26 19:17:51 -08:00
|
|
|
ifeq ($(CONFIGPATH),)
|
|
|
|
CONFIGPATH=config/stm32f4ems
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2018-01-23 18:17:30 -08:00
|
|
|
INCDIR = $(CHIBIOS)/os/license \
|
|
|
|
$(PORTINC) \
|
2017-03-22 04:08:20 -07:00
|
|
|
$(OSALINC) \
|
|
|
|
$(KERNINC) \
|
|
|
|
$(TESTINC) \
|
|
|
|
$(STARTUPINC) \
|
|
|
|
$(HALINC) \
|
2019-03-31 14:15:32 -07:00
|
|
|
$(HALINC_CONTRIB) \
|
2017-03-22 04:08:20 -07:00
|
|
|
$(PLATFORMINC) \
|
|
|
|
$(BOARDINC) \
|
2017-06-02 09:33:45 -07:00
|
|
|
$(BOOTLOADERINC) \
|
2017-03-22 04:08:20 -07:00
|
|
|
$(CHCPPINC) \
|
|
|
|
$(CHIBIOS)/os/hal/lib/streams \
|
|
|
|
$(CHIBIOS)/os/various \
|
2019-02-05 15:36:25 -08:00
|
|
|
$(CHIBIOS)/os/ex/ST \
|
|
|
|
$(CHIBIOS)/os/hal/lib/peripherals/sensors \
|
2018-12-26 19:17:51 -08:00
|
|
|
$(CONFIGPATH) \
|
2015-07-10 06:01:56 -07:00
|
|
|
config/engines \
|
|
|
|
config \
|
|
|
|
ext \
|
|
|
|
ext_algo \
|
2016-02-11 18:03:53 -08:00
|
|
|
console_util \
|
2015-07-10 06:01:56 -07:00
|
|
|
console \
|
2017-03-15 19:42:54 -07:00
|
|
|
$(PROJECT_DIR)/console/binary \
|
|
|
|
$(PROJECT_DIR)/console/fl_binary \
|
|
|
|
$(PROJECT_DIR)/hw_layer \
|
2016-06-10 12:01:47 -07:00
|
|
|
$(PROJECT_DIR)/mass_storage \
|
2015-07-10 06:01:56 -07:00
|
|
|
hw_layer/serial_over_usb \
|
|
|
|
hw_layer/algo \
|
|
|
|
hw_layer/lcd \
|
2019-04-02 20:19:21 -07:00
|
|
|
$(HW_SENSORS_INC) \
|
2016-07-05 08:03:11 -07:00
|
|
|
hw_layer/mass_storage \
|
2018-11-16 04:40:06 -08:00
|
|
|
hw_layer/$(CPU_HWLAYER) \
|
2019-03-12 07:12:37 -07:00
|
|
|
$(HW_LAYER_DRIVERS_INC) \
|
2019-03-31 13:33:16 -07:00
|
|
|
$(UTIL_INC) \
|
2015-07-10 06:01:56 -07:00
|
|
|
development \
|
|
|
|
development/hw_layer \
|
|
|
|
development/test \
|
2019-04-04 22:02:34 -07:00
|
|
|
$(CONTROLLERS_INC) \
|
2015-07-10 06:01:56 -07:00
|
|
|
controllers/sensors \
|
|
|
|
controllers/system \
|
|
|
|
controllers/algo \
|
|
|
|
controllers/core \
|
|
|
|
controllers/math \
|
2017-01-02 12:03:26 -08:00
|
|
|
controllers/trigger/decoders \
|
2015-07-10 06:01:56 -07:00
|
|
|
controllers/trigger
|
|
|
|
|
|
|
|
#
|
|
|
|
# Project, sources and paths
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Compiler settings
|
|
|
|
#
|
|
|
|
|
|
|
|
MCU = cortex-m4
|
|
|
|
|
2019-04-09 16:12:35 -07:00
|
|
|
ifeq ($(CROSS_COMPILE),)
|
|
|
|
TRGT = arm-none-eabi-
|
|
|
|
else
|
|
|
|
TRGT = $(CROSS_COMPILE)
|
|
|
|
endif
|
2019-04-20 18:31:24 -07:00
|
|
|
CC = $(CCPREFIX) $(TRGT)gcc
|
|
|
|
CPPC = $(CCPREFIX) $(TRGT)g++
|
2015-07-10 06:01:56 -07:00
|
|
|
# Enable loading with g++ only if you need C++ runtime support.
|
|
|
|
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
|
|
|
# runtime support makes code size explode.
|
|
|
|
LD = $(TRGT)gcc
|
|
|
|
#LD = $(TRGT)g++
|
|
|
|
CP = $(TRGT)objcopy
|
|
|
|
AS = $(TRGT)gcc -x assembler-with-cpp
|
2017-03-22 04:08:20 -07:00
|
|
|
AR = $(TRGT)ar
|
2015-07-10 06:01:56 -07:00
|
|
|
OD = $(TRGT)objdump
|
|
|
|
SZ = $(TRGT)size
|
|
|
|
HEX = $(CP) -O ihex
|
|
|
|
BIN = $(CP) -O binary
|
|
|
|
|
|
|
|
# ARM-specific options here
|
|
|
|
AOPT =
|
|
|
|
|
|
|
|
# THUMB-specific options here
|
|
|
|
TOPT = -mthumb -DTHUMB
|
|
|
|
|
|
|
|
# Define C warning options here
|
|
|
|
CWARN = -Wall -Wextra -Wstrict-prototypes
|
|
|
|
|
|
|
|
# Define C++ warning options here
|
|
|
|
CPPWARN = -Wall -Wextra
|
|
|
|
|
|
|
|
#
|
|
|
|
# Compiler settings
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Start of user section
|
|
|
|
#
|
|
|
|
|
|
|
|
# List all user C define here, like -D_DEBUG=1
|
|
|
|
UDEFS =
|
|
|
|
|
|
|
|
# Define ASM defines here
|
|
|
|
UADEFS =
|
|
|
|
|
|
|
|
# List all user directories here
|
|
|
|
UINCDIR =
|
|
|
|
|
|
|
|
# List the user directory to look for the libraries here
|
|
|
|
ULIBDIR =
|
|
|
|
|
|
|
|
# List all user libraries here
|
|
|
|
ULIBS = -lm
|
|
|
|
|
|
|
|
#
|
|
|
|
# End of user defines
|
|
|
|
##############################################################################
|
|
|
|
|
2018-12-15 21:21:15 -08:00
|
|
|
include $(RULESFILE)
|