Ubuntu中编译helloworld驱动
1、 新建hello文件夹
2、hello.c
#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif // 下面的是主要的内容
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h> MODULE_LICENSE("GPL"); static int year=; int hello_init()
{
printk(KERN_ALERT "Hello kernel, it's %d!\n",year);
return ;
} void hello_exit()
{
printk(KERN_ALERT "Bye, kernel!\n");
} // 下面两个为关键的模块函数
module_init(hello_init);
module_exit(hello_exit);
3、 Makefile
obj-m := hello.o all :
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
注意:$(MAKE)前面为一个TAB键
4、 make

3、 insmod hello.ko
4、 dmesg

Ubuntu中编译helloworld驱动的更多相关文章
- android在ubuntu中编译为.apk资料
android在ubuntu中编译为.apk文件 今天我在ubuntu环境之下将android程序编译为.apk文件,特将其过程写下来: 1. 在windows环境下使用MyEclipse编辑好and ...
- ubuntu下编译内核驱动。
目的: 1. 驱动热身.网上有很多类似的文章可供参考. 2. 在操作系统中, 编写这个设备的驱动. 3. 为写qemu的watchdog驱动练手. 有朋友问make的 watchdog驱动 需要什么准 ...
- 配置android source 在ubuntu中编译环境
在Ubuntu中可以配置 android source 编译环境,推荐使用最新的64位的Ubuntu LTS(Long Time Support); 1.安装JDK. AOSP主分支代码需要java ...
- 在Ubuntu中编译QT工程Tesful
今天晚上开机到Ubuntu中了,试了一下之前在Windows下建立的Tesful工程,发现没有任何改动就可以编译成功/运行. 附上图:
- 解决一个Ubuntu中编译NEON优化的OpenCV的错误
在Ubuntu 16中编译开启NEON优化的Opencv时,遇到libpng编译是使用汇编代码的错误,完整错误见文章末尾.通过查询发现解决方案是安装跨平台编译器,安装代码如下: sudo apt-ge ...
- ubuntu中编译安装gcc 9.2.0
一切都和其他源码安装软件是一样的: 一.下载源代码: http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz 二.解压文件 tar xvf gcc- ...
- PHP在ubuntu中编译安装
关于怎么获取php源码和解压就不再说了. 编译的参数为: ./configure --prefix=/opt/php --with-bz2 --with-mcrypt --with-mhash --w ...
- Ubuntu中编译链接Opencv应用的简便方式
安装完毕Opencv后,使用下面命令查 看编译/连接參数 pkg-config --cflags --libs opencv 可看到例如以下信息 -I/usr/include/opencv /usr ...
- 在ubuntu中编译内核是用make …
执行过程如下: root@zyx-VirtualBox:~# cd /opt/EmbedSky/ root@zyx-VirtualBox:/opt/EmbedSky# cd linux-2.6.30. ...
随机推荐
- scrapy中自动补全url
url = "https:" + url 或者url = response.urljoin(url) #这里代表的是自动补全url
- python day 03作业答案
1. (10) name='aleX leNb' print(name.split('l',1)) (13) name='aleX leNb' a=name.replace('a','A') prin ...
- Refused to execute inline event handler because it violates the following Content Security Policy directive: "xxx". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...')
/********************************************************************************* * Refused to exec ...
- Skflow mac安装 for tensorflow-0.8.0
参考: # Mac OS X, CPU only: $ pip install --ignore-installed --upgrade https://storage.googleapis.com/ ...
- django,uwsgi, nginx部署项目
在liunx中环境中 对于nginx来说: 1.先安装nginx sudo apt-get install nginx 2.启动nginx服务 sudo /etc/init.d/nginx resta ...
- url的反向解析
1. url的语法格式: url(regex, views, **kwargs, name) name:为地址起别名,反向解析时使用 2.反向解析 对于Django中的url反向解析,是分模板和视图的 ...
- BZOJ-5244 最大真因数(min25筛)
题意:一个数的真因数指不包括其本身的所有因数,给定L,R,求这个区间的所有数的最大真因数之和. 思路:min25筛可以求出所有最小因子为p的数的个数,有可以求出最小因子为p的所有数之和. 那么此题就是 ...
- C# 后台获取前台交互判断
前台传来明细 ,判断是否修改,在把前台 的数据组成新的类保存 public class tt { public string id { get; set; } public string e_id { ...
- ios-根据单元格里的控件tag值,在方法外获得对应的section与row的值
在cell的代理方法里:cellForRowAtIndexPath btn.tag = indexPath.section *100 + indexPath.row; [cell.exitPerson ...
- node学习笔记之io.sockets
socket.get和socket.set函数已经失效,代码修改如下所示: 服务器端: var httpd = require('http').createServer(handler); var i ...