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 ...
随机推荐
- h5 的localStorage和sessionStorage存到缓存里面的值是string类型
localStorage永久存在,不手动清除永远存在:sessionStorage 一次会话的浏览器关闭就自动清除 h5 的localStorage和sessionStorage 存到缓存里面的值都是 ...
- codeforces #305 C Mike and Foam
首先我们注意到ai<=50w 因为2*3*5*7*11*13*17=510510 所以其最多含有6个质因子 我们将每个数的贡献分离, 添加就等于加上了跟这个数相关的互素对 删除就等于减去了跟这个 ...
- chrome内核浏览器插件的使用--Tampermonkey(油猴插件)
Tampermonkey(油猴插件),这个插件是一个用于改造你浏览器打开的网站的插件.它可以在你打开的网页中注入任意js脚本,以达到你想要的外加功能.可以说非常不错.很多时候也值得使用. 这是个chr ...
- ElasticSearch(七) Elasticsearch在Centos下搭建可视化服务
要想可视化ElasticSearch,就需要安装一些插件,安装插件的前提是安装所依赖的环境,比如java,maven等,本篇博文就不再走那些流程了.没安装的童鞋可以看我的ElasticSearch栏目 ...
- 解决使用eclipse创建maven web项目时报Could not resolve archetype的问题
前两天重装了系统,今天想写一个项目的时候出现了点问题. 在使用eclipse创建maven web项目时,点Finish后报了Could not resolve archetype的问题. Could ...
- loj2353. 「NOI2007」 货币兑换
loj2353. 「NOI2007」 货币兑换 链接 https://loj.ac/problem/2353 思路 题目不重要,重要的是最后一句话 提示 输入文件可能很大,请采用快速的读入方式. 必然 ...
- Robot Framework安装及配置
Robot Framework安装及配置 需要按照的软件有Python.WxPython.robot framework.robotframework-ride.robotframework-sele ...
- Hadoop启动之后jps没有NameNode节点
这是因为多次格式化namenode节点出现的问题 1.先运行stop-all.sh 2.删除原目录,即core-site.xml下配置的<name>hadoop.tmp.dir</n ...
- 关于var time = +new Date;
文章地址:https://www.cnblogs.com/Raoh/p/4212075.html
- 2015-10-13 jQuery5实例
jQuery(5) 一.扑克牌切换 <body> <div class="ig ig1"><img src="image/1.jpg&q ...