【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,即可编译成功

相关推荐
不像程序员的程序媛4 小时前
系统cpu内存负载资源分析
运维·服务器·数据库
Uncertainty!!6 小时前
Ubuntu 22.04 安装超好用中文输入法rime-ice(雾凇拼音)过程记录
linux·ubuntu·中文输入法
ShineWinsu7 小时前
对于Linux:网络基础的解析
linux·网络·面试·udp·笔试·ip·tcp
Asuicao7 小时前
centos7.9版本升级ssh OpenSSH 9.8p1 源码 OpenSSL 1.1.1w 源码包以及安装升级回滚文档
运维·ssh
志栋智能7 小时前
超自动化安全中的威胁狩猎
运维·安全·自动化
↘"LYong8 小时前
旧版 CentOS 安装 Docker 完整指南(附国内镜像加速)
linux·运维·docker
Zhang~Ling8 小时前
Vim 多模式详解:命令、插入、底行与插件配置
linux·编辑器·vim
Elastic 中国社区官方博客9 小时前
Elastic 在 Everest Group 企业搜索产品 PEAK Matrix® 评估 2026 中被评为领导者
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
程序员在囧途9 小时前
likeadmin-api API 中转站怎么做统一报价?从 /pricing、/user/balance 到 task_id 回执的落地方法
运维·服务器·数据库·likeadmin-api·api中转站·token计费
想你依然心痛10 小时前
Linux用户空间与内核空间通信:netlink、ioctl、mmap 零拷贝与性能对比
linux·运维·服务器