2014-01-09 06:20:26 -08:00
|
|
|
##############################################################################
|
|
|
|
# Build global options
|
|
|
|
# NOTE: Can be overridden externally.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Compiler options here.
|
|
|
|
ifeq ($(USE_OPT),)
|
2016-06-27 08:29:09 -07:00
|
|
|
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -D_GNU_SOURCE
|
2015-08-23 09:26:05 -07:00
|
|
|
USE_OPT += -DBOARD_OTG_NOVBUSSENS $(build_args)
|
2020-03-31 07:42:11 -07:00
|
|
|
USE_OPT += -fsingle-precision-constant -Wdouble-promotion -specs=nosys.specs
|
2014-01-09 06:20:26 -08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# C specific options here (added to USE_OPT).
|
|
|
|
ifeq ($(USE_COPT),)
|
|
|
|
USE_COPT =
|
|
|
|
endif
|
|
|
|
|
|
|
|
# C++ specific options here (added to USE_OPT).
|
|
|
|
ifeq ($(USE_CPPOPT),)
|
|
|
|
USE_CPPOPT = -fno-rtti
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Enable this if you want the linker to remove unused code and data
|
|
|
|
ifeq ($(USE_LINK_GC),)
|
|
|
|
USE_LINK_GC = yes
|
|
|
|
endif
|
|
|
|
|
2015-10-08 14:09:39 -07:00
|
|
|
# Linker extra options here.
|
|
|
|
ifeq ($(USE_LDOPT),)
|
|
|
|
USE_LDOPT =
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Enable this if you want link time optimizations (LTO)
|
|
|
|
ifeq ($(USE_LTO),)
|
|
|
|
USE_LTO = no
|
|
|
|
endif
|
|
|
|
|
2014-01-09 06:20:26 -08:00
|
|
|
# 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 = yes
|
|
|
|
endif
|
|
|
|
|
2015-10-08 14:09:39 -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 = yes
|
|
|
|
endif
|
|
|
|
|
2014-01-09 06:20:26 -08:00
|
|
|
#
|
|
|
|
# Build global options
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Architecture or project specific options
|
|
|
|
#
|
|
|
|
|
2015-10-08 14:09:39 -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),)
|
2017-09-04 12:12:43 -07:00
|
|
|
USE_PROCESS_STACKSIZE = 0x800
|
2015-10-08 14:09:39 -07:00
|
|
|
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),)
|
2017-09-04 12:12:43 -07:00
|
|
|
USE_EXCEPTIONS_STACKSIZE = 0x800
|
2015-10-08 14:09:39 -07:00
|
|
|
endif
|
|
|
|
|
2015-01-04 20:48:29 -08:00
|
|
|
# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
|
2014-01-09 06:20:26 -08:00
|
|
|
ifeq ($(USE_FPU),)
|
2015-01-04 20:48:29 -08:00
|
|
|
USE_FPU = hard
|
2014-01-09 06:20:26 -08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Enable this if you really want to use the STM FWLib.
|
|
|
|
ifeq ($(USE_FWLIB),)
|
|
|
|
USE_FWLIB = yes
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Architecture or project specific options
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Project, sources and paths
|
|
|
|
#
|
|
|
|
|
|
|
|
# Define project name here
|
|
|
|
PROJECT = BLDC_4_ChibiOS
|
|
|
|
|
|
|
|
# Imported source files and paths
|
2020-03-21 12:14:20 -07:00
|
|
|
CHIBIOS = ChibiOS_3.0.5
|
2017-09-06 12:13:28 -07:00
|
|
|
# Startup files
|
2015-10-08 14:09:39 -07:00
|
|
|
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
|
2017-09-06 12:13:28 -07:00
|
|
|
# HAL-OSAL files
|
2014-01-09 06:20:26 -08:00
|
|
|
include $(CHIBIOS)/os/hal/hal.mk
|
2015-10-08 14:09:39 -07:00
|
|
|
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
|
|
|
|
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
|
2017-09-06 12:13:28 -07:00
|
|
|
# RTOS files
|
2015-10-08 14:09:39 -07:00
|
|
|
include $(CHIBIOS)/os/rt/rt.mk
|
|
|
|
include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
2017-09-06 12:13:28 -07:00
|
|
|
# Other files
|
2014-04-18 15:09:46 -07:00
|
|
|
include hwconf/hwconf.mk
|
|
|
|
include applications/applications.mk
|
2015-04-11 01:07:36 -07:00
|
|
|
include nrf/nrf.mk
|
2019-02-18 10:30:19 -08:00
|
|
|
include libcanard/canard.mk
|
2019-03-10 06:57:42 -07:00
|
|
|
include imu/imu.mk
|
2021-03-27 13:13:24 -07:00
|
|
|
include lora/lora.mk
|
2019-10-25 13:37:35 -07:00
|
|
|
include compression/compression.mk
|
2019-03-31 01:49:18 -07:00
|
|
|
include blackmagic/blackmagic.mk
|
2014-01-09 06:20:26 -08:00
|
|
|
|
|
|
|
# Define linker script file here
|
2014-09-14 17:39:58 -07:00
|
|
|
LDSCRIPT= ld_eeprom_emu.ld
|
2014-01-09 06:20:26 -08:00
|
|
|
|
|
|
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
|
|
|
# setting.
|
2015-10-08 14:09:39 -07:00
|
|
|
CSRC = $(STARTUPSRC) \
|
2014-01-09 06:20:26 -08:00
|
|
|
$(KERNSRC) \
|
2015-10-08 14:09:39 -07:00
|
|
|
$(PORTSRC) \
|
|
|
|
$(OSALSRC) \
|
2014-01-09 06:20:26 -08:00
|
|
|
$(HALSRC) \
|
|
|
|
$(PLATFORMSRC) \
|
2015-10-08 14:09:39 -07:00
|
|
|
$(CHIBIOS)/os/hal/lib/streams/chprintf.c \
|
2014-01-09 06:20:26 -08:00
|
|
|
$(CHIBIOS)/os/various/syscalls.c \
|
2017-09-06 12:13:28 -07:00
|
|
|
board.c \
|
2014-01-09 06:20:26 -08:00
|
|
|
main.c \
|
2015-10-08 14:09:39 -07:00
|
|
|
comm_usb_serial.c \
|
2014-01-09 06:20:26 -08:00
|
|
|
irq_handlers.c \
|
|
|
|
buffer.c \
|
2014-09-19 18:22:38 -07:00
|
|
|
comm_usb.c \
|
2014-01-09 06:20:26 -08:00
|
|
|
crc.c \
|
|
|
|
digital_filter.c \
|
|
|
|
ledpwm.c \
|
|
|
|
mcpwm.c \
|
|
|
|
servo_dec.c \
|
|
|
|
utils.c \
|
2015-07-31 14:26:50 -07:00
|
|
|
servo_simple.c \
|
2014-01-09 06:20:26 -08:00
|
|
|
packet.c \
|
2014-04-12 12:59:33 -07:00
|
|
|
terminal.c \
|
2014-09-14 14:08:22 -07:00
|
|
|
conf_general.c \
|
|
|
|
eeprom.c \
|
2014-09-19 18:22:38 -07:00
|
|
|
commands.c \
|
2014-09-20 04:41:18 -07:00
|
|
|
timeout.c \
|
2014-12-06 19:30:25 -08:00
|
|
|
comm_can.c \
|
2014-12-08 15:11:29 -08:00
|
|
|
ws2811.c \
|
|
|
|
led_external.c \
|
2015-04-11 01:07:36 -07:00
|
|
|
encoder.c \
|
2015-05-08 13:53:59 -07:00
|
|
|
flash_helper.c \
|
2015-12-08 12:01:23 -08:00
|
|
|
mc_interface.c \
|
|
|
|
mcpwm_foc.c \
|
2019-02-18 10:30:19 -08:00
|
|
|
gpdrive.c \
|
2019-03-01 12:36:58 -08:00
|
|
|
confgenerator.c \
|
2019-03-10 06:57:42 -07:00
|
|
|
timer.c \
|
|
|
|
i2c_bb.c \
|
2020-06-29 07:26:39 -07:00
|
|
|
spi_bb.c \
|
2019-04-06 06:36:00 -07:00
|
|
|
virtual_motor.c \
|
2019-09-03 11:39:05 -07:00
|
|
|
shutdown.c \
|
2020-03-16 10:32:39 -07:00
|
|
|
mempools.c \
|
|
|
|
worker.c \
|
2020-10-21 23:32:51 -07:00
|
|
|
bms.c \
|
2014-04-18 15:09:46 -07:00
|
|
|
$(HWSRC) \
|
2015-04-11 01:07:36 -07:00
|
|
|
$(APPSRC) \
|
2019-02-18 10:30:19 -08:00
|
|
|
$(NRFSRC) \
|
2019-03-10 06:57:42 -07:00
|
|
|
$(CANARDSRC) \
|
2019-03-20 14:46:36 -07:00
|
|
|
$(IMUSRC) \
|
2021-03-27 13:13:24 -07:00
|
|
|
$(LORASRC) \
|
2019-10-25 13:37:35 -07:00
|
|
|
$(COMPRESSIONSRC) \
|
2021-04-24 13:36:00 -07:00
|
|
|
$(BLACKMAGICSRC) \
|
|
|
|
qmlui/qmlui.c
|
2015-10-08 14:09:39 -07:00
|
|
|
|
2014-01-09 06:20:26 -08:00
|
|
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
|
|
|
# setting.
|
|
|
|
CPPSRC =
|
|
|
|
|
|
|
|
# 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
|
2015-10-08 14:09:39 -07:00
|
|
|
ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
|
2014-01-09 06:20:26 -08:00
|
|
|
|
2015-10-08 14:09:39 -07:00
|
|
|
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
|
2017-09-06 12:13:28 -07:00
|
|
|
$(HALINC) $(PLATFORMINC) \
|
2014-04-14 14:02:45 -07:00
|
|
|
$(CHIBIOS)/os/various \
|
2015-12-08 12:01:23 -08:00
|
|
|
$(CHIBIOS)/os/hal/lib/streams \
|
2014-04-14 14:02:45 -07:00
|
|
|
mcconf \
|
2015-09-17 14:24:55 -07:00
|
|
|
appconf \
|
2014-04-18 15:09:46 -07:00
|
|
|
$(HWINC) \
|
2015-04-11 01:07:36 -07:00
|
|
|
$(APPINC) \
|
2019-02-18 10:30:19 -08:00
|
|
|
$(NRFINC) \
|
2019-03-10 06:57:42 -07:00
|
|
|
$(CANARDINC) \
|
2019-03-20 14:46:36 -07:00
|
|
|
$(IMUINC) \
|
2021-03-27 13:13:24 -07:00
|
|
|
$(LORAINC) \
|
2019-10-25 13:37:35 -07:00
|
|
|
$(COMPRESSIONINC) \
|
2021-04-24 13:36:00 -07:00
|
|
|
$(BLACKMAGICINC) \
|
|
|
|
qmlui \
|
|
|
|
qmlui/hw \
|
|
|
|
qmlui/app
|
2014-01-09 06:20:26 -08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Project, sources and paths
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# Compiler settings
|
|
|
|
#
|
|
|
|
|
|
|
|
MCU = cortex-m4
|
|
|
|
|
|
|
|
#TRGT = arm-elf-
|
2021-01-11 02:49:36 -08:00
|
|
|
#TRGT = /home/benjamin/Nextcloud/appimage/gcc-arm-none-eabi-7-2018-q2-update/bin/arm-none-eabi-
|
2014-01-09 06:20:26 -08:00
|
|
|
TRGT = arm-none-eabi-
|
|
|
|
CC = $(TRGT)gcc
|
|
|
|
CPPC = $(TRGT)g++
|
|
|
|
# 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
|
2015-10-08 14:09:39 -07:00
|
|
|
AR = $(TRGT)ar
|
2014-01-09 06:20:26 -08:00
|
|
|
OD = $(TRGT)objdump
|
2015-10-08 14:09:39 -07:00
|
|
|
SZ = $(TRGT)size
|
2014-01-09 06:20:26 -08:00
|
|
|
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
|
2019-01-28 11:52:02 -08:00
|
|
|
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -Wshadow
|
2014-01-09 06:20:26 -08:00
|
|
|
|
|
|
|
# Define C++ warning options here
|
2015-10-08 14:09:39 -07:00
|
|
|
CPPWARN = -Wall -Wextra -Wundef
|
2014-01-09 06:20:26 -08:00
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
ifeq ($(USE_FWLIB),yes)
|
|
|
|
include $(CHIBIOS)/ext/stdperiph_stm32f4/stm32lib.mk
|
|
|
|
CSRC += $(STM32SRC)
|
|
|
|
INCDIR += $(STM32INC)
|
|
|
|
USE_OPT += -DUSE_STDPERIPH_DRIVER
|
|
|
|
endif
|
|
|
|
|
2020-12-24 05:10:22 -08:00
|
|
|
RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
|
|
|
|
include $(RULESPATH)/rules.mk
|
|
|
|
|
2014-01-09 06:20:26 -08:00
|
|
|
build/$(PROJECT).bin: build/$(PROJECT).elf
|
2019-04-18 13:30:01 -07:00
|
|
|
$(BIN) build/$(PROJECT).elf build/$(PROJECT).bin --gap-fill 0xFF
|
2014-01-09 06:20:26 -08:00
|
|
|
|
|
|
|
# Program
|
|
|
|
upload: build/$(PROJECT).bin
|
2020-10-09 12:08:48 -07:00
|
|
|
openocd -f board/stm32f4discovery.cfg -c "reset_config trst_only combined" -c "program build/$(PROJECT).elf verify reset exit"
|
|
|
|
|
|
|
|
upload_only:
|
|
|
|
openocd -f board/stm32f4discovery.cfg -c "reset_config trst_only combined" -c "program build/$(PROJECT).elf verify reset exit"
|
2014-01-09 06:20:26 -08:00
|
|
|
|
2019-05-19 01:16:12 -07:00
|
|
|
clear_option_bytes:
|
|
|
|
openocd -f board/stm32f4discovery.cfg -c "init" -c "stm32f2x unlock 0" -c "mww 0x40023C08 0x08192A3B; mww 0x40023C08 0x4C5D6E7F; mww 0x40023C14 0x0fffaaed" -c "exit"
|
|
|
|
|
2015-10-06 03:50:48 -07:00
|
|
|
#program with olimex arm-usb-tiny-h and jtag-swd adapter board. needs openocd>=0.9
|
|
|
|
upload-olimex: build/$(PROJECT).bin
|
|
|
|
openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x.cfg -c "program build/$(PROJECT).elf verify reset"
|
|
|
|
|
2017-09-04 12:12:43 -07:00
|
|
|
upload-pi: build/$(PROJECT).bin
|
|
|
|
openocd -f pi_stm32.cfg -c "reset_config trst_only combined" -c "program build/$(PROJECT).elf verify reset exit"
|
|
|
|
|
|
|
|
upload-pi-remote: build/$(PROJECT).elf
|
|
|
|
./upload_remote_pi build/$(PROJECT).elf ted 10.42.0.199 22
|
|
|
|
|
2014-01-09 06:20:26 -08:00
|
|
|
debug-start:
|
|
|
|
openocd -f stm32-bv_openocd.cfg
|