2021-07-05 12:08:11 -07:00
|
|
|
#
|
|
|
|
# this Makefile is intended to be invoked from one level above - see ..\compile_bootloader.sh
|
2017-05-30 15:38:51 -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),)
|
2021-01-31 11:13:55 -08:00
|
|
|
# this value would be used by default. For 'debug' configuration override with '-O0 -ggdb -g' or something along these lines
|
2017-05-30 15:38:51 -07:00
|
|
|
DEBUG_LEVEL_OPT = -O2
|
2019-12-02 16:11:07 -08:00
|
|
|
DDEFS += -DEFI_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE
|
2017-05-30 15:38:51 -07:00
|
|
|
endif
|
|
|
|
|
2022-02-05 12:57:11 -08:00
|
|
|
# let everyone know that we are compiling bootloader
|
|
|
|
IS_RE_BOOTLOADER = yes
|
|
|
|
|
2017-05-30 15:38:51 -07:00
|
|
|
# disable some modules to shrink bootloader binary
|
2021-02-24 11:08:03 -08:00
|
|
|
DDEFS += -DEFI_BOOTLOADER
|
2021-05-20 13:05:18 -07:00
|
|
|
DDEFS += -DHAL_USE_EXT=FALSE -DHAL_USE_ICU=FALSE -DHAL_USE_PWM=FALSE -DHAL_USE_RTC=FALSE -DEF_LUA=FALSE
|
2022-02-05 12:57:11 -08:00
|
|
|
#disable ChibiOS flash driver and prevent header from include
|
2020-04-25 22:25:41 -07:00
|
|
|
DDEFS += -DHAL_USE_FLASH=FALSE
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2021-03-28 06:06:36 -07:00
|
|
|
DDEFS += -DEFI_USE_UART_DMA=FALSE
|
2020-06-21 20:22:45 -07:00
|
|
|
|
2017-05-30 15:38:51 -07:00
|
|
|
# disable USB (The bootloader has currently UART support only)
|
2021-02-24 11:08:03 -08:00
|
|
|
DDEFS += -DEFI_USB_SERIAL=FALSE
|
2019-03-22 08:38:18 -07:00
|
|
|
# disable CAN
|
|
|
|
DDEFS += -DEFI_CAN_SUPPORT=FALSE
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2020-11-11 17:34:39 -08:00
|
|
|
DDEFS += -DEFI_UNIT_TEST=0 -DEFI_PROD_CODE=1 -DEFI_SIMULATOR=0
|
|
|
|
|
2017-05-30 15:38:51 -07:00
|
|
|
# Compiler options here.
|
|
|
|
ifeq ($(USE_OPT),)
|
2019-11-19 17:43:12 -08:00
|
|
|
USE_OPT = $(EXTRA_PARAMS) $(DEBUG_LEVEL_OPT) $(RFLAGS) -Wno-error=implicit-fallthrough -Wno-error=bool-operation -fomit-frame-pointer -falign-functions=16 -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Werror=type-limits -Wno-error=strict-aliasing -Wno-error=attributes
|
2017-05-30 15:38:51 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
# C specific options here (added to USE_OPT).
|
|
|
|
ifeq ($(USE_COPT),)
|
2019-11-19 17:43:12 -08:00
|
|
|
USE_COPT = -fgnu89-inline -std=gnu99 -Werror-implicit-function-declaration
|
2017-05-30 15:38:51 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
# C++ specific options here (added to USE_OPT).
|
|
|
|
ifeq ($(USE_CPPOPT),)
|
2019-03-22 08:38:18 -07:00
|
|
|
# constexpr float expf_taylor_impl probably needs just c++14 but why not go with 17?
|
2022-10-18 19:30:16 -07:00
|
|
|
USE_CPPOPT = -std=c++20 -Wno-register -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits -Winvalid-pch
|
|
|
|
# gcc-10 c++ 20 depricated uses of volatile errors
|
|
|
|
USE_CPPOPT += -Wno-deprecated
|
2017-05-30 15:38:51 -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
|
|
|
|
|
2019-04-20 18:44:00 -07:00
|
|
|
ifeq ($(CCACHE_DIR),)
|
|
|
|
$(info No CCACHE_DIR)
|
|
|
|
else
|
|
|
|
$(info CCACHE_DIR is ${CCACHE_DIR})
|
|
|
|
CCPREFIX=ccache
|
|
|
|
endif
|
|
|
|
|
2017-05-30 15:38:51 -07:00
|
|
|
# Linker extra options here.
|
|
|
|
ifeq ($(USE_LDOPT),)
|
|
|
|
USE_LDOPT =
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Enable this if you want link time optimizations (LTO)
|
|
|
|
ifeq ($(USE_LTO),)
|
2021-05-20 13:05:18 -07:00
|
|
|
USE_LTO = yes
|
2017-05-30 15:38:51 -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
|
|
|
|
|
|
|
|
# If enabled, this option makes the build process faster by not compiling
|
|
|
|
# modules not used in the current configuration.
|
|
|
|
ifeq ($(USE_SMART_BUILD),)
|
2021-02-10 16:38:24 -08:00
|
|
|
USE_SMART_BUILD = no
|
2017-05-30 15:38:51 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build global options
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Architecture or project specific options
|
|
|
|
#
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
|
|
|
|
ifeq ($(USE_FPU),)
|
|
|
|
USE_FPU = softfp
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Architecture or project specific options
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Project, sources and paths
|
|
|
|
#
|
|
|
|
|
|
|
|
# Define project name here
|
|
|
|
PROJECT = bootloader
|
2021-07-05 12:08:11 -07:00
|
|
|
PROJECT_DIR = ..
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2021-07-25 18:23:23 -07:00
|
|
|
# Configure precompiled header
|
|
|
|
PCH_DIR = $(PROJECT_DIR)/pch
|
|
|
|
PCHSRC = $(PCH_DIR)/pch.h
|
2021-11-08 12:52:58 -08:00
|
|
|
PCHSUB = bootloader
|
2021-07-25 18:23:23 -07:00
|
|
|
|
2017-05-30 15:38:51 -07:00
|
|
|
# Imported source files and paths
|
2019-03-22 08:38:18 -07:00
|
|
|
CHIBIOS = $(PROJECT_DIR)/ChibiOS
|
2021-07-05 08:51:54 -07:00
|
|
|
# todo: looks like 'CHIBIOS_CONTRIB' path is universal shall we defined it only once?
|
|
|
|
CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2022-07-15 23:22:51 -07:00
|
|
|
# Configure libfirmware Paths/Includes
|
|
|
|
RUSEFI_LIB = $(PROJECT_DIR)/libfirmware
|
|
|
|
include $(RUSEFI_LIB)/util/util.mk
|
2022-08-08 05:53:08 -07:00
|
|
|
include $(RUSEFI_LIB)/pt2001/pt2001.mk
|
2022-07-15 23:22:51 -07:00
|
|
|
|
2021-01-19 12:20:35 -08:00
|
|
|
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
|
2019-03-22 08:38:18 -07:00
|
|
|
RULESFILE = $(RULESPATH)/rules.mk
|
|
|
|
|
|
|
|
include $(PROJECT_DIR)/rusefi.mk
|
2017-05-30 15:38:51 -07:00
|
|
|
|
|
|
|
CONFIG = $(PROJECT_DIR)/config
|
|
|
|
|
2021-01-19 12:20:35 -08:00
|
|
|
# Include various ChibiOS mk files
|
|
|
|
# Licensing files.
|
|
|
|
include $(CHIBIOS)/os/license/license.mk
|
2017-05-30 15:38:51 -07:00
|
|
|
# Startup files.
|
2019-03-22 08:38:18 -07:00
|
|
|
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/$(CPU_STARTUP)
|
2017-05-30 15:38:51 -07:00
|
|
|
# HAL-OSAL files (optional).
|
|
|
|
include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
|
2021-07-05 11:18:05 -07:00
|
|
|
include $(CPU_PLATFORM)
|
2021-01-19 12:20:35 -08:00
|
|
|
include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
|
2017-05-30 15:38:51 -07:00
|
|
|
# RTOS files (optional).
|
|
|
|
include $(CHIBIOS)/os/rt/rt.mk
|
2019-03-22 08:38:18 -07:00
|
|
|
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
2020-10-15 05:57:13 -07:00
|
|
|
include $(CHIBIOS)/os/various/cpp_wrappers/chcpp.mk
|
2021-01-19 12:20:35 -08:00
|
|
|
# EX files (optional).
|
|
|
|
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2023-02-01 11:41:27 -08:00
|
|
|
BOARDINC = $(BOARD_DIR)
|
|
|
|
include $(BOARD_DIR)/board.mk
|
2020-02-08 13:34:29 -08:00
|
|
|
include $(PROJECT_DIR)/init/init.mk
|
2019-03-31 23:23:18 -07:00
|
|
|
include $(PROJECT_DIR)/util/util.mk
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2019-04-04 22:24:42 -07:00
|
|
|
include $(PROJECT_DIR)/controllers/controllers.mk
|
2019-03-29 07:46:16 -07:00
|
|
|
include $(PROJECT_DIR)/hw_layer/$(CPU_HWLAYER)/hw_ports.mk
|
2019-07-09 03:06:07 -07:00
|
|
|
include $(PROJECT_DIR)/hw_layer/drivers/drivers.mk
|
2019-03-22 08:38:18 -07:00
|
|
|
|
2017-05-30 15:38:51 -07:00
|
|
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
|
|
|
# setting.
|
2021-01-19 12:20:35 -08:00
|
|
|
CSRC = $(ALLCSRC) \
|
2022-01-04 16:27:49 -08:00
|
|
|
$(BOARDSRC) \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(DEV_SRC) \
|
|
|
|
$(HW_LAYER_EMS) \
|
2019-07-09 03:06:07 -07:00
|
|
|
$(HW_LAYER_DRIVERS_CORE) \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(FATFSSRC) \
|
|
|
|
|
|
|
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
2022-02-06 19:00:49 -08:00
|
|
|
# todo: reduce code duplication with primary Makefile!!!
|
2017-05-30 15:38:51 -07:00
|
|
|
# setting.
|
2021-01-19 12:20:35 -08:00
|
|
|
CPPSRC = $(ALLCPPSRC) \
|
2020-03-13 19:12:52 -07:00
|
|
|
$(HW_LAYER_EMS_CPP) \
|
2022-02-06 19:00:49 -08:00
|
|
|
$(BOARDCPPSRC) \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(HW_SENSORS_SRC) \
|
|
|
|
$(TUNERSTUDIO_SRC_CPP) \
|
|
|
|
$(CONSOLE_SRC_CPP) \
|
|
|
|
$(PROJECT_DIR)/console/binary/tunerstudio_io.cpp \
|
2021-03-28 06:06:36 -07:00
|
|
|
$(PROJECT_DIR)/console/binary/tunerstudio_io_serial.cpp \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/controllers/algo/engine_configuration.cpp \
|
2017-06-04 12:01:40 -07:00
|
|
|
$(PROJECT_DIR)/controllers/persistent_store.cpp \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/hw_layer/io_pins.cpp \
|
2019-03-28 04:38:15 -07:00
|
|
|
$(PROJECT_DIR)/util/efilib.cpp \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/hw_layer/pin_repository.cpp \
|
2022-07-15 23:22:51 -07:00
|
|
|
$(RUSEFI_LIB_CPP) \
|
2017-05-30 15:38:51 -07:00
|
|
|
src/rusefi_stubs.cpp \
|
|
|
|
src/dfu.cpp \
|
|
|
|
src/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
|
|
|
|
# List ASM source files here
|
2019-03-22 08:38:18 -07:00
|
|
|
ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
|
2017-05-30 15:38:51 -07:00
|
|
|
|
2021-01-19 12:20:35 -08:00
|
|
|
INCDIR = $(ALLINC) \
|
2021-07-25 18:23:23 -07:00
|
|
|
$(PCH_DIR) \
|
2021-07-05 12:08:11 -07:00
|
|
|
.. \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(CHIBIOS)/os/various \
|
2019-03-22 08:38:18 -07:00
|
|
|
$(CHIBIOS)/os/ex/ST \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(CONFIG)/engines \
|
2019-04-21 05:51:52 -07:00
|
|
|
$(CONFIG) \
|
2021-02-10 16:38:24 -08:00
|
|
|
$(CONFDIR) \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/ext \
|
|
|
|
$(PROJECT_DIR)/ext_algo \
|
2019-03-31 23:23:18 -07:00
|
|
|
$(UTIL_INC) \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/console_util \
|
|
|
|
$(PROJECT_DIR)/console \
|
|
|
|
$(PROJECT_DIR)/console/binary \
|
2020-05-17 12:56:37 -07:00
|
|
|
$(PROJECT_DIR)/console/binary_log \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/console/fl_binary \
|
|
|
|
$(PROJECT_DIR)/hw_layer \
|
2020-08-02 18:04:50 -07:00
|
|
|
$(PROJECT_DIR)/hw_layer/adc \
|
|
|
|
$(PROJECT_DIR)/hw_layer/mass_storage \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/hw_layer/algo \
|
|
|
|
$(PROJECT_DIR)/hw_layer/sensors \
|
2020-03-13 17:30:07 -07:00
|
|
|
$(PROJECT_DIR)/hw_layer/ports \
|
2022-01-06 17:16:59 -08:00
|
|
|
$(PROJECT_DIR)/console/binary/generated \
|
2020-03-13 17:30:07 -07:00
|
|
|
$(PROJECT_DIR)/hw_layer/$(CPU_HWLAYER) \
|
2019-08-03 17:09:18 -07:00
|
|
|
$(HW_INC) \
|
2019-07-09 03:06:07 -07:00
|
|
|
$(HW_LAYER_DRIVERS_INC) \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/development \
|
|
|
|
$(PROJECT_DIR)/development/hw_layer \
|
|
|
|
$(PROJECT_DIR)/development/test \
|
2019-04-04 22:24:42 -07:00
|
|
|
$(CONTROLLERS_INC) \
|
2017-05-30 15:38:51 -07:00
|
|
|
$(PROJECT_DIR)/controllers/sensors \
|
2020-02-08 13:34:29 -08:00
|
|
|
$(PROJECT_DIR)/init \
|
2022-07-15 23:22:51 -07:00
|
|
|
$(RUSEFI_LIB_INC) \
|
2017-05-30 15:38:51 -07:00
|
|
|
config
|
|
|
|
|
|
|
|
BUILDDIR=blbuild
|
|
|
|
|
|
|
|
#
|
|
|
|
# Project, sources and paths
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Compiler settings
|
|
|
|
#
|
|
|
|
|
|
|
|
MCU = cortex-m4
|
|
|
|
|
2021-01-19 12:20:35 -08:00
|
|
|
ifeq ($(CROSS_COMPILE),)
|
|
|
|
#TRGT = arm-elf-
|
|
|
|
TRGT = arm-none-eabi-
|
|
|
|
else
|
|
|
|
TRGT = $(CROSS_COMPILE)
|
|
|
|
endif
|
2019-04-20 18:44:00 -07:00
|
|
|
CC = $(CCPREFIX) $(TRGT)gcc
|
|
|
|
CPPC = $(CCPREFIX) $(TRGT)g++
|
2017-05-30 15:38:51 -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
|
|
|
|
AR = $(TRGT)ar
|
|
|
|
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
|
2021-04-28 19:41:25 -07:00
|
|
|
ULIBS = -lm --specs=nano.specs
|
2017-05-30 15:38:51 -07:00
|
|
|
|
|
|
|
#
|
|
|
|
# End of user defines
|
|
|
|
##############################################################################
|
|
|
|
|
2019-03-22 08:38:18 -07:00
|
|
|
include $(RULESFILE)
|
2021-07-25 18:23:23 -07:00
|
|
|
include $(PROJECT_DIR)/rusefi_pch.mk
|