本文所使用工程由STM32CubeMX生成,使用芯片:STM32F103ZET6,基本只开了时钟。看懂本篇解析需要有一些最基本的Makefile知识。
Makefile文件如下:

##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.0.0] date: [Fri Jul 10 15:04:01 CST 2020]
##########################################################################################################################

# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
#	2017-02-10 - Several enhancements + project update mode
#   2015-07-22 - first version
# ------------------------------------------------

######################################
# target
######################################
TARGET = GCC_F103


######################################
# building variables
######################################
# debug build?
DEBUG = 1
# optimization
OPT = -Og


#######################################
# paths
#######################################
# Build path
BUILD_DIR = build

######################################
# source
######################################
# C sources
C_SOURCES =  \
Src/main.c \
Src/stm32f1xx_it.c \
Src/stm32f1xx_hal_msp.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
Src/system_stm32f1xx.c  

# ASM sources
ASM_SOURCES =  \
startup_stm32f103xe.s


#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# 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-m3

# fpu
# NONE for Cortex-M0/M0+/M3

# float-abi


# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

# macros for gcc
# AS defines
AS_DEFS = 

# C defines
C_DEFS =  \
-DUSE_HAL_DRIVER \
-DSTM32F103xE


# AS includes
AS_INCLUDES = 

# C includes
C_INCLUDES =  \
-IInc \
-IDrivers/STM32F1xx_HAL_Driver/Inc \
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
-IDrivers/CMSIS/Include \
-IDrivers/CMSIS/Include


# 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 = STM32F103ZETx_FLASH.ld

# libraries
LIBS = -lc -lm -lnosys 
LIBDIR = 
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)))

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
	$(AS) -c $(CFLAGS) $< -o $@
	
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
	$(CC) $(OBJECTS) $(LDFLAGS) -o $@
	$(SZ) $@

$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
	$(HEX) $< $@
	
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
	$(BIN) $< $@	
	
$(BUILD_DIR):
	mkdir $@		

#######################################
# clean up
#######################################
clean:
	-rm -fR $(BUILD_DIR)
  
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

# *** EOF ***

这么长的文件,其实真正用来编译的指令只有几行:
在这里插入图片描述

而贯穿整篇Makefile的只有三行代码:

$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
	$(CC) $(OBJECTS) $(LDFLAGS) -o $@
	$(SZ) $@

正向解析(从Makefile文件->输出结果)

如果要正向解析Makefile文件,需要理清整个文件输出流程,即依赖结构。
其实在这篇makefile里,make就等于make all。
在这里插入图片描述
可以看到,make执行的缺省动作就是all这个label,所以当你打下make时,makefile会想办法生成以下三个文件

$(BUILD_DIR)/$(TARGET).elf
$(BUILD_DIR)/$(TARGET).hex
$(BUILD_DIR)/$(TARGET).bin

而我们找到makefile最上面,定义的变量:
在这里插入图片描述
可以清楚的看到TARGET、BUILD_DIR这两个变量定义,所以我们所要生成的目标文件实际是:

build/GCC_F103.elf
build/GCC_F103.hex
build/GCC_F103.bin

也就是在目录build下生成这三个文件。而build目录和这三个文件的生成方法也已经给出:
在这里插入图片描述
其实把BUILD_DIR和TARGET替换掉,也就是:

build/GCC_F103.elf: $(OBJECTS) Makefile
	$(CC) $(OBJECTS) $(LDFLAGS) -o $@
	$(SZ) $@

build/%.hex: build/%.elf | build
	$(HEX) $< $@
	
build/%.bin: build/%.elf | build
	$(BIN) $< $@	
build:
	mkdir $@

由此也可以看出来,只要GCC_F103.elf有了,那GCC_F103.hex和GCC_F103.bin都是在GCC_F103.elf基础上生成的,所以肯定要先生成GCC_F103.elf。而build就是一行指令:mkdir build($@代表目标文件,这里目标文件就是build)。接着往下看,GCC_F103.elf这个文件又依赖于 $(OBJECTS)这个变量,也就是需要先生成这个,然后执行下面两行代码。 $(OBJECTS)具体是什么,我们再看上面变量定义:
在这里插入图片描述
可以看到这个变量又使用了其他变量,还运用了函数addprefix、notdir和sort。而其中新的两个变量也定义在最上面:
在这里插入图片描述

最外层addprefix用法是:

$(addprefix <prefix>, <name-1>, <name-2>...<name-n>)

把前缀prefix加到name前面。
而notdir是把字符串中的路径去掉,比如:

C_SOURCES = F103/Src/main.c
OBJECTS = $(notdir$(C_SOURCES))

最终OBJECT = main.c
还有一个地方$(C_SOURCES:.c=.o),这里的意思是把C_SOURCES里所有以.c结尾的文件替换为.o结尾的文件。
所以替换展开后OBJECTS其实为:

OBJECTS = \
build/main.o \
build/stm32f1xx_it.o \
build/stm32f1xx_hal_msp.o \
build/stm32f1xx_hal_gpio_ex.o \
build/stm32f1xx_hal_tim.o \
build/stm32f1xx_hal_tim_ex.o \
build/stm32f1xx_hal.o \
build/stm32f1xx_hal_rcc.o \
build/stm32f1xx_hal_rcc_ex.o \
build/stm32f1xx_hal_gpio.o \
build/stm32f1xx_hal_dma.o \
build/stm32f1xx_hal_cortex.o \
build/stm32f1xx_hal_pwr.o \
build/stm32f1xx_hal_flash.o \
build/stm32f1xx_hal_flash_ex.o \
build/system_stm32f1xx.o  

接下来看vpath这个关键字,它的用法是

vpath <pattern> <directories>

设置符合pattern的文件的搜索路径是directories
在这里插入图片描述
的意思就是,所有.c文件的搜索路径是$(sort $(dir $(C_SOURCES))) ,sort函数用来去掉重复的文件路径,dir函数即取路径和notdir函数刚好相反,最终结果就是所有.c文件的搜索路径是C_SOURCES这个变量去掉文件名只保留路径,去掉重复的并排好序列。
可以看出这两行代码是处理所有.c文件的,而下面的两行代码是处理.s文件的,处理方式都一样,都是把文件后缀换为.o:
在这里插入图片描述
注意这里OBJECT是用的 += 而不是 =,代表最后OBJECT里面包含了.c和.s的处理结果。至此我们得到了OBJECT这个变量的最终结果:

OBJECTS = \
build/main.o \
build/stm32f1xx_it.o \
build/stm32f1xx_hal_msp.o \
build/stm32f1xx_hal_gpio_ex.o \
build/stm32f1xx_hal_tim.o \
build/stm32f1xx_hal_tim_ex.o \
build/stm32f1xx_hal.o \
build/stm32f1xx_hal_rcc.o \
build/stm32f1xx_hal_rcc_ex.o \
build/stm32f1xx_hal_gpio.o \
build/stm32f1xx_hal_dma.o \
build/stm32f1xx_hal_cortex.o \
build/stm32f1xx_hal_pwr.o \
build/stm32f1xx_hal_flash.o \
build/stm32f1xx_hal_flash_ex.o \
build/system_stm32f1xx.o  
build/startup_stm32f103xe.o

回到我们刚才追溯到OBJECT的地方:
在这里插入图片描述
这里已经分析过build/GCC_F103.elf这个文件依赖OBJECT,其实就是生成它依赖那么多.o文件,那这些.o文件从哪里来?
在这里插入图片描述
可以看到,所有.o的生成规则Makefile也已经给出。这里的 | $(BUILD_DIR)不作过多解释,其实就是如果要生成.o就要先生成build这个目录,如果生成了build那以后都不需要再生成它了,如果你去掉这个或者只去掉管道符号 |,则每次make都会重新生成所有文件,这里贴出来GUN make的原文描述:
在这里插入图片描述
实际这些.o的生成规则其实就是:

$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

而里面用到的变量都在上面有定义,因为内容较多不再截图。
所以这一行展开就是:

arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb     -DUSE_HAL_DRIVER -DSTM32F103xE -IInc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"$(@:%.o=%.d)" -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

可以看到有一部分还未替换的则是根据生成的.o替换为.d和.lst的。其实就是替换变量,具体参数在gcc中的功能需要你自己去查找。(.s生成.o同理,参数并不完全相同)
在生成完所有.o文件后,我们终于可以继续刚才的代码:
在这里插入图片描述
同样的替换变量后:

arm-none-eabi-gcc $(OBJECTS) -mcpu=cortex-m3 -mthumb    -specs=nano.specs -TSTM32F103ZETx_FLASH.ld   -lc -lm -lnosys -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -o $@
arm-none-eabi-size $@

如果变量为空,则实际展开时用空格代替。
最后生成.hex和.bin:

arm-none-eabi-objcopy -O ihex $< $@
arm-none-eabi-objcopy -O binary -S $< $@
$@可以简单理解为targets,而$<则是第一条prerequisites,而$^是所有prerequisites

我们查看输出结果和我们分析的是否一致:

$ make all
mkdir build
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/main.d" -Wa,-a,-ad,-alms=build/main.lst Src/main.c -o build/main.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_it.d" -Wa,-a,-ad,-alms=build/stm32f1xx_it.lst Src/stm32f1xx
_it.c -o build/stm32f1xx_it.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_msp.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_msp.lst Src
/stm32f1xx_hal_msp.c -o build/stm32f1xx_hal_msp.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_gpio_ex.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_gpio_ex
.lst Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c -o build/stm32f1xx
_hal_gpio_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_tim.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_tim.lst Dri
vers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c -o build/stm32f1xx_hal_tim.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_tim_ex.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_tim_ex.l
st Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c -o build/stm32f1xx_ha
l_tim_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal.lst Drivers/STM
32F1xx_HAL_Driver/Src/stm32f1xx_hal.c -o build/stm32f1xx_hal.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_rcc.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_rcc.lst Dri
vers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c -o build/stm32f1xx_hal_rcc.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_rcc_ex.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_rcc_ex.l
st Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c -o build/stm32f1xx_ha
l_rcc_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_gpio.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_gpio.lst D
rivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c -o build/stm32f1xx_hal_gpio
.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_dma.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_dma.lst Dri
vers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c -o build/stm32f1xx_hal_dma.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_cortex.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_cortex.l
st Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c -o build/stm32f1xx_ha
l_cortex.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_pwr.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_pwr.lst Dri
vers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c -o build/stm32f1xx_hal_pwr.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_flash.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_flash.lst
 Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c -o build/stm32f1xx_hal_f
lash.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/stm32f1xx_hal_flash_ex.d" -Wa,-a,-ad,-alms=build/stm32f1xx_hal_flash_
ex.lst Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c -o build/stm32f
1xx_hal_flash_ex.o
arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_DRIVER -DSTM32F103xE -I
Inc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
 -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMSIS/Include -IDrivers/C
MSIS/Include -Og -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP
 -MF"build/system_stm32f1xx.d" -Wa,-a,-ad,-alms=build/system_stm32f1xx.lst Src/s
ystem_stm32f1xx.c -o build/system_stm32f1xx.o
arm-none-eabi-gcc -x assembler-with-cpp -c -mcpu=cortex-m3 -mthumb   -DUSE_HAL_D
RIVER -DSTM32F103xE -IInc -IDrivers/STM32F1xx_HAL_Driver/Inc -IDrivers/STM32F1xx
_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32F1xx/Include -IDrivers/CMS
IS/Include -IDrivers/CMSIS/Include -Og -Wall -fdata-sections -ffunction-sections
 -g -gdwarf-2 -MMD -MP -MF"build/startup_stm32f103xe.d" startup_stm32f103xe.s -o
 build/startup_stm32f103xe.o
arm-none-eabi-gcc build/main.o build/stm32f1xx_it.o build/stm32f1xx_hal_msp.o bu
ild/stm32f1xx_hal_gpio_ex.o build/stm32f1xx_hal_tim.o build/stm32f1xx_hal_tim_ex
.o build/stm32f1xx_hal.o build/stm32f1xx_hal_rcc.o build/stm32f1xx_hal_rcc_ex.o
build/stm32f1xx_hal_gpio.o build/stm32f1xx_hal_dma.o build/stm32f1xx_hal_cortex.
o build/stm32f1xx_hal_pwr.o build/stm32f1xx_hal_flash.o build/stm32f1xx_hal_flas
h_ex.o build/system_stm32f1xx.o build/startup_stm32f103xe.o -mcpu=cortex-m3 -mth
umb   -specs=nano.specs -TSTM32F103ZETx_FLASH.ld  -lc -lm -lnosys  -Wl,-Map=buil
d/GCC_F103.map,--cref -Wl,--gc-sections -o build/GCC_F103.elf
arm-none-eabi-size build/GCC_F103.elf
   text    data     bss     dec     hex filename
   3712      20    1572    5304    14b8 build/GCC_F103.elf
arm-none-eabi-objcopy -O ihex build/GCC_F103.elf build/GCC_F103.hex
arm-none-eabi-objcopy -O binary -S build/GCC_F103.elf build/GCC_F103.bin
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐