My First Linux Module
My First Linux Module
Today, I successfully build my first linux hello module.
First of all add a directory named hello in the kernel/driver, and add a file hello.c, write codes like bellow:
#include <linux/init.h>
#include <linux/module.h> static int __init hello_init(void)
{
printk(KERN_ERR " Hello, world!\n");
return ;
} static void __exit hello_exit(void)
{
printk(KERN_ERR " Goodbye, world!\n");
} module_init(hello_init);
module_exit(hello_exit); MODULE_AUTHOR("Bob, Zhang");
MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("A simple hello world demo");
MODULE_ALIAS("A simple module");
Then create a Kconfig file:
config HELLO
tristate "HELLO WORLD Driver!"
default m
help
HELLO WORLD
And create a Makefile file:
obj-m += hello.o
Next Add the Kconfig and Makefile into the Kconfig file and Makefile file in parent directory.
Finally run the commands bellow:
make ARCH=arm CROSS_COMPILE=$tool_prefix my_kernel_defconfig
make ARCH=arm CROSS_COMPILE=$tool_prefix modules
mkdir ./moduls_temp
make ARCH=arm CROSS_COMPILE=$tool_prefix modules_install INSTALL_MOD_PATH=./modules_temp
At last, the demo run like this:

My First Linux Module的更多相关文章
- Linux Module
catalog . 概述 . 使用模块 . 插入和删除模块 . 自动化与热插拔 . 版本控制 1. 概述 模块(module)是一种向Linux内核添加设备驱动程序.文件系统及其他组件的有效方法,而无 ...
- linux/module.h: No such file or directory 内核模块编译过程
1.缺少Linux kernel头文件 To install just the headers in Ubuntu: sudo apt-get install linux-headers-$(unam ...
- linux Module驱动开发-一切刚刚开始
linux内核是可以高度定制的,通过配置编译选项达到定制的目的. 在配置kernel编译选项时驱动程序的编译选项一般有三种,不编译.编译为内核驱动.编译为模块驱动.所以linux驱动一般分为两类,内核 ...
- Linux Module框架【转】
转自:http://www.cnblogs.com/LittleHann/p/4558719.html catalog 1. 概述 2. 使用模块 3. 插入和删除模块 4. 自动化与热插拔 5. 版 ...
- <linux/init.h>,<linux/module.h>头文件不存在等问题的解决方法
这个问题真心是处理了一个下午,还自己去下载了个最新的内核拿来编译,其实是完全没必要的,因为ubuntu系统是可以直接下载新内核的. 你可以在/usr/src/文件夹下找到这些内核文件夹,比如说我自己的 ...
- 自己写Linux module来收集buddy info
1 编写代码pslist.c 1: #include<linux/init.h> 2: #include<linux/module.h> 3: #include<linu ...
- Linux module 添加到bashrc 和临时ifort编译器 以及python2和3的配置
第一步vim ~/.bashrc按键盘的i然后source /home/export/online1/bjpara/para/modules/scripts/cn-module.sh最后:x! bas ...
- 简单实例讲解linux的module模块编译步骤
注:原博文地址http://blog.sina.com.cn/s/blog_4ba5b45e0102v25h.html ---------------------------------------- ...
- linux kernel module
#include <linux/init.h>#include <linux/module.h>#include <linux/kernel.h> static i ...
随机推荐
- 移动端picker插件
项目需要,要做移动端网页,比如选择出生日期什么的.可笑weui给的控件,竟然选择后的数据不准确. 于是自己写了一个. 链接: https://pan.baidu.com/s/1qY2SSxQ 密码: ...
- FutureBuilder的使用以及防止FutureBuilder不必要重绘的两种方法
https://blog.csdn.net/u011272795/article/details/83010974 https://segmentfault.com/a/119000001421934 ...
- PHP 订单延时处理:延迟队列(未鉴定)
PHP 订单延时处理:延迟队列: https://github.com/chenlinzhong/php-delayqueue
- Windows下Python安装numpy+mkl,Scipy和statsmodels
最近做时间序列分析需要用到Python中的statsmodels,但是安装过程中遇到很头疼的问题,Google.Stackover各种都没有找到合适的解决办法,而且貌似还有很多同学也在吐槽Window ...
- Learning-Python【7】:Python数据类型(3)—— 字典、集合
一.字典类型 1.用途:用来存放多个不同种类的值 2.定义方式:在{ }内用逗号分隔开多个key:value的元素,其中value可以是任意数据类型,而key的功能通常是用来描述value的,所以ke ...
- win10 处理程序“ExtensionlessUrlHandler-Integrated-4.0”在其模块列表中有一个错误模块“ManagedPipelineHandler”
更新Win10,原来的IIS站点访问不了,原因是因为IIS 没有.net 4.5,使用网上的aspnet_regiis.exe -i命令,一点都不靠谱,直接提示: C:\WINDOWS\system3 ...
- 最短路计数——Dijkstra
题目: 给出一个N个顶点M条边的无向无权图,顶点编号为1−N.问从顶点1开始,到其他每个点的最短路有几条. ——传送门 受到题解的启发,用 Dijkstra A掉(手工代码) 思路: 1.无向无权图, ...
- android -------- OkGo (让网络请求更简单的框架)
项目地址:https://github.com/jeasonlzy 该库是封装了okhttp的网络框架,可以与RxJava完美结合,比Retrofit更简单易用.支持大文件上传下载,上传进度回调,下载 ...
- pipenv使用总结
一.pipenv默认虚拟环境路径在用户目录下的.\virtualenvs下,不同虚拟环境目录不同,如果要更改为在当前项目根目录下,可以在项目根目录下手动创建.venv目录. 1.linux环境下设置环 ...
- spring boot扫描mapper文件
一个简单的功能,百度查的都是XX,谷歌万岁. 因为扫描不到自动生成的mapper就无法注入到service 方案一.@Mapper 如果Mapper文件所在的包和你的配置mapper的项目的pom定义 ...