当前位置: 首页 > news >正文

编译linux内核或模块时遇到错误不显示报错信息的解决办法

【症状】
编译内核模块时,只显示最底部的Error,不显示任何C语言的错误信息。
[oct1158@fed41-bh8f7e0 first]$ make
make -C /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel M=/home/oct1158/Documents/Code/C/driver_test/first modules ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
make[2]: *** [scripts/Makefile.build:273: /home/oct1158/Documents/Code/C/driver_test/first/test.o] Error 1
make[1]: *** [Makefile:1935: /home/oct1158/Documents/Code/C/driver_test/first] Error 2
make: *** [Makefile:7: build] Error 2
[oct1158@fed41-bh8f7e0 first]$

【原因】
make命令中含有s字符,导致进入了安静模式。
make -C /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel M=/home/oct1158/Documents/Code/C/driver_test/first modules ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
在这句命令中,“driver_test”就含有s字符,所以就会触发安静模式。

$(MAKEFLAGS)变量的值:
rR --no-print-directory -- CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf- ARCH=arm M=/home/oct1158/Documents/Code/C/driver_test/first

$(filter-out --%,$(MAKEFLAGS))表达式的值:
rR CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf- ARCH=arm M=/home/oct1158/Documents/Code/C/driver_test/first
可见这个表达式含有s字符。

【解决办法】
注释掉内核根目录的Makefile文件里面的下面三句话。
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
  quiet=silent_
endif
禁止进入安静模式。

修改后就有错误信息输出了。
[oct1158@fed41-bh8f7e0 first]$ make
make -C /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel M=/home/oct1158/Documents/Code/C/driver_test/first modules ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
  CC [M]  /home/oct1158/Documents/Code/C/driver_test/first/test.o
/home/oct1158/Documents/Code/C/driver_test/first/test.c: In function 'mytestdriver_probe':
/home/oct1158/Documents/Code/C/driver_test/first/test.c:10:9: error: implicit declaration of function 'devm_gpiod_get'; did you mean 'em_pd_get'? [-Werror=implicit-function-declaration]
  gpio = devm_gpiod_get(&pdev->dev, NULL, GPIOD_OUT_HIGH); // led on
         ^~~~~~~~~~~~~~
         em_pd_get
/home/oct1158/Documents/Code/C/driver_test/first/test.c:10:42: error: 'GPIOD_OUT_HIGH' undeclared (first use in this function)
  gpio = devm_gpiod_get(&pdev->dev, NULL, GPIOD_OUT_HIGH); // led on
                                          ^~~~~~~~~~~~~~
/home/oct1158/Documents/Code/C/driver_test/first/test.c:10:42: note: each undeclared identifier is reported only once for each function it appears in
/home/oct1158/Documents/Code/C/driver_test/first/test.c: In function 'mytestdriver_remove':
/home/oct1158/Documents/Code/C/driver_test/first/test.c:28:3: error: implicit declaration of function 'gpiod_set_value'; did you mean 'bitmap_set_value8'? [-Werror=implicit-function-declaration]
   gpiod_set_value(gpio, 0); // led off
   ^~~~~~~~~~~~~~~
   bitmap_set_value8
cc1: all warnings being treated as errors
make[2]: *** [scripts/Makefile.build:273: /home/oct1158/Documents/Code/C/driver_test/first/test.o] Error 1
make[1]: *** [Makefile:1935: /home/oct1158/Documents/Code/C/driver_test/first] Error 2
make: *** [Makefile:7: build] Error 2
[oct1158@fed41-bh8f7e0 first]$

修改C语言的错误后:
[oct1158@fed41-bh8f7e0 first]$ make
make -C /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel M=/home/oct1158/Documents/Code/C/driver_test/first modules ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
  CC [M]  /home/oct1158/Documents/Code/C/driver_test/first/test.o
  MODPOST /home/oct1158/Documents/Code/C/driver_test/first/Module.symvers
  LD [M]  /home/oct1158/Documents/Code/C/driver_test/first/test.ko
[oct1158@fed41-bh8f7e0 first]$
编译通过了,CC MODPOST LD等字样也能正常显示了。

事实上,在编译内核模块时,就算make命令没带CROSS_COMPILE=参数,M=参数肯定是必须带的。我们很难保证M参数里面没有s这个字符。

https://zh.purasbar.com/post.php?t=31654https://zh.purasbar.com/post.php?t=31654

相关文章:

  • 自动化测试框架学习总结
  • 12.31[net]review
  • 力扣刷题——1759.统计同质字符串的数目
  • Spring Boot + MyBatis-Plus 项目目录结构
  • 数据结构——环形数组
  • 数字电子技术基础(二十八)——TTL门电路的静态功耗和动态功耗
  • 查找sql中涉及的表名称
  • 使用位运算如何找到数组中只出现一次的数?
  • docker笔记
  • QEMU源码全解析 —— 块设备虚拟化(3)
  • 如何在需求分析阶段考虑未来扩展性
  • c++介绍函数指针 十
  • 面试高频#LeetCode#Hot100-字母异位词分组
  • Generative Image Dynamics(动态图像生成)
  • uni-app学习笔记——自定义模板
  • 基于 GEE 的城市热岛效应分析——可视化地表温度 LST 与归一化植被指数 NDVI 的关联
  • <03.13>八股文补充知识
  • 24个希腊字母
  • Unity中WolrdSpace下的UI展示在上层
  • AI智能分析网关V4将HTTP消息推送至安防监控视频汇聚EasyCVR平台的操作步骤
  • 软件综合课设做网站/搜索引擎优化的核心是
  • oss可以做视频网站吗/济南市新闻最新消息
  • 网站建设费用选网络专业/谷歌搜索引擎营销
  • 邵阳做网站/口碑营销的优势
  • 北京公司网站制作要多少钱/浏览器谷歌手机版下载
  • 石家庄做外贸的网站推广/北京网站优化方式