设为首页 加入收藏

TOP

HC32L110(三) HC32L110的GCC工具链和VSCode开发环境(二)
2023-07-23 13:28:01 】 浏览:42
Tags:HC32L110 GCC VSCode
quot;: "shell", "command": "make clean;make", "problemMatcher": [] }, { "label": "build, download", "type": "shell", "command": "make;make flash", "problemMatcher": [] }, { "label": "download", "type": "shell", "command": "make flash", "problemMatcher": [] }, { "label": "build", "type": "shell", "command": "make", "problemMatcher": [] }, { "label": "clean", "type": "shell", "command": "make clean", "problemMatcher": [] }, ] }

平时使用时, 用Alt + Shift + F10就可以调出Task菜单, 快速执行编译和烧录等操作.

编译选项

项目中新增代码目录和单个C文件

User目录下的代码, Makefile已经覆盖, 会自动添加无需修改 Makefile. 如果新增其他的目录需要包含整个目录, 或包含单个源文件, 可以编辑Makefile中的这部分

# C source folders
CDIRS	:= User \
		Libraries/CMSIS \
		Libraries/HC32L110_Driver/src
# C source files (if there are any single ones)
CFILES := 

其中 CDIRS 用于目录的添加, CFILES 用于单个C源文件的添加.

除此以外, 如果有新增的 include 路径, 需要添加到 INCLUDES 这个变量中

# Include paths
INCLUDES	:= Libraries/CMSIS \
			Libraries/HC32L110_Driver/inc \
			User

如果编译与预期不符, 在make时增加V=1查看实际的命令行.

调整编译参数

编译的参数都在 rules.mk 文件中,

# Global compile flags
CFLAGS		= -Wall -ggdb -ffunction-sections -fdata-sections
ASFLAGS		= -g -Wa,--warn

# Arch and target specified flags
OPT			?= -Os
CSTD		?= -std=c99
ARCH_FLAGS	:= -fno-common -mcpu=cortex-m0plus -mthumb

# c flags
TGT_CFLAGS 	+= $(ARCH_FLAGS) $(addprefix -D, $(LIB_FLAGS))
# asm flags
TGT_ASFLAGS += $(ARCH_FLAGS)
# ld flags
TGT_LDFLAGS += --specs=nano.specs -mcpu=cortex-m0plus -mthumb -nostartfiles -Wl,--gc-sections -Wl,-Map=$(BDIR)/$(PROJECT).map -Wl,--print-memory-usage

如果要优化编译的结果大小或执行速度, 需要修改OPT参数, -O0是无优化, -O1是基础优化, -Os是尺寸压缩, 具体优化项参考 https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

OPT			?= -Os

其中-ffunction-sections -fdata-sections-Wl,--gc-sections是非常重要的参数, 如果不使用这些参数, 编译的结果大概会超出HC32L110的16K字节限制.

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Linux命令之find、grep、echo、ta.. 下一篇最新资讯丨2022年08月04日,IEC60..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目