-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] 1.修复了stm32f103c8t6最小系统板的编译和运行问题
Signed-off-by: jiayuanwen <[email protected]>
- Loading branch information
Showing
33 changed files
with
297 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
include $(BUILD_DIR)/compiler_configs/riscv_embed_gcc/riscv_none_embed_gcc.config | ||
|
||
# c语言文件编译参数 | ||
CFLAGS += -march=rv32imac | ||
CFLAGS += -mabi=ilp32 | ||
CFLAGS += -msmall-data-limit=8 | ||
CFLAGS += -msave-restore | ||
CFLAGS += -Os | ||
CFLAGS += -fmessage-length=0 | ||
CFLAGS += -fsigned-char | ||
CFLAGS += -ffunction-sections | ||
CFLAGS += -fdata-sections | ||
CFLAGS += -fno-common | ||
CFLAGS += -Wunused | ||
CFLAGS += -Wuninitialized | ||
CFLAGS += -std=gnu99 | ||
# CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<" | ||
|
||
#汇编文件编译参数 | ||
ASMFLAGS += -march=rv32imac | ||
ASMFLAGS += -mabi=ilp32 | ||
ASMFLAGS += -msmall-data-limit=8 | ||
ASMFLAGS += -msave-restore | ||
ASMFLAGS += -Os | ||
ASMFLAGS += -fmessage-length=0 | ||
ASMFLAGS += -fsigned-char | ||
ASMFLAGS += -ffunction-sections | ||
ASMFLAGS += -fdata-sections | ||
ASMFLAGS += -fno-common | ||
ASMFLAGS += -Wunused | ||
ASMFLAGS += -Wuninitialized | ||
ASMFLAGS += -x assembler-with-cpp | ||
# ASMFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<" | ||
|
||
#链接参数 | ||
CLINK_FLAGS += -march=rv32imac | ||
CLINK_FLAGS += -mabi=ilp32 | ||
CLINK_FLAGS += -msmall-data-limit=8 | ||
CLINK_FLAGS += -msave-restore | ||
CLINK_FLAGS += -Os | ||
CLINK_FLAGS += -fmessage-length=0 | ||
CLINK_FLAGS += -fsigned-char | ||
CLINK_FLAGS += -ffunction-sections | ||
CLINK_FLAGS += -fdata-sections | ||
CLINK_FLAGS += -fno-common | ||
CLINK_FLAGS += -Wunused | ||
CLINK_FLAGS += -Wuninitialized | ||
CLINK_FLAGS += -nostartfiles | ||
CLINK_FLAGS += -Xlinker --gc-sections --specs=nano.specs --specs=nosys.specs | ||
|
||
#芯片架构(会用在硬件平台相关的编译控制上,如bsp) | ||
CATOS_BOARD_ARCH = riscv-rv32 | ||
|
||
.EXPORT_ALL_VARIABLES: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Build/compiler_configs/riscv_embed_gcc/riscv_none_embed_gcc.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#编译命令指定 | ||
#TOOLCHAIN_DIR = $(shell pwd) | ||
CROSS_COMPILE = $(BUILD_DIR)/../../../riscv_embed_gcc/bin/riscv-none-embed- | ||
|
||
CC = $(CROSS_COMPILE)gcc | ||
AS = $(CROSS_COMPILE)gcc | ||
AR = $(CROSS_COMPILE)ar | ||
LD = $(CROSS_COMPILE)gcc | ||
CP = $(CROSS_COMPILE)objcopy | ||
SZ = $(CROSS_COMPILE)size | ||
|
||
#添加参数使LD输出.map文件:-Wl,-Map=xx.map | ||
LIST_MAP_FILE = -Wl,-Map | ||
|
||
#规则目录指定 | ||
RULE_DIR = $(BUILD_DIR)/compiler_configs/riscv_embed_gcc | ||
|
||
#最终目标文件名 | ||
MAP_NAME := $(PROJECT).map | ||
ELF_NAME := $(PROJECT).elf | ||
BIN_NAME := $(PROJECT).bin | ||
HEX_NAME := $(PROJECT).hex | ||
|
||
.EXPORT_ALL_VARIABLES: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#当前目录 | ||
CUR_DIR = $(shell pwd) | ||
|
||
#目标名(当前目录的目录名(不带完整前缀)) | ||
TARGET := $(lastword $(subst /, ,$(CUR_DIR))) | ||
#输出目录 | ||
#OBJ_OUT_DIR = $(CUR_DIR) | ||
OBJ_OUT_DIR = $(subst $(TOP_DIR),$(RELATIVE_PATH)/$(OBJ_DIR),$(CUR_DIR)) | ||
#给obj目标添加输出目录作为前缀 | ||
OBJ_TARGET = $(patsubst %,$(OBJ_OUT_DIR)/%,$(obj-y)) | ||
#要创建的输出目录,并排序 | ||
OBJ_Y_DIR = $(sort $(dir $(OBJ_TARGET))) | ||
#c文件编译包含目录 | ||
CINCLUDE_FILE_FLAG := $(addprefix -I$(RELATIVE_PATH)/,$(CINCLUDE_FILE)) | ||
|
||
#设置为伪目标,否则检测到文件或目录存在就不会执行命令 | ||
.PHONY: print_cat_compile_info $(subdir-y) $(TARGET) | ||
|
||
all: print_cat_compile_info $(OBJ_Y_DIR) $(TARGET) | ||
|
||
#在子makefile里声明编译前需要打印的信息,VERIFY_MSG = xxx | ||
print_cat_compile_info: | ||
ifdef CAT_COMPILE_INFO | ||
#这里echo要先输出一个空格,换行才能对齐 | ||
@echo " $(CAT_COMPILE_INFO)" | ||
endif | ||
|
||
#创建输出目录 | ||
$(OBJ_Y_DIR): | ||
@echo "\n-->make$(OBJ_Y_DIR)" | ||
@if [ ! -d "$@" ];then $(MK_DIR) $@ ;fi; | ||
|
||
|
||
#让all目标间接依赖OBJ_TARGET,又由于OBJ_TARGET的.o没有给出, | ||
#就会和$(OBJ_OUT_DIR)/%.o匹配 | ||
#############!!note1:subdir-y必须在OBJ_TARGET之后,因为subdir-y的编译 | ||
#需要增加RELATIVE_PATH的层数 | ||
$(TARGET): $(OBJ_TARGET) $(subdir-y) | ||
|
||
ifdef obj-y | ||
#编译文件 | ||
$(OBJ_OUT_DIR)/%.o: $(CUR_DIR)/%.c | ||
ifeq ($(compile_enable_detail), n) | ||
@echo "compile $<" | ||
@$(CC) $(CINCLUDE_FILE_FLAG) $(CFLAGS) -o $@ -c $< | ||
else | ||
$(CC) $(CINCLUDE_FILE_FLAG) $(CFLAGS) -o $@ -c $< | ||
endif | ||
|
||
$(OBJ_OUT_DIR)/%.o: $(CUR_DIR)/%.s | ||
ifeq ($(compile_enable_detail), n) | ||
@echo "compile $<" | ||
@$(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< | ||
else | ||
$(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< | ||
endif | ||
|
||
|
||
$(OBJ_OUT_DIR)/%.o: $(CUR_DIR)/%.S | ||
ifeq ($(compile_enable_detail), n) | ||
@echo "compile $<" | ||
@$(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< | ||
else | ||
$(AS) $(ASMINCLUDE_FILE_FLAG) $(ASMFLAGS) -o $@ -c $< | ||
endif | ||
|
||
endif #ifdef obj-y | ||
|
||
#更改相对路径,以便目录层级创建 | ||
#############!!note2:添加../必须放在这里,放前面的话生成的obj会再往上一个目录... | ||
#就不在目标的output目录了 | ||
ifdef subdir-y | ||
RELATIVE_PATH := $(addprefix ../,$(RELATIVE_PATH)) | ||
endif | ||
|
||
#编译子目录 | ||
$(subdir-y): | ||
$(MAKE) -C $@ | ||
|
||
export CINCLUDE_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
workspace/catOS/bsp/Libraries/STM32F1xx_HAL_Driver/Src/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#VERIFY_MSG = catOS/port:$(RELATIVE_PATH)***** making catOS port dir ***** | ||
|
||
subdir-y += $(CATOS_BOARD_BSP) | ||
subdir-y += board | ||
subdir-y += libcpu | ||
|
||
include $(RULE_DIR)/rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#VERIFY_MSG = catOS/port:$(RELATIVE_PATH)***** making catOS port dir ***** | ||
|
||
subdir-y += $(CATOS_BOARD_BSP) | ||
|
||
include $(RULE_DIR)/rules.mk |
10 changes: 0 additions & 10 deletions
10
workspace/catOS/bsp/arch/cortex_m3/board/stm32f103c8t6_min/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
|
||
obj-y += catos_start.o | ||
obj-y += port_asm.o | ||
# obj-y += port_asm.o | ||
obj-y += port.o | ||
|
||
include $(RULE_DIR)/rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.