树莓派 - 驱动hello

31 篇文章 0 订阅
28 篇文章 0 订阅

树莓派上Linux驱动,从hello world 开始 ... 

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 void hello_exit(void)  
{  
    printk(KERN_ALERT"Goodbye, cruel world\n");  
}  
  
module_init(hello_init);  
module_exit(hello_exit);

Makefile

ifneq ($(KERNELRELEASE),)  
  
obj-m := hello.o  
  
else  
      
KDIR := /home/xxx/Raspberry/linux 
all:  
	make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=/home/xxx/Raspberry/tools-master/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-

clean:  
	rm -f *.ko *.o *.mod.o *.mod.c *.symvers  modul*  
  
endif 

make生成hello.ko

将hello.ko 通过sftp 传给树莓派板


在树莓派班上

$ sudo insmod hello.ko

查看:

$ dmesg | grep Hello
[ 7454.663309] Hello, world
$ lsmod |grep hello
hello                  16384  0


pi@raspberrypi:/sys/module/hello $ tree -a
.
├── coresize
├── holders
├── initsize
├── initstate
├── notes
│   └── .note.gnu.build-id
├── refcnt
├── sections
│   ├── .ARM.exidx
│   ├── .ARM.extab
│   ├── .gnu.linkonce.this_module
│   ├── __mcount_loc
│   ├── .note.gnu.build-id
│   ├── .rodata.str1.4
│   ├── .strtab
│   ├── .symtab
│   └── .text
├── srcversion
├── taint
└── uevent

3 directories, 17 files


pi@raspberrypi:~ $ sudo rmmod hello
pi@raspberrypi:~ $ dmesg | grep Goodbye
[ 8385.391257] Goodbye, cruel world

参考

http://www.cnblogs.com/xianrou/p/6327897.html


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
树莓派LCD驱动/2.8/3.2/3.5/3.97/4.3/5/7等! You can focus on the following GitHub web site, for the latest lcd drivers: https://github.com/goodtft/LCD-show =============================================================================================================== "LCD-show-170315.tar.gz" just for Raspbian (Release date:2017-03-02) or later, DO NOT use it for the Raspbian version before 2017-03-02. ================================================================================================================ "LCD-show-160701.tar.gz" support Raspbian version before Raspbian-2017-02-16,such as(2017-02-16,2017-01-11, 2016-11-25,2016-09-23,2016-05-27,2016-05-10,2016-03-18,or earlier). And This Driver also tesed on "kali-2.1.2" ,"ubuntu-mate-16.04-beta2" ================================================================================================================ How to Install: 1.)Step1, Install Raspbian official mirror a)Download Raspbian official mirror: https://www.raspberrypi.org/downloads/ b)Use“SDFormatter.exe”to Format your TF Card c)Use“Win32DiskImager.exe” Burning mirror to TF Card 2.) Step2, Clone my repo onto your pi git clone https://github.com/goodtft/LCD-show.git chmod -R 755 LCD-show cd LCD-show/ 3.)Step3, According to your LCD's type, excute: In case of 2.8" LCD sudo ./LCD28-show In case of 3.2" LCD sudo ./LCD32-show In case of 3.5" LCD sudo ./LCD35-show In case of 3.97" LCD sudo ./LCD397-show In case of 4.3" LCD sudo ./LCD43-show In case of 5" LCD sudo ./LCD5-show In case of 7inch(B)-800X480 RPI LCD sudo ./LCD7B-show In case of 7inch(C)-1024X600 RPI LCD sudo ./LCD7C-show If you need to switch back to the traditional HDMI display sudo ./LCD-hdmi Wait a few minutes,the system will restart automaticall , enjoy with your LCD.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值