Mac osX下STM32F10x的快速开发(4)
- UID
- 1029342
- 性别
- 男
|
Mac osX下STM32F10x的快速开发(4)
LIBSTM32_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(LIBSTM32_SRCS:.c=.o)))
USR_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(USR_SRCS:.c=.o)))
ASM_SRCS = $(LIBSTM32_ASM_SRCS)
ASM_OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(LIBSTM32_ASM_SRCS:.s=.o)))
TCHAIN = arm-none-eabi
INCLUDE_DIRS = -I $(PRJDIR) -I $(SRCDIR) $(LIBSTM32_INCS) $(USR_INCS) $(USR_LIBS)
COMPILE_OPTS = -mcpu=cortex-m3 -mthumb -mfpu=vfp
COMPILE_OPTS+= -nostartfiles -fno-common -fomit-frame-pointer -Wall -g -O$(OPT)
LIBRARY_DIRS = -L $(STM32_LIB_DIR)/Libraries
PREDEFINES = $(LIBSTM32_DEFS) $(USR_DEFS)
CC = $(TCHAIN)-gcc
CFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) $(PREDEFINES)
CXX = $(TCHAIN)-g++
CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) $(PREDEFINES)
AS = $(TCHAIN)-gcc
ASFLAGS = $(COMPILE_OPTS) -c
LD = $(TCHAIN)-gcc
LDFLAGS = -Wl,--gc-sections,-Map=$(PROJECT).map,-cref,-u,Reset_Handler $(INCLUDE_DIRS) $(LIBRARY_DIRS) -T $(LD_FILE)
OBJCP = $(TCHAIN)-objcopy
AR = $(TCHAIN)-ar
ARFLAGS = cr
MAIN_OUT = $(PROJECT)_GCC
MAIN_OUT_ELF = $(MAIN_OUT).elf
MAIN_OUT_BIN = $(MAIN_OUT).bin
MAIN_OUT_HEX = $(MAIN_OUT).hex
MAIN_OUT_PROG = $(MAIN_OUT_BIN)
STR_DIV = ------------------------------------------------------------
# all
all: start gcc-info $(MAIN_OUT_ELF) $(MAIN_OUT_PROG) size end
# misc
start:
@echo Start Compiling Project $(PROJECT)
@echo User Files:
@echo $(USR_OBJS)
@echo STM32 Library Files:
@echo $(LIBSTM32_OBJS)
end:
@echo $(STR_DIV)
@echo ok!!
gcc-info:
@echo $(STR_DIV)
@echo gcc version is
@$(CC) --version
@echo $(STR_DIV)
# main
$(MAIN_OUT_ELF): $(ASM_OBJS) $(USR_OBJS) $(LIBSTM32_OBJS)
$(LD) $(LDFLAGS) $(ASM_OBJS) $(LIBSTM32_OBJS) $(USR_OBJS) --output $@
$(MAIN_OUT_BIN): $(MAIN_OUT_ELF)
$(OBJCP) -O binary $< $@
$(MAIN_OUT_HEX): $(MAIN_OUT_ELF)
$(OBJCP) -O ihex $< $@
size: $(MAIN_OUT_ELF)
@echo $(STR_DIV)
$(TCHAIN)-size $(MAIN_OUT_ELF)
flash: $(MAIN_OUT_PROG)
@echo $(STR_DIV)
dfu-util -d $(USB_VG) -a 0 --dfuse $(FLASH_LOAD_OFFSET) -D $(MAIN_OUT_BIN)
@echo $(STR_DIV)
@echo flash finish !!!
$(ASM_OBJS): $(ASM_SRCS)
$(CC) -c $(CFLAGS) $^
$(LIBSTM32_OBJS): $(LIBSTM32_SRCS)
$(CC) -c $(CFLAGS) $^
$(USR_OBJS): $(USR_SRCS)
$(CC) -c $(CFLAGS) $^
clean:
-rm $(USR_OBJS) $(PROJECT).map $(ASM_OBJS) $(LIBSTM32_OBJS) $(MAIN_OUT_ELF) $(MAIN_OUT_PROG)
其中:FLASH_LOAD_OFFSET是应用程序的起始地址,另外,STM32F10x.LD文件要修改成这个地址,主程序中要添加中断向量的起始地址,(系统缺省是0x0000):
#ifdef VECT_TAB_FLASH_OFFSET
NVIC_SetVectorTable(NVIC_VectTab_FLASH, VECT_TAB_FLASH_OFFSET); // offset 0x3000
#endif
|
3、这样,就可以在Mac osX中,不离开Aquamacs环境,编辑/编译/下载stm32的程序,都是命令行操作效率很高。 |
|
|
|
|
|