TARGET =main
CC = arm-none-eabi-gcc
AS = arm-none-eabi-as
LD = arm-none-eabi-ld
CFLAGS =-mthumb -mcpu=cortex-m4 -g -I /home/fxx/Desktop/Project/CMSIS/Inc/ -I /home/fxx/Desktop/Project/Dev/Inc/ -DSTM32F40_41xxx
#LDFLAGS = --static -L /usr/arm-none-eabi/lib/ -L /usr/lib/gcc/arm-none-eabi/11.2.0/
LDFLAGS = --static -specs=nosys.specs -Wl,-Map=main.map -g
ASFLAGS = -mthumb -mcpu=cortex-m4
vpath %.c ./CMSIS/Src
vpath %.c ./Dev/Src
vpath %.c ./User
vpath %.h ./Dev/Inc
vpath %.h ./CMSIS/Inc
vpath %.o ./Build
C_INCLUDE = stm32f4xx_gpio.c \
system_stm32f4xx.c \
stm32f4xx_rcc.c \
main.c
OBJ_SOURCE = $(C_INCLUDE:%.c=%.o)
ASM_SOURCE = ./startup_stm32f40_41xxx.s
LD_SOURCE = ./STM32F407IGHx_FLASH.ld
ASMOBJ_SOURCE =$(ASM_SOURCE:%.s=%.o)
$(warning $(C_INCLUDE))
$(warning $(OBJ_SOURCE))
all:$(OBJ_SOURCE) $(ASMOBJ_SOURCE)
$(CC) $(LDFLAGS) $(sort $(addprefix ./Build/,$(C_INCLUDE:%.c=%.o))) $(sort $(addprefix ./Build/,$(ASMOBJ_SOURCE))) -T $(LD_SOURCE) -o $(TARGET).elf
$(OBJ_SOURCE):%.o:%.c
$(CC) $(CFLAGS) -c $< -o ./Build/$@ -Wall
$(ASMOBJ_SOURCE):$(ASM_SOURCE)
$(AS) $(ASFLAGS) -c $^ -o ./Build/$@
clean:
@rm -rf ./Build/*.o
@rm -rf ./*.elf
@rm -rf ./main.map
download:
openocd -f /usr/share/openocd/scripts/interface/stlink.cfg -f /usr/share/openocd/scripts/target/stm32f4x.cfg -c init -c halt -c "flash write_image erase /home/fxx/Desktop/Project/main.elf" -c reset
09-12
371
03-16
8316