【linux驱动开发】编译linux驱动程序报错:ERROR: Kernel configuration is invalid.

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录


一、报错

在编译驱动程序过程中,经常碰到的一个小问题:

bash 复制代码
make -C /home/lubancat/LubanCat_SDK/kernel M=/home/lubancat/lubancat_rk_code_storage/linux_driver/device_tree modules
make[1]: Entering directory '/home/lubancat/LubanCat_SDK/kernel'
  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.
Makefile:630: include/config/auto.conf: No such file or directory
make[1]: *** [Makefile:691: include/config/auto.conf] Error 1
make[1]: Leaving directory '/home/lubancat/LubanCat_SDK/kernel'
make: *** [Makefile:10: all] Error 2

二、解决方法

1.先编译linux内核源码

步骤1如下:

bash 复制代码
lubancat@lubancat-vm:~/LubanCat_SDK/kernel$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- lubancat2_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#

步骤2如下:

bash 复制代码
lubancat@lubancat-vm:~/LubanCat_SDK/kernel$ make ARCH=arm64 -j4 CROSS_COMPILE=aarch64-linux-gnu- dtbs
.....等待编译完成,这里省略中间的编译过程,最后的输出结果如下即可
Image Name:   
Created:      Tue Jul 29 14:27:08 2025
Image Type:   AArch64 Linux Script (uncompressed)
Data Size:    1258 Bytes = 1.23 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 1250 Bytes = 1.22 KiB = 0.00 MiB

2.再重新编译驱动程序

Makefile文件内容如下

bash 复制代码
#指定linux内核源码的路径
KERNEL_DIR=/home/lubancat/LubanCat_SDK/kernel

ARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu-
export  ARCH  CROSS_COMPILE

obj-m := get_dts_info.o
all:
	$(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules

.PHONE:clean

clean:
	$(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean	

直接make,即可编译成功

相关推荐
大树889 小时前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠10 小时前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质10 小时前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
bush410 小时前
嵌入式linux学习记录十四、术语
linux·嵌入式
载数而行52010 小时前
Linux 11 动态监控指令top
linux
Inhand陈工11 小时前
基于台达PLC与映翰通IG502的智慧水产养殖精准投喂与远程运维解决方案
运维·人工智能·物联网·阿里云·信息与通信
酣大智11 小时前
ARP代理--工作原理
运维·网络·arp·arp代理
不会C语言的男孩11 小时前
Linux 系统编程 · 第 8 章:进程基础
linux·c语言
shushangyun_12 小时前
2026年快消品B2B系统推荐:支持终端门店订货、促销政策自动化的工具?
java·运维·网络·数据库·人工智能·spring·自动化
古城小栈12 小时前
Unix 与 Linux 异同小叙
linux·服务器·unix