ERROR: Kernel configuration is invalid.

最简单的linux hello的驱动源程序

//下面是驱动源代码  

#include <linux/init.h>  
#include <linux/module.h>   

static int hello_init(void)  
{  
    printk(KERN_ALERT "Hello, Tekkaman Ninja !\n");  
    return 0;  
}  

static void hello_exit(void)  
{  
    printk(KERN_ALERT "Goodbye, Tekkaman Ninja !\n Love Linux !Love ARM ! Love KeKe !\n");  
}  

module_init(hello_init);  
module_exit(hello_exit);  



MODULE_LICENSE("Dual BSD/GPL");  

下面是Makefile

#!/bin/bash
#通知编译器我们要编译模块的哪些源码
#这里是编译itop4412_hello.c这个文件编译成中间文件itop4412_hello.o
obj-m += mini_linux_module.o 

#源码目录变量,这里用户需要根据实际情况选择路径
#作者是将Linux的源码拷贝到目录/home/topeet/android4.0下并解压的
KDIR := /home/iTop4412_Kernel_3.0

#当前目录变量
PWD ?= $(shell pwd)

#make命名默认寻找第一个目标
#make -C就是指调用执行的路径
#$(KDIR)Linux源码目录,作者这里指的是/home/iTop4412_Kernel_3.0
#$(PWD)当前目录变量
#modules要执行的操作
all:
    make -C $(KDIR) M=$(PWD) modules

#make clean执行的操作是删除后缀为o的文件
clean:
    rm -rf *.o

执行make出现错误

make -C /home/kernel/iTop4412_Kernel_3.0 M=/mnt/code/01qudong/mini_linux_module modules
make[1]: Entering directory '/home/kernel/iTop4412_Kernel_3.0'

  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.


  WARNING: Symbol version dump /home/kernel/iTop4412_Kernel_3.0/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /mnt/code/01qudong/mini_linux_module/mini_linux_module.o
cc1: fatal error: include/generated/autoconf.h: No such file or directory
compilation terminated.
scripts/Makefile.build:311: recipe for target '/mnt/code/01qudong/mini_linux_module/mini_linux_module.o' failed
make[2]: *** [/mnt/code/01qudong/mini_linux_module/mini_linux_module.o] Error 1
Makefile:1368: recipe for target '_module_/mnt/code/01qudong/mini_linux_module' failed
make[1]: *** [_module_/mnt/code/01qudong/mini_linux_module] Error 2
make[1]: Leaving directory '/home/kernel/iTop4412_Kernel_3.0'
Makefile:18: recipe for target 'all' failed
make: *** [all] Error 2

或者是

make[1]: Entering directory `/home/xduser/study/driver/src/linux-2.6.22'    

      ERROR: Kernel configuration is invalid.    
      include/linux/autoconf.h or include/config/auto.conf are missing.    
       Run 'make oldconfig && make prepare' on kernel src to fix it.    
  WARNING: Symbol version dump /home/xduser/study/driver/src/linux-2.6.22'/Module.symvers is missing; modules will have no dependencies and modversions.   

原因是内核没有编译,先处理内核 编译
简单说一说内核编译
1、先make distclean,然后确认主Makefile的设置
(1)主要是检查交叉编译工具链有没有设置对。CROSS_COMPILE ?= /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-
(2)确认ARCH = arm。主要目的是为了编译时能找到arch/arm目录。
2、make x210ii_qt_defconfig
最后出现configuration written to .config,就证明我们的操作是正确的。
如果没有得到.config文件,不能进入下一步。实测发现没有.config也可以make menuconfig,但是这样做出来的内核编译和烧写运行应该是有问题的。
3、make menuconfig
(1)可能出现的错误1:ncurses库没装
错误信息:
* Unable to find the ncurses libraries or the
* required header files.
* ‘make menuconfig’ requires the ncurses libraries.


* Install ncurses (ncurses-devel) and try again.
解决方案:apt-get install libncurses5-dev
(2)可能出现的错误2:屏幕太小
错误信息:
Your display is too small to run Menuconfig!
It must be at least 19 lines by 80 columns.
解决方案:全屏,或者是把字体调小。

总结:
(1)这里会弹出配置界面。
(2)make menuconfig是第二步配置。
(3)因为此内核是九鼎已经移植过的,因此这里的配置可以不做,直接退出即可。
4、make
编译完成后得到的内核镜像不在源码树的根目录下,而是在arch/arm/boot这个目录下。
得到的镜像名是zImage。

  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 错误:内核配置无效。include/generated/autoconf.h或include/config/auto.conf文件丢失。在内核源上运行'make oldconfig && make prepare'以修复它。 ### 回答2: 这个错误通常是在编译内核时出现的,意思是内核配置文件无效,可能是某些必要的文件缺失。要解决这个问题,需要运行“make oldconfig”命令。该命令将为您提供一个默认的内核配置文件,其中包含了大多数配置选项。接着您可以在这个配置文件的基础上进行更改,以满足您的需求。 要运行“make oldconfig”命令,您需要进入内核源代码目录,并执行以下操作: 1. 输入“make menuconfig”命令,打开内核配置菜单。 2. 在菜单中找到“Load an Alternate Configuration File”选项,选中它。 3. 输入“./arch/x86/configs/x86_64_defconfig”来加载默认的内核配置文件。 4. 保存并退出菜单。 5. 接着输入“make oldconfig”命令进行配置。 6. 最后,您可以运行“make”命令进行内核编译。 注意,这个方法可能并不适用于所有情况,具体解决方法需要根据您的实际情况而定。在一些情况下,问题可能是由于缺少必要的库文件造成的,您需要安装这些库文件才能成功编译内核。在其他情况下,问题可能是由于内核源代码本身存在问题,您需要重新下载一份正确的源代码。无论出现何种情况,您需要按照错误提示来尝试解决问题。如果您无法解决问题,可以向相关内核社区寻求帮助,他们会乐意为您提供帮助。 ### 回答3: 您好,这是一个Linux内核的编译错误,在编译时系统会在/include/generated/(包括autoconf.h)和/include/config/(包括auto.conf)目录中查找自动生成的配置文件。当这些自动生成的文件缺失或不存在时,就会出现出现“error: kernel configuration is invalid”的错误提示。 为了解决这个问题,您可以尝试运行“make oldconfig”命令来生成缺失的配置文件。在生成过程中,系统会自动使用旧的配置文件,并弹出一些配置选项供您选择,如果您不确定可以直接按回车键使用默认值。完成配置后,系统会将自动生成的配置文件写入/include/generated/和/include/config/目录下。 如果这个错误还是无法解决,可能需要您手动检查配置文件及其相关路径是否正确,或者卸载旧内核重新安装新的内核。在实际操作过程中,请务必备份重要数据和设置,以免数据丢失或系统不可用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值