- 浏览: 1451126 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (691)
- linux (207)
- shell (33)
- java (42)
- 其他 (22)
- javascript (33)
- cloud (16)
- python (33)
- c (48)
- sql (12)
- 工具 (6)
- 缓存 (16)
- ubuntu (7)
- perl (3)
- lua (2)
- 超级有用 (2)
- 服务器 (2)
- mac (22)
- nginx (34)
- php (2)
- 内核 (2)
- gdb (13)
- ICTCLAS (2)
- mac android (0)
- unix (1)
- android (1)
- vim (1)
- epoll (1)
- ios (21)
- mysql (3)
- systemtap (1)
- 算法 (2)
- 汇编 (2)
- arm (3)
- 我的数据结构 (8)
- websocket (12)
- hadoop (5)
- thrift (2)
- hbase (1)
- graphviz (1)
- redis (1)
- raspberry (2)
- qemu (31)
- opencv (4)
- socket (1)
- opengl (1)
- ibeacons (1)
- emacs (6)
- openstack (24)
- docker (1)
- webrtc (11)
- angularjs (2)
- neutron (23)
- jslinux (18)
- 网络 (13)
- tap (9)
- tensorflow (8)
- nlu (4)
- asm.js (5)
- sip (3)
- xl2tp (5)
- conda (1)
- emscripten (6)
- ffmpeg (10)
- srt (1)
- wasm (5)
- bert (3)
- kaldi (4)
- 知识图谱 (1)
最新评论
-
wahahachuang8:
我喜欢代码简洁易读,服务稳定的推送服务,前段时间研究了一下go ...
websocket的helloworld -
q114687576:
http://www.blue-zero.com/WebSoc ...
websocket的helloworld -
zhaoyanzimm:
感谢您的分享,给我提供了很大的帮助,在使用过程中发现了一个问题 ...
nginx的helloworld模块的helloworld -
haoningabc:
leebyte 写道太NB了,期待早日用上Killinux!么 ...
qemu+emacs+gdb调试内核 -
leebyte:
太NB了,期待早日用上Killinux!
qemu+emacs+gdb调试内核
http://www.tuicool.com/articles/jYreMf
树莓派编译网卡
编译内核模块的helloworld的例子如下
环境:
1.linode虚拟机
2.centos系统,其他系统都行
3.下面ibm的代码,sample.tar.gz
4.编译内核模块需要源码
参考链接
http://blog.csdn.net/tigerjb/article/details/6010997
http://www.ibm.com/developerworks/cn/linux/l-cn-kernelmodules/index.html
上代码
Makefile
★★★★★★★★★★★★★★★我是罪恶的分割线★★★★★★★★★★★
步骤:
环境linode
centos6
由于linode的内核都是自己编译的
上网查了一些自己编译内核的方法,但是还是启动报错
参考http://www.xiaozhou.net/ittech/vps-ittech/upgrade_linode_vps_kernel_manually-2011-04-28.htm
★这个写得很好,学习了
后来自己下了
这一步是用系统当前的config文件
作为内核的make menuconfig或者make config产生的文件
配置项太jb多了
然后可能需要改
然后就会在/boot下面生成vmlinuz System.map
据说改了 /boot/grub/menu.lst重新启动 ,linode选pv-grub-x86-32
就能重新启动使用新内核了,但是我没试验成功,反正我是为了编译内核模块,又不是重新然linode好使,可能虚拟机还是和真实机器有莫名其买的差距吧,没深究
继续编译内核模块:
把新编译的源码链接到 系统已经存在的内核源码
其实不太对,但是两个都是3.8的差别还不算大,内核模块可用
回到罪恶的分割线上面的代码
表示内核已经正确装载了
lsmod查看模块
rmmod 删除模块
把上面ibm的的代码放到附件里了
树莓派编译网卡
编译内核模块的helloworld的例子如下
环境:
1.linode虚拟机
2.centos系统,其他系统都行
3.下面ibm的代码,sample.tar.gz
4.编译内核模块需要源码
参考链接
http://blog.csdn.net/tigerjb/article/details/6010997
http://www.ibm.com/developerworks/cn/linux/l-cn-kernelmodules/index.html
上代码
[root@li408-34 hello]# cat hello.c /* * $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $ * The code samples are covered by a dual BSD/GPL license from * Linux Device Drivers, Third Edition, by Jonathan Corbet, * Alessanfdro Rubini, and Greg Kroah-Hartman.Copyright * 2005 O鈥橰eilly Media, Inc., 0-596-00590-3. */ #include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, haoning-------------\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); } module_init(hello_init); module_exit(hello_exit);
Makefile
[root@li408-34 hello]# cat Makefile # To build modules outside of the kernel tree, we run "make" # in the kernel source tree; the Makefile these then includes this # Makefile once again. # This conditional selects whether we are being included from the # kernel Makefile or not. ifeq ($(KERNELRELEASE),) # Assume the source tree is where the running kernel was built # You should set KERNELDIR in the environment if it's elsewhere KERNELDIR ?= /lib/modules/$(shell uname -r)/build # The current directory is passed to sub-makes as argument PWD := $(shell pwd) modules: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules modules_install: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install clean: rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions \ *.order *.symvers .PHONY: modules modules_install clean else # called from kernel build system: just declare what our modules are obj-m := hello.o endif
★★★★★★★★★★★★★★★我是罪恶的分割线★★★★★★★★★★★
步骤:
环境linode
centos6
[root@li408-34 hello]# uname -a Linux li408-34 3.8.4-linode50 #1 SMP Mon Mar 25 15:50:29 EDT 2013 i686 i686 i386 GNU/Linux [root@li408-34 hello]# uname -r 3.8.4-linode50 [root@li408-34 hello]#
由于linode的内核都是自己编译的
上网查了一些自己编译内核的方法,但是还是启动报错
参考http://www.xiaozhou.net/ittech/vps-ittech/upgrade_linode_vps_kernel_manually-2011-04-28.htm
★这个写得很好,学习了
后来自己下了
linux-3.8.tar.xz xz -d linux-3.8.tar.xz tar xvf linux-3.8.tar cd linux-3.8 cp /proc/config.gz . gunzip config.gz mv config .config
这一步是用系统当前的config文件
作为内核的make menuconfig或者make config产生的文件
配置项太jb多了
然后可能需要改
CONFIG_PARAVIRT_GUEST=y CONFIG_XEN=y CONFIG_PARAVIRT=y CONFIG_PARAVIRT_CLOCK=y CONFIG_XEN_BLKDEV_FRONTEND=y CONFIG_XEN_NETDEV_FRONTEND=y CONFIG_HVC_XEN=y CONFIG_XEN_SCRUB_PAGES=y CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y CONFIG_IP_NF_SECURITY=n CONFIG_IP6_NF_SECURITY=n
#rm -rf /boot/* 看好了,这里可能原来就有启动的东西了,还是别删了 #开始编译 make modules make #安装内核 make install make modules_install
然后就会在/boot下面生成vmlinuz System.map
据说改了 /boot/grub/menu.lst重新启动 ,linode选pv-grub-x86-32
就能重新启动使用新内核了,但是我没试验成功,反正我是为了编译内核模块,又不是重新然linode好使,可能虚拟机还是和真实机器有莫名其买的差距吧,没深究
继续编译内核模块:
ln -s /root/kernel/linux-3.8 /lib/modules/3.8.4-linode50/build
把新编译的源码链接到 系统已经存在的内核源码
其实不太对,但是两个都是3.8的差别还不算大,内核模块可用
回到罪恶的分割线上面的代码
[root@li408-34 hello]# ls Makefile hello.c [root@li408-34 hello]# pwd /root/kk/samples/hello [root@li408-34 hello]#
[root@li408-34 hello]# make make -C /lib/modules/3.8.4-linode50/build M=/root/kk/samples/hello modules make[1]: Entering directory `/root/kernel/linux-3.8' CC [M] /root/kk/samples/hello/hello.o Building modules, stage 2. MODPOST 1 modules CC /root/kk/samples/hello/hello.mod.o LD [M] /root/kk/samples/hello/hello.ko make[1]: Leaving directory `/root/kernel/linux-3.8' [root@li408-34 hello]#
[root@li408-34 hello]# lsmod Module Size Used by [root@li408-34 hello]# [root@li408-34 hello]# ls Makefile Module.symvers hello.c hello.ko hello.mod.c hello.mod.o hello.o modules.order [root@li408-34 hello]# insmod hello.ko [root@li408-34 hello]# lsmod Module Size Used by hello 606 0 [root@li408-34 hello]# [root@li408-34 hello]# cat /proc/modules hello 606 0 - Live 0xede36000 (O) [root@li408-34 hello]# [root@li408-34 hello]# cd /sys/module/hello [root@li408-34 hello]# ls coresize holders initsize initstate notes refcnt sections taint uevent [root@li408-34 hello]# tree -a . |-- coresize |-- holders |-- initsize |-- initstate |-- notes | `-- .note.gnu.build-id |-- refcnt |-- sections | |-- .gnu.linkonce.this_module | |-- .note.gnu.build-id | |-- .rodata.str1.1 | |-- .strtab | |-- .symtab | `-- .text |-- taint `-- uevent 3 directories, 13 files [root@li408-34 hello]# dmesg ..... Hello, world Goodbye, cruel world [root@li408-34 hello]# tail -f /var/log/messages Apr 11 11:37:59 li408-34 abrtd: Init complete, entering main loop Apr 11 11:37:59 li408-34 init: Failed to spawn hvc0 main process: unable to execute: No such file or directory Apr 11 11:42:23 li408-34 kernel: Hello, haoning------------- Apr 11 11:43:56 li408-34 kernel: Goodbye, cruel world Apr 11 11:44:12 li408-34 kernel: Hello, haoning------------- Apr 11 13:51:49 li408-34 kernel: Goodbye, cruel world Apr 11 13:51:59 li408-34 kernel: Hello, haoning------------- Apr 11 14:44:21 li408-34 yum[4371]: Installed: tree-1.5.3-2.el6.i686 Apr 11 15:05:21 li408-34 kernel: Goodbye, cruel world Apr 11 15:05:51 li408-34 kernel: Hello, world
表示内核已经正确装载了
lsmod查看模块
rmmod 删除模块
把上面ibm的的代码放到附件里了
- samples.tar.gz (17 KB)
- 下载次数: 0
发表评论
-
xl2tp 备份
2019-09-24 16:25 5842019年9月24日更新: 注意,需要开启firewall ... -
sdl笔记
2019-01-31 17:19 696sdl教程教程 https://github.com/Twin ... -
tinyemu
2019-01-24 17:59 1411参考https://bellard.org/jslinux/t ... -
aws搭建xl2tp给iphone使用
2018-12-26 21:37 18262019年12月26日 可以参考原来的配置 https:// ... -
consul的基本使用
2017-06-27 11:13 1361### 安装 [centos7上consul的安装](ht ... -
lvs的helloworld
2017-06-13 20:36 570###################lvs######### ... -
系统调用的helloworld
2017-05-04 16:14 568《2.6内核标准教程》 p293 #include < ... -
bitcoin和cgminer的安装
2017-04-05 22:45 1929参考 http://blog.csdn.net/rion_ch ... -
ceph安装和常用命令
2017-03-21 21:55 921/etc/hosts ssh-keygen ssh-copy- ... -
mobile terminal 笔记
2016-12-02 15:35 554找出旧的iphone4 越狱之后可以变个小操作系统 mobi ... -
socket基础和select(python)
2016-06-14 17:21 1772上接 c语言的socket基础ht ... -
socket基础(c语言)
2016-06-14 16:45 956不使用select 普通的基础socket连接,对多个客户端的 ... -
ffmpeg+nginx 的直播(2,直播摄像头和麦克风)
2016-05-28 20:21 4268假设我的服务器是centos7 192.168.139.117 ... -
ffmpeg+nginx 的直播(1,直播播放的视频文件)
2016-05-26 17:11 653264位操作系统centos7 ############ 1.一 ... -
socat和netcat(nc)
2016-04-29 22:36 1694转 原文链接: http://www.wenquan.name ... -
neutron基础九(qemu nat网络)
2016-02-06 17:21 1570接上基础八,kvm透传nested忽略 1.在主机ce ... -
neutron基础八(qemu 桥接网络)
2016-02-06 13:13 1504qemu的桥接和nat的qemu启动命令是一样的,但是后续的脚 ... -
neutron基础七(qemu tap)
2016-02-02 17:02 981使用qemu 建立个虚拟机 然后用tap设备, 根据基础六,t ... -
neutron基础六(bridge fdb)
2016-01-28 18:30 2155转发表 在三台机器上建立三个namespace 192.16 ... -
南北流量
2016-01-23 23:26 1774一、三层网络架构: 接入层:负责服务器的接入和隔离 汇聚层:汇 ...
相关推荐
以helloworld模块在linux-2.4内核下的编写,编译,连接和运行例,简单介绍下linux-2.4下内核模块的编写。
Windows内核安全与驱动开发书的第一个示例程序,在新版本开发环境中调试通过,使用Visual Studio 2017加上WDK 1803环境编译。在调试过程中,由于x64驱动程序禁止使用嵌入汇编,采用Shellcode方式进行软件中断调用,...
2.2. 编译内核模块 2.3. Hello World (part 2) 2.4. Hello World (part 3): 关于 __init and __exit宏 2.5. Hello World (part 4): 内核模块证书和内核模块文档说明 2.6. 从命令行传递参数给内核模块 2.7. 由多个...
6、Linux内核模块编程:内核模块编程、卸载模块编程、参数模块编程 8、Linux内存管理:编写模块程序、编译、插入模块、查看打印信息 8、Linux设备驱动:编写一个简单的字符设备驱动、查看设备号、编写测试程序 使用...
一、linux内核编程环境搭建 升级kernel yum update kernel 原创文章 9获赞 10访问量 362 关注 私信 展开阅读全文 作者:权左
内核模块的文件,您应该首先构建这些文件以熟悉编译和安装已编译内核模块的基础知识。 内核模块 向 Linux 内核添加代码有两种主要方式。 一种方法是在编译过程中选择或添加代码编译到内核中。 另一种方法是在运行时...
使用编译内核法和内核模块法这两种添加系统调用的方法添加一个不用传递参数的系统调用,其功能是简单输出类似“hello wold”这样的字符串。 三. 实验步骤 3.1内核编译法添加系统调用 (1)通过su root 输入密码后...
1. 查看内核版本 [root@localhost test]# uname -r 3.10.0-862.el7.x86_64 2. 切换到相应的内核源码中 [root@localhost test]# cd /usr/src/kernels/3.10.0-862.el7.x86_64/drivers/ [root@localhost test]# ...
内核模块相比于应用程序 2.3.1. 用户空间和内核空间 2.3.2. 内核的并发 2.3.3. 当前进程 2.3.4. 几个别的细节 2.4. 编译和加载 2.4.1. 编译模块 2.4.2. 加载和卸载模块 2.4.3. 版本依赖 2.4.4. 平台依赖性 2.5. ...
1.1内核模块的编译文件 1.2 多文件内核模块 2.字符设备文件 2.1多内核版本源文件 3./proc文件系统 4.使用/proc进行输入 5.和设备文件对话(写和IOCTLS) 6.启动参数 7.系统调用 8.阻塞进程 9....
2.3. 内核模块相比于应用程序 2.3.1. 用户空间和内核空间 2.3.2. 内核的并发 2.3.3. 当前进程 2.3.4. 几个别的细节 2.4. 编译和加载 2.4.1. 编译模块 2.4.2. 加载和卸载模块 2.4.3. 版本依赖 2.4.4. 平台...
1.1内核模块的编译文件 4 1.2 多文件内核模块 5 2.字符设备文件 8 2.1多内核版本源文件 16 3./proc文件系统 17 4.使用/proc进行输入 22 5.和设备文件对话(写和IOCTLS) 30 6.启动参数 44 7....
Ubuntu10.04下驱动开发环境的建立(Linux驱动开发源码树的建立),包括 Linux内核:代码的下载,编译,新内核替换老内核...helloworld驱动:源码,编译,安装模块和卸载模块 我在建立开发源码树时遇到的问题及解决方法
内容hello.c :一个简单的“ hello world”模块hello-packet.c :每次计算机收到数据包时都记录日志。 可以很容易地修改这一包,使其在50%的时间内丢包。 rootkit.c :一个简单的rootkit。编译它们我正在运行Linux ...
读核感悟 kbuild系统 内核模块的编译 22 读核感悟 kbuild系统 编译到内核和编译成模块的区别 24 读核感悟 kbuild系统 make bzImage的过程 26 读核感悟 kbuild系统 make menuconfig 31 读核感悟 文件系统 用C来实现...
在这里,我们将编译一个内核模块,它拦截每个“读取”系统调用,搜索一个字符串,如果它看起来像 gcc 编译器或 python 解释器,则替换它。 这旨在演示受感染的系统如何从完全安全的源代码构建恶意二进制文件。 更...
读核感悟-kbuild系统-内核模块的编译.........................................22 读核感悟-kbuild系统-编译到内核和编译成模块的区别...........................24 读核感悟-kbuild系统-make bzImage的过程.........
1.1内核模块的编译文件........................................................................................................四 1.2 多文件内核模块........................................................
|-编译和加载内核HelloWorld ------------------------------ 2.内核编程基础 |-WIN64内核编程的基本规则 |-驱动程序与应用程序通信 |-内核里使用内存 |-内核里操作字符串 |-内核里操作文件 |-内核里操作注册表...
读核感悟-kbuild系统-内核模块的编译.........................................22 读核感悟-kbuild系统-编译到内核和编译成模块的区别...........................24 读核感悟-kbuild系统-make bzImage的过程.........