我需要从头开始为omap4编写SPI Linux字符设备驱动程序.我知道编写设备驱动程序的一些基础知识.但是,我不知道如何从头开始编写平台特定的设备驱动程序.
我写了一些基本的char驱动程序,我认为编写SPI设备驱动程序与它类似.Char驱动程序具有file_operations包含驱动程序中实现的功能的结构.
struct file_operations Fops = {
.read = device_read,
.write = device_write,
.ioctl = device_ioctl,
.open = device_open,
.release = device_release, /* a.k.a. close */
};
Run Code Online (Sandbox Code Playgroud)
现在,我将通过spi-omap2-mcspi.c代码作为参考,以便从头开始开始开发SPI驱动程序.
但是,我没有看到打开,读取,写入等功能.不知道程序从哪里开始.
我正在尝试在我的intel x86主机上为ARM体系结构交叉编译helloworld内核(2.6.x)模块.
ARM的代码源工具链位于:/ home/ravi/workspace/hawk/arm-2009q3
内核源代码位于:/ home/ravi/workspace/hawk/linux-omapl1
我的Makefile:
ARCH=arm
CROSS_COMPILE=arm-none-linux-gnueabi
obj-m := Hello.o
KDIR := /home/ravi/workspace/hawk/linux-omapl1
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
Run Code Online (Sandbox Code Playgroud)
当我运行make时,.ko生成的是我的主机,这意味着makefile正在调用本机编译器而不是交叉编译器.我做错了什么?交叉编译器的二进制文件在我的路径中.
makefile cross-compiling kernel-module embedded-linux linux-toolchain