insmod(arm linux中 mknod insmod mount区别与用法?cat/proc/devices是什么意思?谢谢)
1、Uboot:每个arm芯片或者海斯芯片都有各自的uboot。
2、但他们的内核版本可以是一样的,主要是跟各自内核的进行的编译选项有关, 31的内核版本里加了版本检查选项“Kernel type->Symmetrical Multi-Processing”,而21的内核版本没有设置该选项。
在开发kernel driver时,总是会遇到讨人厌的vermagic检查,只要目前在run的kernel版本跟driver编译时用的kernel版本不一致,就没办法insmod。
bash-3.2# insmod sdio.ko
sdio: version magic '2.6.28-271-gec75a15 preempt mod_unload modversions ARMv7 '
should be '2.6.28 preempt mod_unload ARMv7 '
insmod: init_mole 'sdio.ko' failed (Exec format error)
这大大降低了开发速度,尤其是当你拿不到客户在用的kernel时,又要开发driver给他用,真的是很麻烦……
那麼要怎麼利用恶心的方式绕过去呢???
一、先把 Moudle version 检查关掉。
user@host # ARCH=arm make menuconfig
--- Enable loadable mole support │ │
│ │ [ ] Forced mole loading │
│
│ │ [*] Mole unloading
│ │
│ │ [*] Forced mole unloading │
│
│ │ [ ] Mole versioning support │
│
│ │ [ ] Source checksum for all moles
二、 使用modinfo时,可以看到目前这driver的vermagic
filename: external_drivers/omap3530/Linux/sdio/sdio.ko
author: Texas Instruments Inc
alias: TIWLAN_SDIO
license: GPL
description: TI WLAN SDIO driver
depends:
vermagic: 2.6.28-271-gec75a15 preempt mod_unload ARMv7
parm: g_sdio_debug_level:debug level (int)
三、 修改 kernel 的 vermagic,再重新编译driver
vermagic 的第一个值 2.6.28-noneed 是由这 include/linux/utsrelease.h里的 UTS_RELEASE 所定义。
#define UTS_RELEASE "2.6.28-271-gec75a15"
之后再由 include/linux/vermagic.h 里的 macro
去组合出 VERMAGIC_STRING , 也就是 kernel 的vermagic。
#include
#include
#ifdef CONFIG_SMP
#define MODULE_VERMAGIC_SMP "SMP "
#else
#define MODULE_VERMAGIC_SMP ""
#endif
#ifdef CONFIG_PREEMPT
#define MODULE_VERMAGIC_PREEMPT "preempt "
#else
#define MODULE_VERMAGIC_PREEMPT ""
#endif完成编译后,你就可以得
#ifdef CONFIG_MODULE_UNLOAD
#define MODULE_VERMAGIC_MODULE_UNLOAD "mod_unload "
#else
#define MODULE_VERMAGIC_MODULE_UNLOAD ""
#endif
#ifndef CONFIG_MODVERSIONS
#define MODULE_VERMAGIC_MODVERSIONS "modversions "
#else
#define MODULE_VERMAGIC_MODVERSIONS ""
#endif
#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC ""
#endif
#define VERMAGIC_STRING \
UTS_RELEASE " " \
MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
MODULE_ARCH_VERMAGIC
所以, 我们只要把 UTS_RELEASE 改成我们的数字即可,当然若是懒得去try组合后的字串,也可以直接将VERMAGIC_STRING改成你要的字串
建议修改完 vermagic.h, utsrelease.h后,还是把kernel重编完再编kernel,比较保险。
以下是修改后,用modinfo看的结果
filename: external_drivers/omap3530/Linux/sdio/sdio.ko
author: Texas Instruments Inc
alias: TIWLAN_SDIO
license: GPL
description: TI WLAN SDIO driver
depends:
vermagic: 2.6.28 preempt mod_unload ARMv7
parm: g_sdio_debug_level:debug level (int)
------------------------------------------------------------------------------------------
另外若你是用git 做版本控制 , 那就会出现git的版本号在kernel 编号上
所以要把他关掉
General setup --->
[ ] Automatically append version information to the version strin
解释;
CONFIG_LOCALVERSION_AUTO:
│
│
│
│ This will try to automatically determine if the current tree is a │
│ release tree by looking for git tags that belong to the current │
│ top of tree revision.
│
│
│
│ A string of the format -gxxxxxxxx will be added to the localversion │
│ if a git-based tree is found. The string generated by this will be │
│ appended after any matching localversion* files, and after the value │
│ set in CONFIG_LOCALVERSION.
│
│
│
│ (The actual string used here is the first eight characters proced │
│ by running the command:
│
│
│ which is done within the script "scripts/setlocalversion".) │
│
│
│ Symbol: LOCALVERSION_AUTO [=y]
│
│ Prompt: Automatically append version information to the version string │
│ Defined at init/Kconfig:84
│
│ Location:
│
│ ingT
arm linux中 mknod insmod mount区别与用法?cat/proc/devices是什么意思?谢谢mknod 是创建设备节点命令
insmod 是加载内核模块的命令
mount 是挂载命令
编译后的内核模块xxxxx.ko 使用insmod加载,然后再/dev 下创建设备节点或者叫设备文件(使用的命令就是mknod)。
mount挂载用的和上面2个没啥联系、
cat/proc/devices 是查看内核使用的主设备号
insmod dev没文件我的操作步骤是(终端下执行的命令):
1)、命令:insmod xx.ko
2)、加载驱动成功后,命令:lsmod
3)、执行上面命令后,就能看到自己加载成功的驱动了。
4)、命令:cat /proc/devices
5)、执行上面命令后,找到自己驱动的名字。并且也能看到驱动对应的主设备号。
6)、命令:mknod /dev/(上面命令看到的名字) c 主设备号 从设备号(0)
7)、执行完上面的命令,在dev文件夹下就能看到驱动文件名字了。之后就可以操作了。
linux编程,图中insmod了一个模块,lsmod怎么什么都不显示,用的超级终端,A9的板子insmod后,使用lsmod查看,如果成功则可以看到刚才安装的mole。此时如果修改了mole代码要重新安装,则需要先rmmod刚才安装的模块才能重新安装,否则在insmod时会提示已经存在。
我的开发板是nfs挂载的root,rmmod时提示 rmmod : chdir(/lib/moles): No such file or directory
网上搜索,原来是因为busybox的rmmod实现中使用到了lib/moles/2..30.4/这个目录,因此在根文件系统的中必须存在lib/moles/2.6.30.4/这个目录才能卸载,其中的2.6.30.4是我的开发板的kernel版本号。遂创建该目录,并且将mole.ko拷贝至该目录,一切ok!
try!!!
如何在suse linux 中设置开机自动insmod加载vi /etc/mole
conf
insmod probe 什么时候调用最终,modprobe调用insmod先加载被依赖的模块,然后加载该被内核要求的模块
modprobe将insmod向 /lib/moles/version/[1]目录,该目录为默认标准存放内核模块的目录
linux命令insmod这个命令应该需要root权限来执行,通常在/sbin或/usr/sbin目录下
默认情况下,普通用户的PATH环境变量不包含它们,所以显示找不到
TAG:
热门标签: 接露水(1) 山湖(1) 神算(1) 爱上一个不该爱的人怎么办(1) 如何提高情商说话技巧和沟通能力(1)
注
部分信息与图片素材来源于互联网,如内容侵权与违规,请与本站联系,将立即处理,举报邮箱:1356571586@qq.com
随机关键词:

资源联系人
-
上一篇
excel行高怎么设置(excel行高怎么设置)
excel表格行高在哪里调整调整行高的方法如下: 1、首先,我们打开一个excel文档。 2、选中第三行,然后右击,弹出的界面,我们点击行高。 3、弹出的界面,我们输入15,然后点击确定。 4、结果如图所示,这样我们就将行高设置好了。 在Excel中超实用的四个...
-
上一篇
neurocomputing(neurocomputing期刊怎么样)
neurocomputing是什么期刊 neurocomputing简述1、Neurocomputing是Elsevier旗下的SCI期刊。 2、该期刊主要关注领域包括神经网络、机器学习等人工智能领域热门话题。随着人工智能领域越来越受到学术界的关注,该期刊的关注程度和影...