基於arm/Linux平臺USB無線網卡的wifi驅動移植

基於arm/Linux平臺USB無線網卡的wifi驅動移植

這是同學在用的板子,arm平臺是三星2440Linux內核是2.6.24,威盛VNT6656USB無線網卡;開發平臺是Fedora10,內核是2.6.27。遭遇的問題主要有如下幾個:

一、驅動程序的版本不對

開始在網上找了個VNT6656Linux驅動程序,直接先在本地機器上編譯。結果錯誤太多太多,改了一批還有一大批,主要問題是很多的“結構體”不對,而且開始還得把CFLAGS全部換成EXTRA_CFLAGS。最終才反應過來,可能下的驅動程序版本有問題。到www.viaarena.com下載最新的驅動:http://www.viaarena.com/Driver/VT6656_Linux_src_v1.19_12_x86.zip 。之前的驅動是1.13版本的。根本的問題在於,沒有認真讀驅動說明文檔,開始的版本根本不支持fedora10

那麼,到底兩個驅動有什麼不同呢?原因在於,在Linux2.6.24以後的內核中,網絡部分有了改動,而且是網絡部分很重要的結構體被改動了,第一個驅動肯定是基於2.6.24之前的內核。比如,struct sk_buff,在這裏可以看到具體的不同點,文中提到的《Professional Linux Kernel Architecture》可以網上下一下,確實不錯,內容包含2.6.24以後比較新的內容。

二、編譯驅動模塊

驅動程序是是要編譯成模塊的,直接make就是編譯本地機器上的驅動,很順利,生成的vntwusb.ko可以在本地機器上加載成功,使用正常,竊喜。接 下來把Makefie裏面的CCLD等交叉編譯工具變量設爲arm-linux-gccarm-linux-ld。繼續make,又出錯了,具體錯誤 忘了。正確的方法是,make -C $(KERNEL_DIR) M=$(MODULE_DIR) ,-C指名內核所在文件夾,不寫就按照默認的。默認的是本地機器上的內核,本人所在機器默認內核是/usr/src/kernels /2.6.27.5-117.fc10.i686,這樣肯定不行。M指名要編譯模塊所在的路徑。實際命令是

make -C /media/Study/temp/utu-Linux2.6.24_for_utu2440_2009-03-15 M=/media/Study/temp/VT6656_Linux_src_v1.19_12_x86/driver

繼續編譯,依然有錯,因爲Makefile還沒改好。把Makefile裏的KSRC變量直接賦值KSRC=/media/Study/temp /utu-Linux2.6.24_for_utu2440_2009-03-15,Makefile裏面還有KSP等搗亂的變量,直接都刪掉即可。 make 時候還要新增加一個選項,

KSRC=/media/Study/temp/utu-Linux2.6.24_for_utu2440_2009-03-15

,不加好像不行,鬱悶。。。繼續編譯,會在ioctl.c line:298 出現段錯誤segmentation fault,把這一行註釋掉

// pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;

這樣就可以得到我們需要的vntwusb.ko。不解的是,在按照本地機器的內核編譯就沒有任何問題。

三、還要編譯內核

有了驅動模塊,在板子上加載時出現“Unknown symbol in module”的錯誤。原來板子預裝的內核是不帶wifi也即802.11模塊的。回想下,在編譯結束時也打印了一個警告信息,說是wireless send event 沒註冊之類的。。重新編譯內核時可以直接找到板子默認配置文件,把裏面wireless部分改一下,並改文件名爲.config作爲默認配置.make menuconfig當然也可以。改動如下:

#
# Wireless
#
CONFIG_CFG80211=y
CONFIG_NL80211=y
CONFIG_WIRELESS_EXT=y
CONFIG_IEEE80211=y
# CONFIG_IEEE80211_DEBUG is not set
CONFIG_IEEE80211_CRYPT_WEP=y
# CONFIG_IEEE80211_CRYPT_CCMP is not set
# CONFIG_IEEE80211_CRYPT_TKIP is not set
# CONFIG_RFKILL is not set

內核編譯好了,下載到板子裏去就好了。。

四、如何在板子上使用無線網卡呢?

前提,USB Host驅動需要已經安裝好了。加載vntw6656.ko模塊成功之後,要使用無線網卡還需把驅動程序包裏的wetctl工具編譯一下,修改 Makefile直接make就行,編譯好了考到板子的/sbin/裏。另外程序包裏還有個腳本文件,使用時可以根據需要改動。 DESIRED_SSID=“TestAP”是新建的無線連接名字,BSSTYPEadhoc,建立點對點的adhoc網絡,可以讓其他網絡尋找到。加入附件的網絡,把
/sbin/wetctl $DEVICE join /
infra/   #BSSTYPE
類型
ChianNet / #想要連接的無線網絡名稱
11 /
channel
$PSMODE /
$AUTHTYPE

幾個選項改掉就行。也可以直接用wetctl幾個命令

wetctl eth1 scanlink list join等]

ifconfig 兩個個命令

ifconfig eth1 192.168.1.110

ifconfig eth1 up

總結:Linux 移植真累。。。

 

 

 

 

 

 

 

 

 

 

 

 


移植wifi無線網卡到mini2440上全過程【轉】

http://www.arm9home.com/bbs/read.php?tid-1305-fpage-2.html

正在實驗,先轉載,以避免丟失

 

前段時間移植了U-bootlinux2.6.27.9mini2440上,最近有點空,手頭有一個usb接口的zd1211b芯片的wifi無線網卡(PSPNDSL玩家都知道的神卡),於是決定在內核中加入此無線網卡的驅動。我是在我移植的linux2.6.27.9內核上移植的。關於內核移植,請看我的這篇文章。http://blog.chinaunix.net/u2/75270/showart.php?id=1796658

新版的linux2.6.27.9已自帶zd1211b的驅動。此驅動在rat-linux-2.6.27.9/drivers/net/wireless/zd1211rw/中。
要讓此驅動生效,得修改內核配置。
選中
networking support-->wireless-->Generic IEEE 802.11 Networking Stack (mac80211)
選中
device drivers-->netword device support-->wirelss lan-->ZyDAS ZD1211/ZD1211B USB-wireless support
重新編譯內核。下載到板子中,重啓。加入無線網卡。出現
usb 1-1: USB disconnect, address 2
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: reset full speed USB device using s3c2410-ohci and address 3
zd1211rw 1-1:1.0: phy1
表示無線網卡已被識別。使用cat /proc/net/wireless 命令,可以查看到系統中多了個wlan0網卡。此時,網卡還沒工作。使用命
ifconfig wlan0 up則出現firmware:requesting zd1211,然後沒反應了,這是因爲沒有firmware的原因,從這裏
http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2?modtime=1191498990&big_mirror=0
下載到zd1211 firmware 1.4後,根據firmware的說明,將其中的zd1211_*文件拷貝到根文件系統/lib/firmware/zd1211目錄中。這
裏再執行ifconfig wlan0 up命令,則出現
firmware: requesting zd1211/zd1211b_ub
firmware: requesting zd1211/zd1211b_uphr
zd1211rw 1-1:1.0: firmware version 4725
zd1211rw 1-1:1.0: zd1211b chip 0ace:1215 v4810 full 00-02-72 AL2230_RF pa0 g--N
網卡硬件開始正常工作了。其中,0ace:1215是網卡的ID,可以用主機linux系統命令lsusb查看到。
但此時,網卡還沒被正確配置,還不能正常使用。
要正常使用無線網卡,還要正確配置。linux下的配置工具是wireless-tools,可以在這裏下載到它的最新版。
http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html
下載後,將源代碼解壓。再修改其中的makefile文件,將其中的
CC = gcc
AR = ar
RANLIB = ranlib
改爲
CC = arm-linux-gcc
AR = arm-linux-ar
RANLIB = arm-linux-ranlib
再執行make,編譯完成後,將生成的iwconfigiwlist文件拷貝到rat-linux for mini2440的根文件系統中的/bin目錄下,將
libiw.so.29
拷貝到/lib目錄下。
啓動mini2440開發板,進入linux命令行後,執行ifconfig wlan0 up,啓動無線網卡。再執行iwlist scanning,此命令可以搜索到
可用的無線網絡接入點。我的無線接入點是一臺無線路由器,ESSID"rat-linux",執行此命令後就會下列輸出
wlan0     Scan completed :
          Cell 01 - Address: 00:19:C6:53:B9:CE
                    ESSID:"rat-linux"
                    Mode:Master
                    Channel:2
                    Frequency:2.417 GHz (Channel 2)
                    Quality=11/100  Signal level:66/100
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s
                    Extra:tsf=000000056306469f
                    Extra: Last beacon: 1065ms ago

其中可以看到我的無線接入點是需要密碼的。假設密碼是123456。使用如下的命令設置密碼。
  iwconfig wlan0 key 123456
爲了能接無線網,還要使用下面的命令設置ESSID
  iwconfig wlan0 essid "rat-linux"
其它的參數可以都採用默認的,不用再設了。可以使用下面的命令加入無線網了。
  
  iwconfig wlan0 ap auto
再執行iwconfig wlan0,就可以看到下面的信息。
wlan0     IEEE 802.11bg  ESSID:"rat-linux"
          Mode:Managed  Frequency:2.417 GHz  Access Point: 00:19:C6:53:B9:CE
          Bit Rate=1 Mb/s   Tx-Power=27 dBm
          Retry min limit:7   RTS thr:off   Fragment thr=2352 B
          Encryption key:1234-56   Security mode:open
          Power Management:off
          Link Quality=100/100  Signal level:66/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
這就表示已接入無線網。
最後,爲無線網卡指定IP地址。命令如下
  ifconfig wlan0 192.168.1.30 netmask 255.255.255.0
我的開發主機和無線網卡處於同一網段,因此是可以相互PING通的。因此可以用從開發主機上PING無線網卡的IP地址的方法來確網
卡是否工作正常。從主機上執行ping 192.168.1.30,正常PING通。
至此,無線網卡安裝全部完成。
最後,爲了方便配置,可以將上述的配置命令寫入linux腳本文件,以後,只要執行此腳本,即可完成上述步驟的配置。腳本文件內
容如下。
#! /bin/sh
ifconfig wlan0 up
iwconfig wlan0 key 123456
iwconfig wlan0 essid "rat-linux"
iwconfig wlan0 ap auto
ifconfig wlan0 192.168.1.30 netmask 255.255.255.0

 原文地址 http://www.arm9home.com/bbs/read.php?tid-1305-fpage-2.html

 

 

 

 

 

 

 

 

轉貼:無線網卡驅動RT73的移植

2009-06-15 22:52

1.下載最新版的RT73無線網卡驅動:
# wget http://rt2x00.serialmonkey.com/rt73-cvs-daily.tar.gz
解壓:# tar zxvf rt73-cvs-daily.tar.gz

2.在內核中創建新文件夾drivers/usb/net/rt73
# mkdir drivers/usb/net/rt73
將解壓出來的文件夾Module下的文件拷貝到剛纔新建的rt73文件夾中:
# cp rt73-(time)/Module/* /home/oem/trunk/cirrus-1-0-0-4/linux-2.6.8.1/drivers/usb/net/rt73

 

3.修改Qwerk板內核源代碼,加入RT73驅動的配置信息,以使在make menuconfig 中能添加RT73驅動的選項。

?修改drivers/usb/net/Kconfig文件,加入RT73的驅動模塊的配置項:
# gedit drivers/usb/net/Kconfig &
加入以下內容:
config RT73
tristate “support for rt73 wireless usb device”
depends on USB && NET && USB_USBNET

?修改drivers/usb/net/Makefile, 加入rt73的編譯項:
# gedit drivers/usb/net/Makefile &
添加一下內容:
obj-$(CONFIG_RT73)+= rt73/

4.修改RT73Makefile,設置內核位置和編譯選項:

?刪除以前的modules選項,並將arm編譯項改成modules,這樣編譯的時候纔是for ARM版本的驅動模塊;

?修改KERNDIRQwerk內核位置:
KERNDIR=/home/oem/trunk/cirrus-1-0-0-4/linux-2.6.8.1

5.配置內核:

?Qwerk默認配置拷貝到內核根目錄下:
# cp ../edb9302/linux.config .config

?make menuconfig界面配置編譯選項,選上RT73無線網卡編譯選項:
USB devices à network à support for rt73 wireless usb device,按空格鍵選爲M,將其編譯成模塊。

6.編譯內核模塊:
# make modules
成功編譯後,會在drivers/usb/net/rt73目錄下生成rt73.ko驅動文件,將其拷貝到FTP目錄下,以便於下載到Qwerk板上:
# cp drivers/usb/net/rt73/rt73.ko /home/ftp/

7.下載rt73驅動到Qwerk上,並修改一些腳本文件使其開機加載驅動並啓用網卡:
假設Qwerk板已經可以啓動起來(燒寫系統可以參考QwerkDevelopmentGuide),啓動Qwerk板,從minicom命令行操作:
# cd /opt/driver/
# wget ftp://192.168.1.201/rt73.ko
編寫開機加載rt73.ko驅動、啓用網卡腳本,將其放入/opt/scripts/目錄下:
# cd ../scripts/
# vi wifi-up
加入如下內容:
(去公司後Copy到這兒)
修改/opt/scripts/robot.init腳本文件,在最後添加wifi-up腳本:
# vi robot.init
加入:
/opt/scripts/wifi-up
保存推出。

8.至此爲止,無線網卡驅動移植和配置工作已經完成,重啓Qwerk,無線網卡就能工作了。

說明:

1.如果按照modules編譯的rt73.ko不能工作的話,可以選用armdebug編譯。

附一個老外的指導:

put the contents of the Module directory into my arm 2.6.15 kernel tree under drivers/usb/net/rt73, then did the following to make it part of the kernel build:
- I added to the /drivers/usb/net/Kconfig to add an option to enable the rt73 module,
- Then edited the Makefile in /drivers/usb/net to have it build the subdir rt73 when the option above is active.
Then I ran the kernel menuconfig to actually enable that option.

Finally I edited the Makefile for the rt73 driver itself:
- put the right paths in KERNEL_SOURCE and MODULE_ROOT
- removed the calls to /sbin/depmod since we're not on the target system
- deleted the module and debug rules
- renamed arm rule to module and armdebug rule to debug

At this point doing make modules && make modules_install from the kernel root did the trick.
I'm not sure if this will be enough on your system. It worked for me.

 

 

 

 

 

 

USB無線網卡驅動RT73的移植

 

來源: ChinaUnix博客  日期: 2009.03.26 14:52 (共有0條評論) 我要評論

 

1.RT73無線網卡驅動:
http://www.ralinktech.com.tw/data/drivers/2009_0206_RT73_Linux_STA_Drv1.1.0.2.tar.bz2

2.
解壓
# tar -xvzf  
2009_0206_RT73_Linux_STA_Drv1.1.0.2.tar.bz2

# cd 2009_2006_RT73_Linux_STA_Drv_1.1.0.2/Module
# cp Makefile.6  ./Makefile
3.
編輯
Makefile
######################################################################
# Module Name: Makefile
# Abstract: Makefile for rt73 linux driver on kernel series 2.6
######################################################################
CC     :=arn-linux-gcc

LD     :=arm-linux-ld

#PLATFORM=PC
PLATFORM=CMPC

#Enable for wpa_supplicant's spcific driver "driver_ralink.c", default enabled.
HAS_RALINK_WPA_SUPPLICANT_SUPPORT=y
#Enable for wpa_supplicant's generic driver "driver_wext.c", used for NetworkManager
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n
#Support Block Net-If during TxSw queue full.
HAS_BLOCK_NET_IF=y
WFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs
ifeq ($(HAS_RALINK_WPA_SUPPLICANT_SUPPORT),y)
WFLAGS += -DRALINK_WPA_SUPPLICANT_SUPPORT
endif
ifeq ($(HAS_NATIVE_WPA_SUPPLICANT_SUPPORT),y)
WFLAGS += -DNATIVE_WPA_SUPPLICANT_SUPPORT
endif
ifeq ($(HAS_BLOCK_NET_IF),y)
WFLAGS += -DBLOCK_NET_IF
endif
## Comment/uncomment the following line to enable/disable debugging
#EXTRA_CFLAGS += -DDBG
EXTRA_CFLAGS += $(WFLAGS)
ifeq ($(PLATFORM),PC)
LINUX_SRC =/lib/modules/$(shell uname -r)/build
endif
ifeq ($(PLATFORM),CMPC)
#LINUX_SRC = /home/fonchi/vendor/kernel-default-2.6.21/linux-2.6.21
LINUX_SRC = /usr/work/linux-2.6.24

endif
EXTRA_CFLAGS += -I$(LINUX_SRC)/include
obj-m := rt73.o
rt73-objs := /
rtmp_main.o /
mlme.o /
connect.o /
rtusb_bulk.o /
rtusb_io.o /
sync.o /
assoc.o /
auth.o /
auth_rsp.o /
rtusb_data.o /
rtmp_init.o /
sanity.o /
rtmp_wep.o /
rtmp_info.o /
rtmp_tkip.o /
wpa.o md5.o
ifeq ($(HAS_NATIVE_WPA_SUPPLICANT_SUPPORT),y)
rt73-objs += rtmp_wext.o
endif
ifeq ($(HAS_BLOCK_NET_IF),y)
rt73-objs += netif_block.o
endif
## Configuration files on SuSE
#NDDIR=/etc/sysconfig/network
#MOD_CONF=/etc/modprobe.d/module-renames
## NDDIR/ifcfg-rausb0
ND_CONF=/etc/sysconfig/network-scripts/ifcfg-rausb0
ifdef NDDIR
NDDIR := $(NDDIR)
else
  NDDIR := /etc/sysconfig/network-scripts
endif
ifdef MOD_CONF
MOD_CONF := $(MOD_CONF)
else
MOD_CONF := /etc/modprobe.conf
endif
all:
make -C $(LINUX_SRC) SUBDIRS=$(shell pwd) modules
clean:
rm -rf *.o *~ .*.cmd *.ko *.mod.c .tmp_versions built-in.o
install:
make -C /lib/modules/$(shell uname -r)/build /
INSTALL_MOD_DIR=extra SUBDIRS=$(shell pwd) /
modules_install
@echo "Network device directory $(NDDIR)";
@echo "Module configuration file $(MOD_CONF)";
@if [ -d "$(NDDIR)" ] ; then /
  if [ ! -f "$(ND_CONF)" ]; then /
   echo "Create 'ifcfg-rausb0' in $(NDDIR)/"; /
   cp ifcfg-rausb0 $(NDDIR)/ ; /
  fi; /
  fi
@if ! grep -q 'rausb0' $(MOD_CONF) ; then /
  echo "append 'alias rausb0 rt73' to $(MOD_CONF)"; /
  echo "alias rausb0 rt73" >> $(MOD_CONF) ; /
  fi
/sbin/depmod -a
# auto copy *.bin to /etc/Wireless/RT73STA
# mkdir /etc/Wireless ;
# mkdir /etc/Wireless/RT73STA ;
# cp $(shell pwd)/*.bin /etc/Wireless/RT73STA ;
# cp $(shell pwd)/*.dat /etc/Wireless/RT73STA ;
# Copy file on Mandriva 2007.1
# cp $(shell pwd)/*.bin /lib/firmware/ ;
config:
@touch config.mk
@./Configure
4.
交叉編譯

# make all
生成
rt73.ko
5.
在嵌入式linux

# mkdir /etc/Wireless
# mkdir /etc/Wireless/RT73STA
# cp rt73.bin /etc/Wireless/RT73STA/rt73.bin
# dos2unix rt73sta.dat
# cp rt73sta.dat  /etc/Wireless/RT73STA/rt73sta.dat
# /sbin/insmod rt73.ko
#/sbin/ifconfig rausb0 inet 192.168.2.9 up
#route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1  dev rausb0
ping  192.168.2.1 -t


# ifconfig rausb0 up     
# iwconfig            
# iwlist rausb0 scanning     
# iwconfig rausb0 essid "your wireless net"      
# iwconfig rausb0 key "your key"                     
設置一下IP地址和DNS,就可以上網了!

可使用udhcpc自動獲取ip地址

# udhcpc -i rausb0
ping
一下網關及外網地址



發佈了8 篇原創文章 · 獲贊 0 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章