`
koliy
  • 浏览: 146685 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

android-insmod驱动模块出错问题解决方法

 
阅读更多

转载:http://hi.baidu.com/bamboolsu/blog/item/3b8a8608f8e2f98fd0581b79.html
---------------------------------------------------------------------

insmod: error inserting 'hello.ko': -1 Invalid module




1, make xconfig
General setup---->>>local version -append to kernel release:       在这儿添加下面内容
-170.2.117.fc10.i686

or modify ./.config file:
#
# General setup
#
CONFIG_EXPERIMENTAL=y
CONFIG_LOCK_KERNEL=y
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_LOCALVERSION="-170.2.117.fc10.i686"

.config配置文件
在内核树的根目录中,有一个.config文件,它记录了内核的配置选项,可直接对它进行修改,再运行(若.config不存在,对内核进行配置后会生成它,这种情况下当然不能开始就运行oldconfig). 实际上, 如果你手头有合适的 .config 文件, 可以运行 make oldconfig  直接按 .config 的内容来配置


2, save config

3, make kernel
then the ./include/linux/utsrelease.h  will change from linux-2.6.27.41 to linux-2.6.27.41-170.2.117.fc10.i686



[leo@leo linux-2.6.27.41-170.2.117.fc10.i686]$ findcode 2.6.27.41
./include/linux/autoconf.h: * Linux kernel version: 2.6.27.41
./include/linux/utsrelease.h:#define UTS_RELEASE "2.6.27.41"
[leo@leo linux-2.6.27.41-170.2.117.fc10.i686]$ vi ./include/linux/utsrelease.h


[leo@leo test]$ sudo cat /var/log/messages | tail
Jul  2 17:07:32 leo dhcpd: DHCPACK on 192.168.1.93 to 00:02:9b:48:7a:04 via eth1
Jul  2 17:09:46 leo kernel: hello: version magic '2.6.27.41 SMP mod_unload 686 4KSTACKS ' should be '2.6.27.41-170.2.117.fc10.i686 SMP mod_unload 686 4KSTACKS '





  在使用命令ismod helloworld.ko 加载编译成功的模块helloworld.ko时出现错误  insmod: error inserting 'helloworld.ko': -1 Invalid module format
一般出错信息被记录在文件/var/log/messages中
[root@hailiang linux-2.6.15.5]# cat /var/log/messages |tail

  May  8 16:41:45 hailiang kernel: helloworld: version magic '2.6.27.5-117.fc10.i686 SMP mod_unload modversions 686 4KSTACKS ' should be '2.6.27.5-117.fc10.i686 SMP mod_unload 686 4KSTACKS '

通过命令看一下模块的相关信息

[root@hailiang tmp]# modinfo helloworld.ko
filename:       helloworld.ko
alias:          a simplest module
description:    A simple helloworld module
author:         zhanghailiang
depends:       
vermagic:       2.6.27.5-117.fc10.i686 SMP mod_unload modversions 686 4KSTACKS  

内核无法加载模块的原因是因为记载版本号的字符串和当前正在运行的内核模块的不一样,这个版本印戳作为一个静态的字符串存在于内核模块中,叫vermagic,可以从编译模块中间生成的文件helloworld.moc.h中

#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>

MODULE_INFO(vermagic, VERMAGIC_STRING);找到这个符号,

打开文件/usr/src/kernels/2.6.27.5-117.fc10.i686/include/linux/vermagic.h (注意在fedroa 10 中源码树是在/usr/src/下)

#include <linux/utsrelease.h>
#include <linux/module.h>

/* Simply sanity version stamp for modules. */
#ifdef CONFIG_SMP
#define MODULE_VERMAGIC_SMP "SMP "
#else
#define MODULE_VERMAGIC_SMP ""
#endif
。。。。。。。。。。。。。。。。。。。
#ifdef CONFIG_MODVERSIONS
#define MODULE_VERMAGIC_MO

DVERSIONS "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


从这里看出vermagic中多出来的字符modversions是由于编译内核时选上了 “”选项的原因,(其实这是因为在编译helloworld模块前,自己曾试图重新编译内核所致:cd /usr/src/kernel..

[root@hailiang 2.6.27.5-117.fc10.i686]# make menuconfig
scripts/kconfig/mconf arch/x86/Kconfig
#
# configuration written to .config
#



*** End of Linux kernel configuration.
*** Execute 'make' to build the kernel or try 'make help'.

[root@hailiang 2.6.27.5-117.fc10.i686]# make
scripts/kconfig/conf -s arch/x86/Kconfig
CHK     include/linux/version.h
CHK     include/linux/utsrelease.h
make[1]: *** No rule to make target `missing-syscalls'.  Stop.
make: *** [prepare0] Error 2

)见下图





然后再重新编译helloworld.ko模块,然后再加载helloworld 成功。

  一点别的:在网上对这个问题有另一个解决方法就是modprobe --force-vermagic helloworld强制加载内核,在这里我试了一下问题还是原来invalid module format

注意:(1)modprobe   模块名(不要带后缀.ko)   注:挂载一个模块

(2)在这里直接modprobe ./helloworld 错误
FATAL: Module helloworld not found.
这是因为

使用man modprobe看

DESCRIPTION

      modprobe intelligently adds or removes a module from the Linux kernel: note that  for  conve-
nience, there is no difference between _ and - in module names.  modprobe looks in the module
directory /lib/modules/‘uname -r‘ for all  the  modules  and  other  files,  except  for  the
optional  /etc/modprobe.conf  configuration  file  and  /etc/modprobe.d  directory  (see mod-
probe.conf(5)). modprobe will also use module options specified on the kernel command line i
modprobe会自动在/lib/modules/'uname -r'下寻找模块加载,将helloworld.ko拷到/lib/modules 下然后再执命令 modprobe helloworld 发现还是找不到,从man modprobe

  modprobe  expects  an  up-to-date  modules.dep  file, as generated by depmod (see depmod(8))

看出还需要依赖命令:depmod生成的module.dep 使用这个命令后 在modprobe helloworld 成功





findcode sell program.


#!/bin/sh                      

if [ "$1" = "" ]; then
echo "Syntax:"   
echo " fcode [-q] [-i] [-b] [-t] [-nc] [-p path] code"
echo " -q: only print file names"                    
echo " -i: case insensitive"                         
echo " -b: look also in build dirs: '*-linux-gnu/...'"
echo " -t: don't look in '3pp/...'"
echo " -nc: no color grep (is useful when piping output)."

exit
fi

path=.

grep_cmd="/bin/grep --color=always"

while (( "$#" )); do
if [ "$1" == "-q" ] ; then
quiet="-l"
fi
if [ "$1" == "-i" ] ; then
ignore_case="-i"
fi
if [ "$1" == "-b" ] ; then
### This will destroy the pruning of *-linux-gnu and
### therefore those directories will be checked:
check_build_dirs="true"
fi
if [ "$1" == "-t" ] ; then
skip_3pp="-name 3pp -prune -or"
fi
if [ "$1" == "-p" ] ; then
shift;
path="$1"
fi
if [ "$1" == "-nc" ]; then
grep_cmd="/bin/grep"
fi

code=$1
shift;
done

find $path -name "dist" -prune -or -name ".svn" -prune -or \
-name "*-linux-gnu$check_build_dirs" -prune -or $skip_3pp \
-iname "*.c" -or -iname "*.h" -or -iname "*.cpp" -or \
-name "Makefile*" -or -name "Imakefile" -or -name "dist_*" -or \
-name "dist-*" -or -name "*.idl" -or -name "*.htm*" -or \
-name "*.xml" -or -name "*.sh" -or -name "*.perl" -or \
-name "*.pl" -or -name "configure" -or -name "*.in" -or \
-name "*.patch" -or -name "PATCHES" | sed -e "s/ /\\\ /g" | \
xargs $grep_cmd $quiet $ignore_case "$code"







分享到:
评论

相关推荐

    insmod解决.txt )

    insmod解决.txt ) insmod解决.txt ) insmod解决.txt ) insmod解决.txt ) insmod解决.txt )

    p720_ov2640_r58_dev拍照和录像都是720p的分辨率20160713_1430.7z

    手工加载vfe_v4l2.ko驱动模块之后,生成了设备节点/dev/video0。 赶紧修改为/dev/video0。然后使用adb push进去。 修改属性之后,摄像头还是不显示。重启之后正常了。这里折腾了好久!!!! R:\wyb\p720_ov2640_...

    r58_bmi160_bma250_ov2640_dev点亮VGA的ov2640HDMI显示_20160630_1142.7z

    手工加载vfe_v4l2.ko驱动模块之后,生成了设备节点/dev/video0。 赶紧修改为/dev/video0。然后使用adb push进去。 修改属性之后,摄像头还是不显示。重启之后正常了。这里折腾了好久!!!! R:\wyb\r58_bmi160_...

    ov7670_ruoge_kerun_r8增加摄像头的亮度20160630_1526.7z

    2、在init.rc(init.sun5i.rc)中加载ov7670.ko这个驱动模块。 R:\wyb\ov7670_ruoge_kerun_r8\android\device\softwinner\nuclear-evb\init.sun5i.rc #csi module insmod /system/vendor/modules/videobuf-core.ko ...

    insmod过程.pdf

    insmod过程pdf--莫搬砖员

    ruoge_kerun_r8_ov2643显示为VGA_20160630_1613.7z

    2、在init.rc(init.sun5i.rc)中加载ov2643.ko这个驱动模块。 R:\wyb\ruoge_kerun_r8_ov2643\android\device\softwinner\nuclear-evb\init.sun5i.rc #csi module insmod /system/vendor/modules/videobuf-core.ko ...

    vga_ov5640_ruoge_kerun_r8_20160629_1426.7z

    2、在init.rc(init.sun5i.rc)中加载ov5640.ko这个驱动模块。 R:\wyb\vga_ov5640_ruoge_kerun_r8\android\device\softwinner\nuclear-evb\init.sun5i.rc #csi module insmod /system/vendor/modules/videobuf-core...

    c674x-irq-events.ko

    omapl138双核通信开发驱动组件,如果在insmod c67x-irq-events.ko发现没有这个组件的话,可以直接把这个组件放在指定目录下

    Linux内核驱动模块编程指南

    linux 驱动编程参考书 注意是英文的

    索智R16开发板点亮ov7725+ov2640+ov5640_20160721_1726.7z

    驱动里面搜索可以设置为:1600x1200, 1280x960, 1024x768, 1280x720, 800x600(出错), 640x480 R:\wyb\test_ov2640_r16\android\device\softwinner\astar-evb20\configs\camera.cfg ;---------------------------...

    !!!!gc2135_parrotv1.1_r16m_验证完成VGA分辨率_20171010_1513没有外层目录.7z

    驱动里面搜索可以设置为:1600x1200, 1280x960, 1024x768, 1280x720, 800x600(出错), 640x480 R:\wyb\test_ov2640_r16\android\device\softwinner\astar-evb20\configs\camera.cfg ;---------------------------...

    gc2135_parrotv1.1_r16m_验证完成VGA分辨率_20171010_1700没有外层目录.7z

    驱动里面搜索可以设置为:1600x1200, 1280x960, 1024x768, 1280x720, 800x600(出错), 640x480 R:\wyb\test_ov2640_r16\android\device\softwinner\astar-evb20\configs\camera.cfg ;---------------------------...

    linux gigabyte ga-945gzm-s2 网卡驱动

    今天将系统转成Linux,完成系统安装后却发现网卡驱动有问题.在网上找了半天也没有发现好的解决办法(也可能是我用google的能力不行),最后鼓捣了半天,终于安装成功了.想想其它安装驱动不是很困难,真正麻烦的是...

    newifi-d2-jail-break.ko

    某品牌路由器刷机不死启动必备工具,懒得四处找了,自已备用,newifi d2,简单3步: 1,打开SSH,... 2,下载newifi-d2-jail-break.ko到/tmp 3,insmod newifi-d2-jail-break.ko

    2410 led驱动

    使用方法二、作为动态模块进行编译 -------------------------------------------------------------------------------------- 在本实验目录下执行make命令编译生成led.o文件,通过FTP/TFTP 方式下载到开发板; 再...

    bmi160调通bmi160的ACC+GYR_20160907.7z

    全志R58的官方开发板加载bmi160驱动的步骤3B.txt 开发板:全志R58的官方开发板R58_PER3_LPDDR3_32X1_V1_1.pdf(板载加速度传感器bma250) 目标:外挂bmi160模块可以检测到加速度和角速度(acc+gyr/加速度传感器+...

    ov7725_r16_dev借用ov7736的驱动框架打开ov7725了20160719_1432.7z

    启动之后实际加载的摄像头的驱动模块(ov7725借用ov7736的驱动程序): shell@astar-evb20:/ # shell@astar-evb20:/ # lsmod gt82x 9849 0 - Live 0x00000000 bma250 7848 0 - Live 0x00000000 sunxi_schw 12559 0 ...

    r58_evb_sc5806v4加载TP成功修改config 20160815 2026.7z

    或者一次性解决问题(挨个文件使用相对路径链接好之后打包/有能力的同学可以使用脚本来完成) 设想2(未经验证):比对两个services4中的C文件,使用比对工具拷贝过来覆盖!!!! rootroot@rootroot-E400:~/...

    Busybox for Android v1.20.2

    Busybox for Android v1.20.2 Stable built by Linus Yang [Aug 12, 2012 Update] - Update to 1.20.2 stable [Features] - Tested on Android 2.1, 2.3, 4.0 and 4.1. Should be capable with all Android ...

    RTL8152-RTL8153驱动源码

    RTL8152-RTL8153驱动源码,下载解压,可编译进linux内核,生成.ko文件。使用insmod命令加载驱动。注意驱动之间的关联关系。

Global site tag (gtag.js) - Google Analytics