########################################################################################################################## # File automatically-generated by tool: [projectgenerator] version: [3.18.0-B7] date: [Mon Jan 23 18:29:42 CET 2023] ########################################################################################################################## # ------------------------------------------------ # Generic Makefile (based on gcc) # # ChangeLog : # 2017-02-10 - Several enhancements + project update mode # 2015-07-22 - first version # ------------------------------------------------ ###################################### # target ###################################### TARGET = FC_camera ###################################### # building variables ###################################### # debug build? DEBUG = 1 # optimization OPT = -Og ifndef VERBOSE MAKEFLAGS += --no-print-directory endif ####################################### # paths ####################################### # Build path BUILD_DIR = build ###################################### # source ###################################### # C sources C_SOURCES = \ Src/main.c \ Src/stm32l4xx_it.c \ Src/stm32l4xx_hal_msp.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \ Src/system_stm32l4xx.c # ASM sources ASM_SOURCES = \ startup_stm32l452xx.s ####################################### # binaries ####################################### BINPATH = /opt/gcc-arm-none-eabi-9-2020-q2/bin/ PREFIX = arm-none-eabi- CC = $(BINPATH)$(PREFIX)gcc CP = $(BINPATH)$(PREFIX)g++ AS = $(BINPATH)$(PREFIX)g++ -x assembler-with-cpp CO = $(BINPATH)$(PREFIX)objcopy AR = $(BINPATH)$(PREFIX)ar SZ = $(BINPATH)$(PREFIX)size HEX = $(CO) -O ihex BIN = $(CO) -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 = \ -DSTM32_L4 \ -DUSE_HAL_DRIVER \ -DSTM32L452xx # AS includes AS_INCLUDES = # C includes C_INCLUDES = \ -IInc \ -IDrivers/STM32L4xx_HAL_Driver/Inc \ -IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \ -IDrivers/CMSIS/Device/ST/STM32L4xx/Include \ -IDrivers/CMSIS/Include \ -ICamera_driver \ -IApp # compile gcc flags ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections BOTHFLAGS = -Wno-write-strings -specs=nano.specs -specs=nosys.specs $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections ifeq ($(DEBUG), 1) BOTHFLAGS += -g -gdwarf-2 endif CFLAGS = $(MCU) -std=c++17 -Wno-register $(BOTHFLAGS) -fno-exceptions -fno-asynchronous-unwind-tables CDFLAGS = $(MCU) -std=c17 $(BOTHFLAGS) # Generate dependency information CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" $(eval CPP_SOURCES=$(shell $(CC) $(C_INCLUDES) $(C_DEFS) -MM Src/main.c | sed 's/\\/\\n/g' | sed 's/\s/ /g' | sed 's/ /\n/g' | grep hpp | sed 's/hpp/cpp/g' | sort -u )) ####################################### # LDFLAGS ####################################### # link script LDSCRIPT = STM32L452CEUx_FLASH.ld # libraries LIBS = -lc -lm -lnosys LIBDIR = LDFLAGS = $(MCU) -Wl,--no-wchar-size-warning -specs=nosys.specs -specs=nano.specs -u _printf_float -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections # default action: build all all: @printf "Dependencies:\n$(shell echo $(CPP_SOURCES) | sed 's/ /\\n/g' | sed 's/alohal\///g')\n=================================================\n" @make bin -j$(nproc) flash_build: @make bin -j$(nproc) bin: $(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))) OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o))) vpath %.cpp $(sort $(dir $(CPP_SOURCES))) # list of ASM program objects OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) vpath %.s $(sort $(dir $(ASM_SOURCES))) $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) @echo "CC " $< @$(CC) -c $(CDFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ $(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR) @echo "CP " $< @$(CP) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cpp=.lst)) $< -o $@ $(BUILD_DIR)/main.o: Src/main.c Makefile | $(BUILD_DIR) @echo "CP " $< @$(CP) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cpp=.lst)) $< -o $@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) @echo "AS " $< @$(AS) -c $(CFLAGS) $< -o $@ $(BUILD_DIR)/$(TARGET).elf: $(DEPS) $(OBJECTS) Makefile @echo "LD " $< @$(CP) $(OBJECTS) $(LDFLAGS) -o $@ @$(SZ) $@ $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) @echo "HEX " $@ @$(HEX) $< $@ $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) @echo "BIN " $@ @$(BIN) $< $@ $(BUILD_DIR): mkdir $@ ####################################### # clean up ####################################### clean: -rm -fR $(BUILD_DIR) ####################################### # dependencies ####################################### DEPENDENCIES := $(OBJECTS:.o=.d) -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) -include $(DEPENDENCIES) # Flash flash: flash_build openocd -f interface/stlink.cfg -f target/stm32l4x.cfg -c "program build/$(TARGET).bin verify reset exit 0x08000000" reset: openocd -f interface/stlink.cfg -f target/stm32l4x.cfg -c init -c "reset halt" # *** EOF ***