加载rt3070sta.ko出现insmod: can't insert 'rt3070sta.ko': invalid module format问题

[root@smsf /root]# insmod rt3070sta.ko
rt3070sta: unknown relocation: 40

insmod: can't insert 'rt3070sta.ko': invalid module format

我使用的是linux2.6.28-10版本的内核

编译器是 arm-none-linux-gnueabi-gcc-4.3.3

无论怎么改都是这样的问题,开始以为是内核配置不对,但是启动后会出现

usb 1-1: New USB device found, idVendor=148f, idProduct=3070
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: 802.11 n WLAN
usb 1-1: Manufacturer: Ralink
usb 1-1: SerialNumber: 1.0

已经认出USB设备了,为什么就是不行呢,后来又改了几个版本的root文件系统,还是不行

最后在网上查到一个帖子,如下


由于EABI-4.3.3的编译器比2.6.25.8的新,再编译连接程序时两者的有些参数不兼容,所以使用3.4.5的编译器编译2.6.25.8的内核和wifi驱动时不会有任何问题;而EABI-4.3.3的编译器编译2.6.25.8的wifi驱动时(主要是mac80211)要调用到include/asm-arm/elf.h文件中的参数,而2.6.25.8的内核中没有EABI要调用的参数。所以会出现“unknown relocation: 40”这个错误。
解决办法:
1、修改include/asm-arm/elf.h的32行,添加#define R_ARM_V4BX     40
2、修改arch/arm/kernel/module.c文件在134行添加
case R_ARM_V4BX:
     *(u32 *)loc &=0xf000000f;
       *(u32 *)loc |=0x01a0f000;
       break;


难怪呢,按指示修改elf.h,这个文件在2.6.28的内核里面是arch/arm/include/asm下的elf.h

添加#define R_ARM_V4BX     40


在arch/arm/kernel/module.c文件在134行添加

     case R_ARM_V4BX:
       *(u32 *)loc &=0xf000000f;
       *(u32 *)loc |=0x01a0f000;
       break;

再编译加载,大功告成,这个问题折腾了我好几天

[root@smsf /root]# insmod rt3070sta.ko
rtusb init rt2870 --->




=== pAd = c48ff000, size = 508632 ===


<-- RTMPAllocTxRxRingMemory, Status=0
<-- RTMPAllocAdapterBlock, Status=0
usbcore: registered new interface driver rt2870
[root@smsf /root]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 10:12:34:56:78:18
          inet addr:192.168.8.3  Bcast:192.168.8.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:39 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4538 (4.4 KiB)  TX bytes:0 (0.0 B)
          Interrupt:16 Base address:0xc300


lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


ra0       Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


[root@smsf /root]# iwconfig
-/bin/sh: iwconfig: not found
[root@smsf /root]# ifconfig ra0 192.168.8.25
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc]
RTMP_TimerListAdd: add timer obj c49468c8!
RTMP_TimerListAdd: add timer obj c49468f4!
RTMP_TimerListAdd: add timer obj c4946920!
RTMP_TimerListAdd: add timer obj c494689c!
RTMP_TimerListAdd: add timer obj c4946818!
RTMP_TimerListAdd: add timer obj c4946844!
RTMP_TimerListAdd: add timer obj c491145c!
RTMP_TimerListAdd: add timer obj c4900c70!
RTMP_TimerListAdd: add timer obj c4900ca4!
RTMP_TimerListAdd: add timer obj c49114f4!
RTMP_TimerListAdd: add timer obj c4911404!
RTMP_TimerListAdd: add timer obj c49114c4!
-->RTUSBVenderReset
<--RTUSBVenderReset
Key1Str is Invalid key length(0) or Type(0)
Key2Str is Invalid key length(0) or Type(0)
Key3Str is Invalid key length(0) or Type(0)
Key4Str is Invalid key length(0) or Type(0)
1. Phy Mode = 5
2. Phy Mode = 5
NVM is Efuse and its size =2d[2d0-2fc]
phy mode> Error! The chip does not support 5G band 5!
RTMPSetPhyMode: channel is out of range, use first channel=1
(Efuse for 3062/3562/3572) Size=0x2d [2d0-2fc]
3. Phy Mode = 9
AntCfgInit: primary/secondary ant 0/1
MCS Set = ff 00 00 00 01
<==== rt28xx_init, Status=0
0x1300 = 00064300



你可能感兴趣的:(LINUX设备驱动)