sentry_gimbal_hzz/Makefile

349 lines
12 KiB
Makefile
Raw Normal View History

2022-10-20 17:13:02 +08:00
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.17.1] date: [Thu Oct 20 16:31:27 CST 2022]
##########################################################################################################################
# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
# 2017-02-10 - Several enhancements + project update mode
# 2015-07-22 - first version
# ------------------------------------------------
######################################
# target
######################################
TARGET = basic_framework
######################################
# building variables
######################################
# debug build?
DEBUG = 1
# optimization
2022-12-03 21:39:31 +08:00
OPT = -O0 # O0避免没有使用到的变量被优化,如果没有特殊的调试需求请修改成-Og.
# 为了更高的性能,正式上车不需要调试时修改成-O3
2022-10-20 17:13:02 +08:00
#######################################
# paths
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
# C sources
C_SOURCES = \
2022-11-03 18:19:06 +08:00
HAL_N_Middlewares/Src/main.c \
HAL_N_Middlewares/Src/gpio.c \
2022-12-26 15:40:20 +08:00
HAL_N_Middlewares/Src/i2c.c \
2022-11-03 18:19:06 +08:00
HAL_N_Middlewares/Src/adc.c \
HAL_N_Middlewares/Src/can.c \
HAL_N_Middlewares/Src/dma.c \
HAL_N_Middlewares/Src/rng.c \
HAL_N_Middlewares/Src/rtc.c \
HAL_N_Middlewares/Src/spi.c \
HAL_N_Middlewares/Src/tim.c \
HAL_N_Middlewares/Src/usart.c \
HAL_N_Middlewares/Src/usb_device.c \
HAL_N_Middlewares/Src/usbd_conf.c \
HAL_N_Middlewares/Src/usbd_desc.c \
HAL_N_Middlewares/Src/usbd_cdc_if.c \
HAL_N_Middlewares/Src/stm32f4xx_it.c \
HAL_N_Middlewares/Src/stm32f4xx_hal_msp.c \
HAL_N_Middlewares/Src/system_stm32f4xx.c \
HAL_N_Middlewares/Src/freertos.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
2022-12-26 15:40:20 +08:00
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \
2022-11-03 18:19:06 +08:00
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \
HAL_N_Middlewares/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \
HAL_N_Middlewares/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
HAL_N_Middlewares/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
HAL_N_Middlewares/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/list.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/queue.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/timers.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \
HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
2022-11-11 21:20:58 +08:00
HAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT/SEGGER_RTT_printf.c \
HAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT/SEGGER_RTT.c \
bsp/dwt/bsp_dwt.c \
bsp/pwm/bsp_pwm.c \
2023-01-01 17:32:22 +08:00
bsp/bsp_legacy_support/bsp_temperature.c \
bsp/bsp_legacy_support/bsp_buzzer.c \
bsp/bsp_legacy_support/bsp_led.c \
2023-02-02 14:15:57 +08:00
bsp/gpio/bsp_gpio.c \
bsp/spi/bsp_spi.c \
bsp/iic/bsp_iic.c \
bsp/can/bsp_can.c \
bsp/usart/bsp_usart.c \
bsp/log/bsp_log.c \
2022-11-12 18:03:18 +08:00
bsp/bsp_init.c \
2022-10-20 17:13:02 +08:00
modules/algorithm/controller.c \
modules/algorithm/kalman_filter.c \
modules/algorithm/QuaternionEKF.c \
modules/algorithm/crc8.c \
modules/algorithm/crc16.c \
modules/algorithm/user_lib.c \
modules/BMI088/bmi088.c \
2022-10-20 17:13:02 +08:00
modules/imu/BMI088driver.c \
modules/imu/BMI088Middleware.c \
modules/imu/ins_task.c \
modules/ist8310/ist8310.c \
2023-01-01 17:32:22 +08:00
modules/led/led_task.c \
2022-10-20 17:13:02 +08:00
modules/master_machine/master_process.c \
modules/master_machine/seasky_protocol.c \
2023-01-02 23:20:35 +08:00
modules/motor/DJImotor/dji_motor.c \
modules/motor/HTmotor/HT04.c \
modules/motor/LKmotor/LK9025.c \
modules/motor/step_motor/step_motor.c \
modules/motor/servo_motor/servo_motor.c \
2022-10-29 23:14:19 +08:00
modules/motor/motor_task.c \
modules/oled/oled.c \
modules/referee/crc_ref.c \
2022-10-20 17:13:02 +08:00
modules/referee/referee.c \
2022-11-11 12:32:24 +08:00
modules/referee/referee_UI.c \
modules/referee/referee_communication.c \
2022-10-29 23:14:19 +08:00
modules/remote/remote_control.c \
2022-11-03 20:38:55 +08:00
modules/super_cap/super_cap.c \
2022-11-13 14:40:21 +08:00
modules/can_comm/can_comm.c \
modules/message_center/message_center.c \
2022-12-08 17:36:12 +08:00
modules/daemon/daemon.c \
2022-12-05 15:59:47 +08:00
modules/vofa/vofa.c \
application/gimbal/gimbal.c \
application/chassis/chassis.c \
application/shoot/shoot.c \
application/cmd/robot_cmd.c \
application/robot.c
2022-11-03 20:38:55 +08:00
2022-10-20 17:13:02 +08:00
# ASM sources
2022-11-11 21:20:58 +08:00
ASM_SOURCES += \
startup_stm32f407xx.s \
HAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT/SEGGER_RTT_ASM_ARMv7M.s
2022-10-20 17:13:02 +08:00
#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# PREFIX = ccache arm-none-eabi- 可以通过安装ccache来缓存makefile内容加速编译
2022-10-20 17:13:02 +08:00
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m4
# fpu
FPU = -mfpu=fpv4-sp-d16
# float-abi
FLOAT-ABI = -mfloat-abi=hard
# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# macros for gcc
# AS defines
AS_DEFS =
# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32F407xx \
-DARM_MATH_CM4 \
-DARM_MATH_MATRIX_CHECK \
-DARM_MATH_ROUNDING
# AS includes
2022-11-19 15:23:19 +08:00
AS_INCLUDES = -IHAL_N_Middlewares/Inc
2022-10-20 17:13:02 +08:00
# C includes
C_INCLUDES = \
2022-11-03 18:19:06 +08:00
-IHAL_N_Middlewares/Inc \
-IHAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Inc \
-IHAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy \
-IHAL_N_Middlewares/Drivers/CMSIS/Device/ST/STM32F4xx/Include \
-IHAL_N_Middlewares/Drivers/CMSIS/Include \
-IHAL_N_Middlewares/Drivers/CMSIS/DSP/Include \
-IHAL_N_Middlewares/Middlewares/ST/STM32_USB_Device_Library/Core/Inc \
-IHAL_N_Middlewares/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \
-IHAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS \
-IHAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
-IHAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/include \
-IHAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/include \
2022-11-11 21:20:58 +08:00
-IHAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT \
-IHAL_N_Middlewares/Middlewares/Third_Party/SEGGER/Config \
2022-11-03 18:19:06 +08:00
-IHAL_N_Middlewares/Middlewares/ST/ARM/DSP/Inc \
-Iapplication/chassis \
-Iapplication/shoot \
-Iapplication/gimbal \
-Iapplication/cmd \
2022-10-20 17:13:02 +08:00
-Iapplication \
-Ibsp/dwt \
-Ibsp/can \
-Ibsp/usart \
2023-02-02 14:15:57 +08:00
-Ibsp/gpio \
-Ibsp/spi \
-Ibsp/iic \
-Ibsp/log \
-Ibsp/pwm \
2023-01-01 17:32:22 +08:00
-Ibsp/bsp_legacy_support \
2022-10-20 17:13:02 +08:00
-Ibsp \
-Imodules/algorithm \
-Imodules/BMI088 \
2022-10-20 17:13:02 +08:00
-Imodules/imu \
-Imodules/ist8310 \
2023-01-01 17:32:22 +08:00
-Imodules/led \
2022-10-20 17:13:02 +08:00
-Imodules/master_machine \
2023-01-02 23:20:35 +08:00
-Imodules/motor/DJImotor \
-Imodules/motor/LKmotor \
-Imodules/motor/HTmotor \
-Imodules/motor/step_motor \
-Imodules/motor/servo_motor \
2022-10-20 17:13:02 +08:00
-Imodules/motor \
-Imodules/oled \
2022-10-20 17:13:02 +08:00
-Imodules/referee \
-Imodules/remote \
-Imodules/super_cap \
-Imodules/can_comm \
2022-12-02 22:17:10 +08:00
-Imodules/message_center \
2022-12-08 17:36:12 +08:00
-Imodules/daemon \
2022-12-05 15:59:47 +08:00
-Imodules/vofa \
-Imodules/
2022-10-20 17:13:02 +08:00
# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32F407IGHx_FLASH.ld
# libraries
LIBS = -lc -lm -lnosys \
-larm_cortexM4lf_math
LIBDIR = \
2022-11-03 18:19:06 +08:00
-LHAL_N_Middlewares/Drivers/CMSIS/Lib/GCC
2022-10-20 17:13:02 +08:00
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
2022-11-16 20:58:27 +08:00
# 以下是编译命令,命令之前被粉色高亮的@就是静默输出的指令.删除前面的@会将输出显示到命令行.
# 如@$(CC) -c $(CFLAGS) ...... 去掉第一个@即可.
2022-10-20 17:13:02 +08:00
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
@$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
2022-10-20 17:13:02 +08:00
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
@$(AS) -c $(CFLAGS) $< -o $@
2022-10-20 17:13:02 +08:00
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
@$(CC) $(OBJECTS) $(LDFLAGS) -o $@
2022-11-19 15:23:19 +08:00
$(SZ) $@
2022-10-20 17:13:02 +08:00
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $@
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $@
$(BUILD_DIR):
@mkdir $@
2022-10-20 17:13:02 +08:00
#######################################
# clean up
#######################################
clean:
rd /s/q $(BUILD_DIR)
# linux: rm -rf $(BUILD_DIR)
#######################################
# download without debugging
#######################################
OPENOCD_FLASH_START = 0x08000000 # 如果切换芯片可能需要修改此值
download_dap:
openocd -f openocd_dap.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).hex $(OPENOCD_FLASH_START)" -c reset -c shutdown
download_jlink:
JFlash -openprj'stm32.jflash' -open'$(BUILD_DIR)/$(TARGET).hex',0x8000000 -auto -startapp -exit
2022-10-20 17:13:02 +08:00
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)
# *** EOF ***