树莓派驱动开发 helloworld

编写Makefile

ifneq ($(KERNELRELEASE),)  
  
obj-m := MiniX.o  
  
else  
      
KDIR := /home/hi/pi/kernel/linux/  
all:  
	make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=/home/hi/pi/kernel/RpiTools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi-  
  
clean:  
	rm -f *.ko *.o *.mod.o *.mod.c *.symvers  modul*  
  
endif

 

编写main.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 void hello_exit(void)
{
    printk(KERN_ALERT"Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

  

  

posted on 2016-03-16 17:16  qwerhq  阅读(1427)  评论(0)    收藏  举报

导航