insmod/lsmod/modinfo/modprobe/depmod工具使用

insmod lsmod modinfo

insmod一个模块的时候出现问题: Invalid module format
在这里插入图片描述
通过modinfo查看模块信息,发现模块的vermagic与内核的版本是不匹配的。
在这里插入图片描述
第一种解决办法是使用目标板子上所用的内核重新编译模块
第二种办法是insmod -f xxx.ko或者insmod --force-vermagic xxx.ko (但是现在的insmod好像不支持这些参数)


modprobe depmod

如何实现modprobe,使用modprobe来加载这些模块
modprobe不会知道module之间的依赖性,而是通过读取/lib/modules/2.6.xx/modules.dep文件获知,这个文件是通过depmod建立的。开发板上modules.dep文件生成步骤如下:
步骤1: mkdir -p /lib/modules/uname -r
步骤2:将源码linux-imx目录下的modules.order和modules.builtin复制到/lib/modules/uname -r目录下
步骤3:执行depmod -a会生成modprobe的依赖文件modules.dep


rmmod

-f, --force This option can be extremely dangerous: it has no effect unless CONFIG_MODULE_FORCE_UNLOAD was set when the kernel was compiled. With this option, you can remove modules which are being used, or which are not designed to be removed, or have been marked as unsafe (see lsmod(8)).

rmmod -f出现的问题:
a. rmmod: ERROR: Resource temporarily unavailable
内核CONFIG_MODULE_FORCE_UNLOAD未使能之前,rmmod会出现

b. rmmod: ERROR: could not remove Device or resource busy
First I wouldn’t do the __KERNEL__ and MODULE defines
Second you aren’t telling the kernel what the init and exit fuctions are, you need to do something like
module_init(init_module);
module_exit(cleanup_module);
Third they need to be declared to be of a type module_init and module_exit can work with, use the __init and __exit macros to do this.
static int __init init_module(void) {…}
static int __exit cleanup_module(void) {…}
Forth make sure you are using a compatible compiler, if they aren’t compatible you’ll sometimes get this issue


参考文章

  1. Building modules for a precompiled kernel
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luckywang1103

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值