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 ...
随机推荐
- php window系统 xdebug+phpstorm 本地断点调试使用教程
运行环境: phpStorm 2017.2 PHP 7.1.5 Xdebug 2.6.1 php.ini添加xdebug模块 你需要仔细分析和选择要下载的对应版本,否则无法调试.由于非常容易出错,建议 ...
- P2365 任务安排 / [FJOI2019]batch(斜率优化dp)
P2365 任务安排 batch:$n<=10000$ 斜率优化入门题 $n^{3}$的dp轻松写出 但是枚举这个分成多少段很不方便 我们利用费用提前的思想,提前把这个烦人的$S$在后面的贡献先 ...
- 从路由器镜像中提取uImage头信息
uImage header为64字节,文件头为27 05 19 56 hexdump -C a.bin | grep "27 05 19 56" 或者 hd aa.bin | gr ...
- 国服最强JWT生成Token做登录校验讲解,看完保证你学会!
转载于:https://blog.csdn.net/u011277123/article/details/78918390 Free码农 2017-12-28 00:08:02 JWT简介 JWT(j ...
- GDB in Action
GDB in Action 入门 编译 gcc -g -O0 -o word2vec.c word2vec -g 选项:要求 gcc 编译器保留调试符号信息. -O0 选项表示不优化,从 O1 ~ O ...
- Java基础学习-Java语言概述
一.Java语言发展史 创始人:詹姆斯·高斯林(James Gosling) 公司:SUN——(Stanford University Network斯坦福大学网络公司) 1995年5月23日,Jav ...
- ffmpeg 图像转视频 视频转图像
ffmpeg使用 以下两条可使用,具体可参考:https://blog.csdn.net/pkueecser/article/details/8555261pic to video:ffmpeg -f ...
- Git 与 GitHub 入门级
今天我们来搞一下Git 这东西虽然没啥搞头儿,但是开发当中还必须得会用,谁让你我都是苦逼的开发呢~~~~ 一.下载与安装 这玩意简单,给你赋个图片,自己研究一下~~~~ 1.官网:https://gi ...
- HADOOP HA 踩坑 - org.apache.hadoop.hdfs.qjournal.protocol.JournalNotFormattedException: Journal Storage Directory /mnt/data1/hadoop/dfs/journal/hdfscluster not formatted
报错:在journalnode的log中: org.apache.hadoop.hdfs.qjournal.protocol.JournalNotFormattedException: Journal ...
- redis 序列化存入对象
redis 序列化存入对象 //序列化 public static byte [] serialize(Object obj){ ObjectOutputStream obi=null; ByteAr ...