编译 buildroot 错误录
为什么要记录编译过程的错误?
- 问题定位和诊断
明确错误来源:编译错误记录提供了错误发生的位置和性质,使工程师能够迅速定位到问题的源头。日志通常会包含文件名、行号以及错误消息,帮助工程师确定出错的代码段。
历史追踪:记录的错误信息可以帮助追踪错误的历史,从而识别是否是由于最近的代码修改引入的问题。 - 改进开发效率
迅速修复:准确的错误记录可以减少调试时间,让开发人员更快地修复问题,而不必手动查找每个可能的错误点。
减少重复错误:通过分析错误记录,开发人员可以识别出常见的错误模式,从而采取措施避免类似问题的再次出现。 - 代码质量提高
代码审查:编译错误记录可以用作代码审查的依据,帮助团队识别和改正代码中的缺陷。
学习和改进:记录的错误信息为工程师提供了学习的机会,尤其是新手工程师可以通过分析这些错误,了解常见问题及其解决方法,从而提升编程技能。 - 沟通和协作
错误记录可以帮助其他人,有效的沟通。如果一个错误难以解决,别人可以将错误日志分享给需要寻求帮助的人。
作者:炭烤毛蛋 ,点击博主了解更多。
提示: 编译日志信息提示比较全面,要耐心仔细查看。
1. 内核编译错 错误
错误一
scripts/kconfig/conf --syncconfig Kconfig
HOSTLD scripts/dtc/dtc
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:99: scripts/dtc/dtc] Error 1
make[1]: *** [scripts/Makefile.build:637: scripts/dtc] Error 2
make: *** [Makefile:1187: scripts] Error 2
ERROR: Running build_kernel failed!
ERROR: exit code 2 from line 501:
make ARCH=$RK_ARCH $RK_KERNEL_DTS.img -j$RK_JOBS
检查 gcc 编译版本。开发环境 22.04,gcc version 11.4.0 符合要求。
gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
根据提示 修改 scripts/dtc/dtc-lexer.lex.c 中错误位置进行屏蔽,或者增加外部变量引用。
-YYLTYPE yylloc;
+extern YYLTYPE yylloc;
错误二
config=/home/1126/buildroot/output/rv1126/.rockchipconfig Config.in
#
# configuration written to /home/1126/buildroot/output/rv1126/.config
#
make: Leaving directory '/home/1126/buildroot'
====Start build rv1126====
2022-07-17T17:13:30 >>> host-m4 1.4.18 Building
Done in 7s (error code: 2)
Command exited with non-zero status 2
you take 0:08.57 to build ramboot
ERROR: Running build_ramboot failed!
ERROR: exit code 2 from line 565:
/usr/bin/time -f "you take %E to build ramboot" $COMMON_DIR/mk-ramdisk.sh ramboot.img $RK_CFG_RAMBOOT
builtroot 编译错误
错误一
Done in 8s (error code: 2)
Failed to build rockchip_rv1126_evb_tb:
# 2022-07-17 11:31:24
2022-07-17T11:31:24 make: Entering directory '/home/rv1126/buildroot'
2022-07-17T11:31:31 /usr/bin/make -j1 O=/home/rv1126/buildroot/output/rockchip_rv1126_evb_tb HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" syncconfig
2022-07-17T11:31:31 make[1]: Entering directory '/home/rv1126/buildroot'
2022-07-17T11:31:31 GEN /home/rv1126/buildroot/output/rockchip_rv1126_evb_tb/Makefile
2022-07-17T11:31:32 make[1]: Leaving directory '/home/rv1126/buildroot'
2022-07-17T11:31:32
2022-07-17T11:31:32 Your PATH contains spaces, TABs, and/or newline (n) characters.
2022-07-17T11:31:32 This doesn't work. Fix you PATH.
2022-07-17T11:31:32 make: *** [support/dependencies/dependencies.mk:27: dependencies] Error 1
2022-07-17T11:31:32 make: Leaving directory '/home/rv1126/buildroot'
Please check details in /home/rv1126/output/log/2022-07-17_11-29-18/br-rockchip_rv1126_evb_tb_2022-07-17_11-31-24.log
Command exited with non-zero status 1
you take 0:17.37 to build buildroot
ERROR: Running /home/rv1126/device/rockchip/common/scripts/mk-rootfs.sh - build_buildroot failed!
ERROR: exit code 1 from line 13:
/usr/bin/time -f "you take %E to build buildroot" "$SCRIPTS_DIR/mk-buildroot.sh" $RK_BUILDROOT_CFG "$ROOTFS_DIR"
摘取关键错误信息如下:
2022-07-17T11:31:32 Your PATH contains spaces, TABs, and/or newline (n) characters.
2022-07-17T11:31:32 This doesn't work. Fix you PATH.
2022-07-17T11:31:32 make: *** [support/dependencies/dependencies.mk:27: dependencies] Error 1
our PATH contains spaces, TABs, and/or newline (n) characters. 错误提示表明你的操作系统中的环境变量 PATH 包含了空格、制表符或换行符等非法字符,这可能导致编译时出现问题。
错误原因: WSL默认引入 windows 环境参量
修改方法
:重置 PATH 环境变量。
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
make
错误二
warning: Python 3 support is currently experimental. YMMV.
Please use Python 2.6 - 2.7 instead.
rv1126/.repo/repo/main.py:19: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
import imp
Traceback (most recent call last):
File "rv1126/.repo/repo/main.py", line 46, in <module>
from subcmds.version import Version
File "rv1126/.repo/repo/subcmds/__init__.py", line 33, in <module>
mod = __import__(__name__,
尝试将 repo 脚本解释器,修改 #!/usr/bin/env python
为 #!/usr/bin/env python2
,经过测试问题解决。
vi .repo/repo/repo
-#!/usr/bin/env python
-#!/usr/bin/env python2
错误三
2022-07-24T13:34:41 g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
查阅相关信息后,认为是虚拟机内存不足造成。参照《Android 编译报错记录篇》增加服务器交换分区内存可以解决此问题。
错误四
2022-07-24T09:44:05 g++: fatal error: Killed signal terminated program cc1plus
2022-07-24T09:44:05 compilation terminated.
2022-07-24T09:44:05 make[1]: *** [Makefile:182: cmGeneratorTarget.o] Error 1
2022-07-24T09:44:05 make[1]: *** Waiting for unfinished jobs....
2022-07-24T09:44:09 make[1]: Leaving directory '/home/rv1126/buildroot/output/rockchip_rv1126_evb_tb/build/host-cmake-3.22.3/Bootstrap.cmk'
与错误三 原因相同,日志体现略有不同。解决方法嘛,就不用细说咯。
错误五
ERROR: Running build_buildroot failed!
ERROR: exit code 1 from line 556:
/usr/bin/time -f "you take %E to build builroot" $COMMON_DIR/mk-buildroot.sh $BOARD_CONFIG
问题原因:buildroot 环境变量发生变迁,无法正常执行。
解决方案:清除当前编译缓存 ./build.sh cleanall
,然后重新编译 ./build.sh
。
错误六
2022-07-24T15:28:07 >>> camera_engine_rkaiq 1.0 Building
Done in 10min 17s (error code: 2)
Command exited with non-zero status 2
you take 10:18.63 to build ramboot
ERROR: Running build_ramboot failed!
ERROR: exit code 2 from line 565:
查看 br.log 发现是文件缺失。
2022-07-24T15:28:07 ### conver iqfile: /home/1126/buildroot/output/rv1126/build/camera_engine_rkaiq-1.0/iqfiles/os04c10_DW-RV04C_2G2P650IR-F21.xml
2022-07-24T15:28:07 /bin/bash: /home/1126/buildroot/output/rv1126/host/bin/rkisp_parser: No such file or directory
2022-07-24T15:28:07 make[1]: *** [package/pkg-generic.mk:258: /home/1126/buildroot/output/rv1126/build/camera_engine_rkaiq-1.0/.stamp_built] Error 127
2022-07-24T15:28:07 make: *** [/home/1126/buildroot/output/rv1126/Makefile:16: _all] Error 2
日志提示 rkisp_parser 命令无法正常执行,手动验证确实存在问题。
/home/1126/buildroot/output/rv1126/host/bin/rkisp_parser
No such file or directory
解决方法:更替 rkisp_parser 为当前系统可执行文件。
Tips
编译错误日志内容很详细。
结语
不枉博主详细讲解,欢迎订阅博主–炭烤毛蛋 。