原创:http://blog.sina.com.cn/u/2312748742
例一
hellomod.c
#include
#include
#include
MODULE_LICENSE("GPL");
module_param(nbr, int, S_IRUGO);
{
}
static void __exityuer_exit(void)
{
}
module_exit(yuer_exit);
================================
Makefile:
ifneq($(KERNELRELEASE),)
hellomodule-objs :=hellomod.o
obj-m :=hellomodule.o
else
PWD:=$(shell pwd)
KVR?=$(shell uname -r)
#KDIR:=/lib/modules/$(KVR)/build
KDIR:=/workspace/TI-DM365/git-20111108
l:
clean:
endif
执行 make。将会生成hellomodule.ko 。拷贝到arm板中。insmod hellomodule.ko加载模块。
实验成功。
必须先编译内核。make uImage
例二、=======================================>>>>
lcdtest.c 文件
#include
#include
#include
MODULE_LICENSE("GPL");
#define SYSTEM_PINMUX1 *(volatile unsigned int*)0x01c40004
#define SYSTEM_PINMUX2 *(volatile unsigned int*)0x01c40008
#defineGIO_DIR23
#define GIO_OUTDATA23
#define GIO_SETDATA23
#define GIO_CRLDATA23
#defineGIO_DIR45
#define GIO_OUTDATA45
#define GIO_SETDATA45
#define GIO_CRLDATA45
void UTIL_waitLoop(int loopcnt);
void Davinci_light_lcd(void);
void Davinci_shutdown_lcd(void);
void Davinci_shutdown_lcd(void)
{
//
//end
}
void Davinci_light_lcd(void)
{
//
//end
}
void UTIL_waitLoop(int
{
}
{
}
static void __exit yuer_exit(void)
{
}
module_init(yuer_init);
module_exit(yuer_exit);
-----------------------------------------------------------
Makefile文件;
ifneq($(KERNELRELEASE),)
lcdmod-objs :=lcdtest.o
obj-m :=lcdmod.o
else
PWD:=$(shell pwd)
KVR?=$(shell uname -r)
KDIR:=/lib/modules/$(KVR)/build
#KDIR:=/workspace/TI-DM365/git-20111108
all:
clean:
endif
-------------------------------------------------------
编译时;makeKDIR=/workspace/TI-DM365/git-20111108
实验不成功,以为地址不能这样直接用。待验证。