include/linux/autoconf.h or include/config/auto.conf are missing.

来源:互联网 发布:我是大美人淘宝官方店 编辑:程序博客网 时间:2024/05/16 07:45

做了一个简单的设备驱动程序:

ARM_hello.c

#include <linux/module.h>static int hello_init(void){    printk("Hello, I am coming !\n");    return 0;}static void hello_exit(void){    printk("Goodbye, I Love Linux ! I Love ARM ! \n");}module_init(hello_init);module_exit(hello_exit);

Makefile:

#--------------------------for ARM----------------------------------CROSS_COMPILE := /opt/FriendlyARM/toolschain/4.4.3/bin/arm-linux-CC :=$(CROSS_COMPILE)gccKERNEL_DIR := /opt/FriendlyARM/mini2440/linux-2.6.32.2#------------------------------------------------------------------obj-m :=ARM_hello.oPWD := $(shell pwd)all:make -C $(KERNEL_DIR) M=$(PWD) modulesclean:rm -fr *.o *.ko *.mod.o *.mod.c .*.cmd *.order *.*s *~ .tmp*

执行

$ sudo make

出现如下错误:

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.

网上都说是要编译内核什么,make menuconfig 什么的,当时不敢随便编译内核,怕把这个系统搞死了。

后来,突然想起来手册我没有完全看完,于是去翻手册,原来真的要编译内核,这个内核是ARM的内核,因为需要在PC上制造出一个和ARM也一样的内核编译环境,也就是交叉编译环境,所以,按照手册,编译了一下ARM的那个内核。

具体操作在我的另一篇博文中:交叉编译环境之编译内核阶段各种错误