A simple device driver is developed:
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*
Run
$ Sudo make
The following error occurs:
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.
Everything on the internet is about how to compile the kernel and make menuconfig. At that time, I did not dare to compile the kernel at will, for fear of killing the system.
Later, I suddenly remembered that I had not fully read the manual. So I went to the manual to compile the kernel, which is the ARM kernel, it is necessary to create a kernel compiling environment similar to arm on the PC, that is, the cross compiling environment. Therefore, compile the kernel of arm according to the manual.
The specific operations are described in my other blog post: errors in the Cross-compilation environment during kernel Compilation