|
发表于 2024-3-17 15:36:01
|
显示全部楼层
发一个vscode+GCC 的一个makefile. makeupload 暂且用不了,swm341.cfg 写不出来
- CROSS_COMPILE ?= arm-none-eabi-
- CC = $(CROSS_COMPILE)gcc
- OBJCOPY = $(CROSS_COMPILE)objcopy
- OBJDUMP = $(CROSS_COMPILE)objdump
- SZ = $(CROSS_COMPILE)size
- TARGET ?= 02_logger
- BUILD ?= out
- BUILD_DIR ?= out
- OBJ_DIR ?= ${BUILD_DIR}/obj
- WORKSPACE_DIR = ./
- #######################################
- # CFLAGS -mthumb -mcpu=cortex-m33 -mfloat-abi=soft -std=c99 -Wpointer-arith
- #######################################
- C_DEFS ?= -D__UVISION_VERSION="532" -D__TARGET_FPU_VFP -D__ARM_MATH_CM4 -D__FPU_PRSENT=1
- DEBUG = 1
- ifeq ($(DEBUG),1)
- CFLAGS += -O0 -g
- else
- CFLAGS += -O2
- endif
- CPU = -mcpu=cortex-m33
- # fpu
- FPU = -mfpu=fpv5-sp-d16
- # float-abi
- FLOAT-ABI = -mfloat-abi=hard
- # mcu
- MCU = -mthumb $(CPU) $(FPU) $(FLOAT-ABI)
- # CFLAGS ?= $(MCU)
- # CFLAGS += -std=c99 -Wpointer-arith
- # # CFLAGS += -ffunction-sections -fdata-sections -fno-common -funsigned-char
- # CFLAGS += -fno-common -funsigned-char
- # CFLAGS += -mlittle-endian -gdwarf-3 -O0 -ffunction-sections -fdata-sections -fno-common -funsigned-char -mno-unaligned-access
- # # CFLAGS += -Wno-missing-noreturn -Wno-sign-conversion
- # # CFLAGS += -ffunction-sections -fdata-sections -fno-common -funsigned-char
- # CFLAGS += $(C_INCLUDES)
- CFLAGS = $(MCU) -std=c99 -Wpointer-arith
- CFLAGS += -ffunction-sections -fdata-sections -fno-common -funsigned-char -mno-unaligned-access
- DEBUG = 1
- ifeq ($(DEBUG),1)
- CFLAGS += -O0 -g
- else
- CFLAGS += -O2
- endif
- ASFLAGS = $(CFLAGS)
- LINKER_SCRIPT = swm341.ld
- LDFLAGS = -Wl,--gc-sections -Wl,-Map=$@.map -T $(LINKER_SCRIPT) $(MCU) -specs=nosys.specs -specs=nano.specs -u _printf_float
- # CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
- ASFLAGS = $(CFLAGS)
- # LINKER_SCRIPT = swm341.ld
- # LIBS = -lc -lm
- # LIBDIR =
- # LDFLAGS ?= $(MCU)
- # LDFLAGS += -Wl,--gc-sections -T$(LINKER_SCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$@.map
- # LDFLAGS += -specs=nosys.specs -specs=nano.specs -u _printf_float
-
- # LIBS = -lc -lm -lnosys
- # LIBDIR =
- # LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
- ASM_SOURCES ?=
- ASM_SOURCES += $(WORKSPACE_DIR)CSL/CMSIS/DeviceSupport/startup/gcc/startup_SWM341.s
- C_SOURCES ?=
- C_INCLUDES ?=
- C_INCLUDES += -I ${WORKSPACE_DIR}CSL/CMSIS/CoreSupport/
- C_INCLUDES += -I ${WORKSPACE_DIR}CSL/CMSIS/DeviceSupport/
- C_INCLUDES += -I ${WORKSPACE_DIR}CSL/SWM341_StdPeriph_Driver/
- # C_INCLUDES += $(addprefix -I,$(sort $(dir $(filter-out $(ROOT_DIR)/platform%,$(subst \,/,$(shell find . -type f -name *.h)))) ))
- # C_INCLUDES += -I APP/
- # C_INCLUDES += -I BSP/
- # 自行注释用不到的Drivers
- C_SOURCES += $(WORKSPACE_DIR)CSL/CMSIS/DeviceSupport/system_SWM341.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_adc.c
- # C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_can.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_cordic.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_crc.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_dac.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_div.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_dma.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_dma2d.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_exti.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_flash.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_gpio.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_i2c.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_jpeg.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_lcd.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_port.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_pwm.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_rtc.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_sdio.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_sdram.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_sfc.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_sleep.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_spi.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_timr.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_uart.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_usbd.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_usbh.c
- C_SOURCES += $(WORKSPACE_DIR)CSL/SWM341_StdPeriph_Driver/SWM341_wdt.c
- ############ Freertos
- C_SOURCES += $(wildcard *.c $(WORKSPACE_DIR)FreeRTOS/*.c)
- C_SOURCES += $(wildcard *.c $(WORKSPACE_DIR)FreeRTOS/portable/GCC/ARM_CM33_NTZ/non_secure/*.c)
- C_INCLUDES += -I$(WORKSPACE_DIR)FreeRTOS/include/
- C_INCLUDES += -I$(WORKSPACE_DIR)FreeRTOS/
- C_INCLUDES += -I$(WORKSPACE_DIR)FreeRTOS/portable/GCC/ARM_CM33_NTZ/non_secure
- ############ Easylooger
- C_SOURCES += $(wildcard *.c $(WORKSPACE_DIR)EasyLogger/src/*.c)
- C_INCLUDES += -I$(WORKSPACE_DIR)EasyLogger/inc/
-
- C_SOURCES += $(wildcard *.c APP/*.c)
- C_INCLUDES += $(addprefix -I,$(sort $(dir $(filter-out $(ROOT_DIR)/platform%,$(subst \,/,$(shell find ./APP -type f -name *.h)))) ))
- C_SOURCES += $(wildcard *.c BSP/*.c)
- C_INCLUDES += $(addprefix -I,$(sort $(dir $(filter-out $(ROOT_DIR)/platform%,$(subst \,/,$(shell find ./BSP -type f -name *.h)))) ))
- # OBJS = $(addprefix $(BUILD)/, $(APP_SRC:.c=.o) $(CSL_SRC:.c=.o) $(CSL_SRS:.s=.o) $(BSP_SRC:.c=.o))
- # color
- NO_COLOR = \033[0;01m
- OK_COLOR = \033[35;01m
- ERROR_COLOR = \033[31;01m
- DONE_COLOR = \033[31;01m
- CC_COLOR = \033[34;01m
- .PHONY: test echo prestage endsatge
- # default action: build all
- all: prestage buildstage endsatge
- build: buildstage FORCE
- buildstage: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
- prestage:
- @echo -e "$(OK_COLOR)::::::::::: prestage build :::::::::::$(NO_COLOR) "
- @mkdir -p $(BUILD_DIR)
- @mkdir -p $(OBJ_DIR)
- endsatge:
- @echo -e "$(OK_COLOR)::::::::::: COMPLETE BUILDING :::::::::::$(NO_COLOR) "
-
- #######################################
- # build the application
- #######################################
- # list of objects
- OBJECTS = $(addprefix $(OBJ_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
- vpath %.c $(sort $(dir $(C_SOURCES)))
- # list of ASM program objects
- OBJECTS += $(addprefix $(OBJ_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
- vpath %.s $(sort $(dir $(ASM_SOURCES)))
- $(OBJ_DIR)/%.o: %.c Makefile | $(OBJ_DIR)
- @echo -e "$(OK_COLOR) $< ===>>> $@ $(NO_COLOR) "
- $(CC) -c -o $(OBJ_DIR)/$(notdir $@) $(CFLAGS) $(C_INCLUDES) -Wa,-a,-ad,-alms=$(OBJ_DIR)/$(notdir $(<:.c=.lst)) $<
- $(OBJ_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
- $(CC) -c -o $(OBJ_DIR)/$(notdir $@) $(CFLAGS) $(C_INCLUDES) $<
- $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
- @echo -e "$(OK_COLOR) LINK TO ELF : $@ $(NO_COLOR) "
- $(CC) -o $@ $(LDFLAGS) $(OBJECTS)
- @echo -e "$(CC_COLOR) "
- $(SZ) $@
- # $(CC) $(OBJECTS) $(LDFLAGS) -o $@
- $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
- $(OBJCOPY) -O ihex $< $@
- $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
- $(OBJCOPY) -O binary $< $@
- @echo -e "$(NO_COLOR)"
- # $(BUILD_DIR):
- # mkdir $@
-
- test:
- @$(info === test ===)
- @echo -e "$(CC_COLOR) ===== "
- @echo ${C_SOURCES}
- @echo -e "$(CC_COLOR) ===== "
- @echo ${C_INCLUDES}
- @echo -e "$(CC_COLOR) ===== "
- @echo ${OBJECTS}
- @echo -e "$(NO_COLOR)"
- echo:
- @$(info === echo info ===)
- @echo ${C_DEFS} ${C_INCLUDES}
- clean:
- rm -rf $(BUILD)/*
- #######################################
- # upload cmsis-dap.cfg stlink.cfg
- #######################################
- upload:
- # @openocd -f interface/cmsis-dap.cfg -f target/stm32f4x.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).bin 0x08000000" -c reset -c shutdown
- # @openocd -f interface/cmsis-dap.cfg -f target/stm32f4x.cfg -c init -c halt -c "program $(BUILD_DIR)/$(TARGET).bin exit 0x08000000" -c reset -c shutdown
- # @openocd -f interface/cmsis-dap.cfg -f target/stm32f4x.cfg -c init -c halt -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit" -c reset -c shutdown
- @openocd -f cmsis-dap.cfg -f swm341.cfg \
- -c init -c reset -c halt \
- -c "program $(BUILD_DIR)/$(TARGET).bin exit 0x00000000" \
- -c reset -c shutdown
复制代码 |
|