分类: LINUX
2011-02-03 11:54:42
VNT6656无线网卡移植
[A] 2.6.32.2内核下的移植
这里是友善之臂提供的2.6.32.2内核 + VNT6656 WLAN源代码 1.20.03的编译和使用方法:
1.编译驱动模块
目前1.20.03版本的驱动源代码可以对2.6.32.2内核直接编译成功,无需修改。
1.a 从 下载VNT6656驱动源代码并解压缩.(在Linux下你需要安装"unrar");
1.b 进入VT6656_linux_src_v1.20.03_x86/driver目录,执行
#make -C /path/to/source/of/linux-2.6.32.2 M=`pwd` modules
//上边的内核目录根据实际调整!
编译成功后,最终将生成驱动内核模块vntwusb.ko
2.使用驱动模块
2.a 将vntwusb.ko下载至开发板上;
2.b 将VNT6656 USB无线网卡插入开发板的USB Host端口;
2.c 加载vntwusb.ko驱动模块
#insmod /path/to/vntwusb.ko //左边的驱动模块的目录根据实际调整!
2.d 可以看到无线网卡被识别:
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: New USB device found, idVendor=160a, idProduct=3184
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: VNT USB-802.11 Wireless LAN Adapter
usb 1-1: Manufacturer: VIA Networking Technologies, Inc.
usb 1-1: configuration #1 chosen from 1 choice
VIA Networking Wireless LAN USB Driver Ver. 1.20.03
VIA Networking Wireless LAN USB Driver Ver. 1.20.03
Copyright (c) 2004 VIA Networking Technologies, Inc.
usb 1-1: reset full speed USB device using s3c2410-ohci and address 3
usbcore: registered new interface driver vntwusb
2.e 无线网卡对于的网络设备接口通常是eth1或wlan0(eth0是开发板上的DM9000A网卡),用ifconfig命令将其设为UP状态:
#ifconfig eth1 up
可以用ifconfig和iwconfig看到其状态
[root@FriendlyARM plg]# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:12:7B:43:1C:21
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:403 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:18538 (18.1 KiB)
[root@FriendlyARM plg]# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
eth1 802.11-a/b/g ESSID:""
Mode:Managed Frequency=2.437 GHz Access Point: Not-Associated
Bit Rate:1 Mb/s Sensitivity=0/255
Retry min limit:8 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
vntwpa no wireless extensions.
3.配置无线网卡
要正常使用无线网卡,还要正确配置。linux下的配置工具是wireless-tools。有个很好用的配置工具(wireless tool),可以方便配置无线网卡。
3.a 下载wire-tool工具
下载地址是: (在下方找)。
3.a 编译工具
下载后,将源代码解压。再修改其中的Makefile文件,将其中的CC、AR和RANLIB进行修改:
#vi Makefile
CC = gcc
AR = ar
RANLIB = ranlib
改为
CC = arm-linux-gcc
AR = arm-linux-ar
RANLIB = arm-linux-ranlib
再执行
#make
3.b 下载wire-tool到开发板
编译完成后,将生成的iwconfig,iwlist文件拷贝到mini2440的根文件系统中的/bin目录下,将libiw.so.29拷贝到mini2440根文件系统下的/lib目录下。
3.c 启动无线网卡
启动mini2440开发板,进入linux命令行后,执行:
#ifconfig eth1 up //也可能是wlan0
3.d 搜索无线网路
启动无线网卡。再执行
#iwlist scanning
此命令可以搜索到可用的无线网络接入点。我搜索到的如下:
eth1 Scan completed :
Cell 01 - Address: 00:0A:EB:D4:D4:B6
ESSID:"TP-LINK" //无线连接名称
Mode:Managed
Channel:6
Frequency:2.437 GHz (Channel 6)
Quality=20/100 Signal level=-82 dBm Noise level=0 dBm
Encryption key:off //是否需要密码,如是on就需要密码
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
12 Mb/s; 24 Mb/s; 36 Mb/s; 9 Mb/s; 18 Mb/s
48 Mb/s; 54 Mb/s //速度支持
Extra:bcn_int=100
我的无线路由器ESSID是"TP-LINK",执行此命令后就会下列输出:
3.e设置联网密码:
#iwconfig wlan0 key 123456 //如果没密码就无需执行
3.f 设置ESSID
用如下命令设置要连接的ESSID
#iwconfig wlan0 essid "TP-LINK" //根据需要修改ESSID
3.g 加入无线网络
#iwconfig eth1 ap auto
3.h 查看连接状态
# iwconfig eth1
我的输出如下结果
eth1 802.11-a/b/g ESSID:"TP-LINK"
Mode:Managed Frequency=2.437 GHz Access Point: 00:0A:EB:D4:D4:B6
Bit Rate=5.5 Mb/s Sensitivity=-78 dBm
Retry min limit:8 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=70/100 Signal level:-78 dBm Noise level:0 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:95 Invalid misc:0 Missed beacon:0
3.i 为无线网卡设置IP地址
#ifconfig eth1 192.168.1.130 netmask 255.255.255.0
3.j 测试网络是否连通
#ping 192.168.1.1
我的返回如下结果,可见无线网已经连通,而且很稳定。但我发现无线网卡很热,也许是网卡不好吧。
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: seq=0 ttl=64 time=21.447 ms
64 bytes from 192.168.1.1: seq=1 ttl=64 time=3.166 ms
64 bytes from 192.168.1.1: seq=2 ttl=64 time=3.180 ms
64 bytes from 192.168.1.1: seq=3 ttl=64 time=3.300 ms
^C
--- 192.168.1.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 3.166/7.773/21.447 ms
3.k 无线联网的自动化
为了确保开发板系统启动无线网络就联通,可以建立一个脚本文件/etc/wireless.sh,内容如下:
#!/bin/sh
echo "Install wireless model ….."
insmod /lib/modules/vntwusb.ko #要提前将无线网模块文件复制好
ifconfig eth1 up
echo "wireless up ….."
#iwconfig eth1 key 123456 #根据需要设置
iwconfig eth1 essid "TP-LINK" #根据需要
iwconfig eth1 ap auto
ifconfig eth1 192.168.1.130 netmask 255.255.255.0
echo "wireless Linked ….."
注意修改其权限使之可以执行。
[B] 基于Linux2.6.37内核的移植
================2.6.37========内核移植================================
1. 在drivers/main_usb.c中加入头文件(139行附近)
//============syd168===================
#include
//=====================================
2. 替换如下代码,注释掉的被替换为黄色背景的(2067行附近):
static void device_set_multi(struct net_device *dev) {
PSDevice pDevice = (PSDevice)VNT_NETDEV_GET_PRIV(dev);
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
u32 mc_filter[2];
int ii;
//==================syd168===========
// struct dev_mc_list *mclist;
struct netdev_hw_addr *ha;
//=================================
3. 替换如下代码,注释掉的被替换为黄色背景的(2088行附近):
if (dev->flags & IFF_PROMISC) { // Set promiscuous.
DBG_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
// Unconditionally log net taps.
pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
}
//==================syd168======================
// else if ((dev->mc_count > pDevice->multicast_limit) || (dev->flags & IFF_ALLMULTI)) {
else if ((netdev_mc_count(dev) > pDevice->multicast_limit) || (dev->flags & IFF_ALLMULTI)) {
//===============================
4. 注释掉如下代码(灰色背景部分),替换为黄色背景部分(2121行附近):
CONTROLnsRequestOut(pDevice,
MESSAGE_TYPE_WRITE,
MAC_REG_MAR0,
MESSAGE_REQUEST_MACREG,
8,
pbyData
);
pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
}
else {
memset(mc_filter, 0, sizeof(mc_filter));
//===============syd168==============================
/*
for (ii = 0, mclist = dev->mc_list; mclist && ii < dev->mc_count;
ii++, mclist = mclist->next) {
int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
}
*/
netdev_for_each_mc_addr(ha, dev) {
int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
}
//===================================================
其余的操作过程和2.6.32.2一样。
chinaunix网友2011-04-06 11:35:58
拜读过 您的 <