Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2764638
  • 博文数量: 505
  • 博客积分: 1552
  • 博客等级: 上尉
  • 技术积分: 2514
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-23 18:24
文章分类

全部博文(505)

文章存档

2019年(12)

2018年(15)

2017年(1)

2016年(17)

2015年(14)

2014年(93)

2013年(233)

2012年(108)

2011年(1)

2009年(11)

分类: LINUX

2015-01-24 12:47:30

一、交叉编译rt3070驱动

1.下载rt3070驱动

2.解压:

tar xvf /share/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO.tar

3.修改makefile

12行,修改为CHIPSET = 3070

修改 PLATFORM = DM6446,并注释掉#PLATFORM = PC

修改内核所在目录:

258 ifeq ($(PLATFORM),DM6446)

259 LINUX_SRC = /workdir/kernel.2.6.34

260 endif

4.修改os/linux/config.mk

764 ifeq ($(PLATFORM),DM6446)

765         EXTRA_CFLAGS := -nostdinc -iwithprefix include -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include  -Wall -Wstrict-protot    ypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Os -fno-omit-frame-pointer -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mlittl    e-endian  -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm9tdmi -msoft-float -Uarm -Wdeclaration-after-statement -c -o $(WFLAGS)

766 export EXTRA_CFLAGS

767 endif

修改了两个地方:

修改一:将CFLAGS修改为EXTRA_CFLAGS,否则报如下错误

make[1]: 正在进入目录 `/opt/workdir/kernel.2.6.34'

scripts/Makefile.build:49: *** CFLAGS was changed in "/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/Makefile". Fix it to use EXTRA_CFLAGS。 停止。

make[1]: *** [_module_/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux] 错误 2

make[1]:正在离开目录 `/opt/workdir/kernel.2.6.34'

make: *** [LINUX] 错误2

修改原因,按照编译出错提示Fix it to use EXTRA_CFLAGS,原因还不清楚。

修改二:

去掉编译选项中的mabi=apcs-gnu参数

原因:apcs-gnuOABI的参数,因此将OABI的参数传给符合 EABI标准的编译,编译阶段没有报错,但在板上运行时,程序中涉及到浮点数的部分出现了许多莫名的问题。

在我们的板子上出现如下错误:

# insmod rt3070sta.ko 

rtusb init rt2870 --->

Unable to handle kernel NULL pointer dereference at virtual address 00000028

pgd = c47c4000

[00000028] *pgd=84779031, *pte=00000000, *ppte=00000000

Internal error: Oops: 17 [#1] PREEMPT

last sysfs file: /sys/devices/platform/musb_hdrc/usb1/1-1/1-1:1.0/uevent

Modules linked in: rt3070sta(+) edmak irqk cmemk

CPU: 0    Not tainted  (2.6.34_ldrsc-svn1086 #53)

PC is at kref_get+0x10/0x50

LR is at kobject_get+0x20/0x28

pc : []    lr : []    psr: 20000013

sp : c4147d10  ip : c4147d28  fp : c4147d24

r10: c0037be0  r9 : 00000000  r8 : bf0ab82c

r7 : bf0abe38  r6 : bf0a9558  r5 : c0037be0  r4 : 0000000c

r3 : 00000001  r2 : 00003070  r1 : bf0ab82c  r0 : 00000028

Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user

Control: 0005317f  Table: 847c4000  DAC: 00000015

Process insmod (pid: 536, stack limit = 0xc4146270)

Stack: (0xc4147d10 to 0xc4148000)

7d00:                                     00000017 0000000c c4147d3c c4147d28

7d20: c0197148 c0197f2c c4146000 ffffff9c c4147d4c c4147d40 c01e3e00 c0197138

7d40: c4147d64 c4147d50 c0221918 c01e3df4 c4147d7c c0037c00 c4147e14 c4147d68

7d60: bf081a44 c0221908 c4147d94 c4147d78 c035e234 c0078578 c00fa838 00000000

7d80: c466ff08 c4147de0 c4147da4 c4147d98 c035e2a0 c035e184 c4147ddc c4147da8

7da0: c00fb354 c035e2a0 c466ff08 c4147de0 c4147ddc c4147dc0 c00fab84 00000000

7dc0: c466ff08 c4147de0 c46f2728 00000001 c4147dfc c4147de0 c022acb4 c022abb8

7de0: c4147dfc bf0ab82c c0037be0 c0037c00 c0037be0 c415a000 bf0abe38 bf0ab82c

7e00: 00000000 00000000 c4147e3c c4147e18 c022b804 bf081a30 c0037c00 c0037c34

7e20: bf0abe38 bf0abe38 c04953a8 00000000 c4147e5c c4147e40 c01e73a4 c022b73c

7e40: c0037c00 c0037c34 bf0abe38 bf0abe38 c4147e7c c4147e60 c01e7650 c01e7304

7e60: c4147e7c 00000000 c4147e80 c01e75e4 c4147ea4 c4147e80 c01e6660 c01e75f4

7e80: c4097d58 c4160210 bf0abe08 bf0abe38 c4160360 bf0a49e4 c4147eb4 c4147ea8

7ea0: c01e7200 c01e6618 c4147ee4 c4147eb8 c01e6d9c c01e71f0 bf0a49dc bf0abe08

7ec0: bf0abe08 bf0abe38 bf0abe38 bf0a49e4 c04a9380 bf0c2000 c4147f0c c4147ee8

7ee0: c01e78ec c01e6d04 bf0abe08 bf0abfc4 bf0abe38 bf0a49e4 c04a9380 bf0c2000

7f00: c4147f2c c4147f10 c022b2a4 c01e784c 00000000 bf0abfc4 00000000 401f6008

7f20: c4147f3c c4147f30 bf0c2028 c022b248 c4147f7c c4147f40 c003f3d4 bf0c2010

7f40: c4147f6c 000c5387 bf0abfc4 00000000 401f6008 00000000 bf0abfc4 00000000

7f60: 401f6008 c0040064 c4146000 00000000 c4147fa4 c4147f80 c0081414 c003f388

7f80: ffffffff 401f6008 00000000 becadc98 00000000 00000080 00000000 c4147fa8

7fa0: c003fee0 c008135c 00000000 becadc98 401f6008 000c5387 000c3764 00000000

7fc0: 00000000 becadc98 00000000 00000080 becadc98 000c3764 00000000 00000002

7fe0: 00000069 becad7bc 00020268 40192c24 60000010 401f6008 ebfffc7b e1a04000

Backtrace: 

[] (kref_get+0x0/0x50) from [] (kobject_get+0x20/0x28)

 r4:0000000c

[] (kobject_get+0x0/0x28) from [] (get_device+0x1c/0x24)

 r4:ffffff9c

[] (get_device+0x0/0x24) from [] (usb_get_dev+0x20/0x28)

[] (usb_get_dev+0x0/0x28) from [] (rtusb_probe+0x24/0x320 [rt3070sta])

 r4:c0037c00

[] (rtusb_probe+0x0/0x320 [rt3070sta]) from [] (usb_probe_interface+0xd8/0x118)

[] (usb_probe_interface+0x0/0x118) from [] (driver_probe_device+0xb0/0x164)

[] (driver_probe_device+0x0/0x164) from [] (__driver_attach+0x6c/0x90)

 r7:bf0abe38 r6:bf0abe38 r5:c0037c34 r4:c0037c00

[] (__driver_attach+0x0/0x90) from [] (bus_for_each_dev+0x58/0x8c)

 r6:c01e75e4 r5:c4147e80 r4:00000000

[] (bus_for_each_dev+0x0/0x8c) from [] (driver_attach+0x20/0x28)

 r7:bf0a49e4 r6:c4160360 r5:bf0abe38 r4:bf0abe08

[] (driver_attach+0x0/0x28) from [] (bus_add_driver+0xa8/0x238)

[] (bus_add_driver+0x0/0x238) from [] (driver_register+0xb0/0x13c)

[] (driver_register+0x0/0x13c) from [] (usb_register_driver+0x6c/0x130)

[] (usb_register_driver+0x0/0x130) from [] (init_module+0x28/0x40 [rt3070sta])

 r7:401f6008 r6:00000000 r5:bf0abfc4 r4:00000000

[] (init_module+0x0/0x40 [rt3070sta]) from [] (do_one_initcall+0x5c/0x19c)

[] (do_one_initcall+0x0/0x19c) from [] (sys_init_module+0xc8/0x1f8)

[] (sys_init_module+0x0/0x1f8) from [] (ret_fast_syscall+0x0/0x2c)

 r7:00000080 r6:00000000 r5:becadc98 r4:00000000

Code: e1a0c00d e92dd810 e24cb004 e24dd004 (e5903000) 

---[ end trace fb9efbb0b83ac13c ]---

Segmentation fault

这个错误很难发现

5.修改os/linux/usb_main_dev.c

加入: MODULE_LICENSE("GPL");

否则在加载驱动时出现如下错误:

# insmod rt3070sta.ko 

rt3070sta: module license 'unspecified' taints kernel.

Disabling lock debugging due to kernel taint

rt3070sta: Unknown symbol usb_alloc_urb

rt3070sta: Unknown symbol usb_free_urb

rt3070sta: Unknown symbol usb_alloc_coherent

rt3070sta: Unknown symbol usb_register_driver

rt3070sta: Unknown symbol usb_put_dev

rt3070sta: Unknown symbol usb_get_dev

rt3070sta: Unknown symbol usb_submit_urb

rt3070sta: Unknown symbol usb_free_coherent

rt3070sta: Unknown symbol usb_control_msg

rt3070sta: Unknown symbol usb_deregister

rt3070sta: Unknown symbol usb_kill_urb

insmod: can't insert 'rt3070sta.ko': unknown symbol in module or invalid parameter

6.修改chips/rtmp_chip.c

 464 #ifdef RT30xx

 465 

 466 

 467         if (IS_RT30xx(pAd))

 468         {

 469                 if (IS_RT3390(pAd))

 470 //                        RT33xx_Init(pAd);

 471                         ;

 472                 else

 473                         RT30xx_Init(pAd);

 474         }

 475 #endif /* RT30xx */

否则编译汇编RT33xx_Init未定义的错误

7.修改os/linux/sta_ioctl.c

2227 #ifdef CONFIG_WEXT_PRIV

2228         .private        = (iw_handler *) rt_priv_handlers,

2229         .num_private            = N(rt_priv_handlers),

2230         .private_args   = (struct iw_priv_args *) privtab,

2231         .num_private_args       = N(privtab),

2232 #endif

否则会报如下错误

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2227: 错误:初始值设定项里有未知的字段‘private

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2227: 警告:从不兼容的指针类型初始化

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2228: 错误:初始值设定项里有未知的字段‘num_private

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2228: 警告:结构初始值设定项中有多余元素

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2228: 警告:(在‘rt28xx_iw_handler_def’的初始化附近)

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2229: 错误:初始值设定项里有未知的字段‘private_args

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2229: 警告:结构初始值设定项中有多余元素

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2229: 警告:(在‘rt28xx_iw_handler_def’的初始化附近)

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2230: 错误:初始值设定项里有未知的字段‘num_private_args

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2230: 警告:结构初始值设定项中有多余元素

/opt/workdir/2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/os/linux/../../os/linux/sta_ioctl.c:2230: 警告:(在‘rt28x

8、拷贝RT2870STA.dat/etc/Wireless/RT2870STA/

二、交叉编译wireless_tools

1下载wireless_tools.29.tar.bz2

解压

#tar xvfj wireless_tools.29.tar.bz2

#cd wireless_tools.29

3 Makefile修改

CC= arm_v5t_le-gcc1.4 复制文件到产品板

4.拷贝libiw.so.29文件到目标系统/usr/lib/

拷贝用到的几个程序到产品板就可以了

iwpriviwconfigiwlist, iwevent, iwspy

三、开发板中

1.插入rt3070

2.加载驱动驱动模块:insmod rt3070sta.ko

3.ifconfig ra0 192.168.3.252 netmask 255.255.0.0

iwlist scanning

lo        Interfnet eth0: DaVinci EMAC: ioctl not supported

ace doesn't support scanning.

eth0      Interface doesn't support scanning.

===>rt_ioctl_giwscan. 10(10) BSS returned, data->length = 1209

ra0       Scan completed :

          Cell 01 - Address: 00:14:78:BA:86:04

                    Protocol:802.11b/g

                    ESSID:"123"

                    Mode:Managed

                    Frequency:2.437 GHz (Channel 6)

                    Quality=100/100  Signal level=-35 dBm  Noise level=-92 dBm

                    Encryption key:off

                    Bit Rates:54 Mb/s

          Cell 02 - Address: 00:22:6B:3F:AC:E1

                    Protocol:802.11b/g

                    ESSID:"yanfa"

                    Mode:Managed

                    Frequency:2.437 GHz (Channel 6)

                    Quality=37/100  Signal level=-75 dBm  Noise level=-70 dBm

                    Encryption key:off

                    Bit Rates:54 Mb/s

          Cell 03 - Address: E2:F8:DA:3C:BF:FA

                    Protocol:802.11b/g/n

                    ESSID:"frank's"

                    Mode:Managed

                    Frequency:2.462 GHz (Channel 11)

                    Quality=100/100  Signal level=-39 dBm  Noise level=-92 dBm

                    Encryption key:on

                    Bit Rates:54 Mb/s

                    IE: IEEE 802.11i/WPA2 Version 1

                        Group Cipher : CCMP

                        Pairwise Ciphers (1) : CCMP

                        Authentication Suites (1) : PSK

iwconfig ra0 essid "123"

# iwconfig

lo        no wirnet eth0: DaVinci EMAC: ioctl not supported

eless extensions.

eth0      no wireless extensions.

ra0       Ralink STA  ESSID:"123"  Nickname:"RT2870STA"

          Mode:Managed  Frequency=2.437 GHz  Access Point: 00:14:78:BA:86:04   

          Bit Rate=54 Mb/s   

          RTS thr:off   Fragment thr:off

          Encryption key:off

          Link Quality=100/100  Signal level:-34 dBm  Noise level:-66 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

ifconfig eth0 down

# ping 192.168.4.222  注:192.168.4.222为无线路由ip

PING 192.168.4.222 (192.168.4.222): 56 data bytes

64 bytes from 192.168.4.222: seq=0 ttl=64 time=8.548 ms

64 bytes from 192.168.4.222: seq=1 ttl=64 time=1.978 ms

64 bytes from 192.168.4.222: seq=2 ttl=64 time=1.993 ms
阅读(2114) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~