小弟刚开始接触潜入式系统,写了一个程序,请大侠们指点一下:
/*hello.c*/
#include<linux/init.h>
#include<linux/module.h>
#include<linux/moduleparam.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "hello,world\n");
return 0;
}
static int hello_exit(void)
{
printk(KERN_ALERT "goodbye,world\n");
return 0;
}
module_init(hello_init);
module_exit(hello_exit);
之后写了一个makefile程序
ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
.PHONY:modules modules_install clean
else
obj-m:=hello.o
endif
在根目录下执行make,结果如下:
root@wuyi:/home/wuyi/hello# make
make -C /lib/modules/2.6.24-16-generic/build M=/home/wuyi/hello modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.24-16-generic'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/linux-headers-2.6.24-16-generic'
在此目录下执行:insmod hello.ko,结果什么都看不到,恳请大侠指点,这是怎么回事阿,谢谢
关于hello world的问题
-
- 帖子: 55
- 注册时间: 2008-05-09 22:00
- 联系:
-
- 帖子: 4
- 注册时间: 2008-05-29 8:39