1在linux内核根目录下(有arch文件夹的目录),此目录下运行终端,make menuconfig
在弹出的配置界面中,进行linux操作系统的各种配置,包括cpu的架构等。
其中涉及设备驱动程序的是:
kernel-2.6.13/drivers/char/Kconfig文件,配置字符型设备的配置选项
在配置界面中,Device Drivers Character devices 选择要配置的驱动。
在配置界面中,对Kernel Feautre -> Preemptible Kernel (EXPERIMENTAL)选项,打开;
把xxx.c(xxx设备驱动源代码)放到A文件夹下,并在该文件夹下放一个makefile,makefile内容如下:
obj-m := hello.o
KERNELDIR :=/home/fpga/qq2440/codes/examples/kernel-2.6.13-qq2440-20081028/kernel-2.6.13
#对应到自己开发板得内核目录
default:
make -C $(KERNELDIR) M=$(shell pwd) modules
install:
insmod hello.ko
uninstall:
rmmod hello.ko
clean:
make -C $(KERNELDIR) M=$(shell pwd) clean
然后在A文件夹下的终端中运行:make
(若多次编译,记得先clean再make)
生成的hello.ko
用ftp方式将hello.ko发送至开发板
在开发板上切换路径为/home/plg
在plg文件夹下看到ftp接收来的hello.ko,然后运行insmod hello.ko即可看到运行结果。
记得chmod 777 xxx.ko