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

相关推荐
取经蜗牛3 小时前
Ubuntu 国内镜像源配置指南(多版本常用镜像地址都有)
linux·运维·ubuntu
实心儿儿4 小时前
Linux —— 线程控制(1)
linux·运维·服务器
筠筠喵呜喵4 小时前
Linux软件开发性能优化
linux·c++·性能优化
Bruce_kaizy4 小时前
c++ linux环境编程——文件io介绍以及open 、write 、read 三剑客深度详解
linux·服务器·c++·ubuntu·操作系统·文件io
亦良Cool5 小时前
VMware虚拟机ubuntu瘦身,解决虚拟机越用越大
linux·运维·ubuntu
星辰&与海6 小时前
KVM + QEMU虚拟化方案
linux·运维
宋浮檀s6 小时前
应急响应——恶意流量&攻击行为识别
linux·运维·网络·网络安全·应急响应
REDcker6 小时前
Linux OverlayFS详解
java·linux·运维
Yunzenn7 小时前
深度分析字节最新研究cola-DLM 第 07 章:推理流水线逐行拆解 —— 从 prompt 到生成文本
人工智能·驱动开发·深度学习·chatgpt·架构·prompt·github
zizle_lin7 小时前
WSL的系统安装和部分环境配置(按需操作)
运维