? ? 幾年前,入了一個tl wn725的usb無線網(wǎng)卡咪笑,在windows下使用還可以可帽,連接速度150M,40Mhz窗怒,MCS7映跟。于是想把這個無線網(wǎng)卡用在raspiberry 2上面,編譯內(nèi)核的時候加上mt7601支持兜粘,把系統(tǒng)cp到ssd卡boot分區(qū)申窘,啟動,然后插入wn725孔轴,看dmesg
Jun 24 14:15:57 pi kernel: [ 2826.232039] usb 1-1.4: new high-speed USB device number 8 using dwc_otg
Jun 24 14:15:57 pi kernel: [ 2826.332869] usb 1-1.4: New USB device found, idVendor=148f, idProduct=2878
Jun 24 14:15:57 pi kernel: [ 2826.332898] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Jun 24 14:15:57 pi kernel: [ 2826.332914] usb 1-1.4: Product: ?
Jun 24 14:15:57 pi kernel: [ 2826.332929] usb 1-1.4: Manufacturer: ?
Jun 24 14:15:57 pi kernel: [ 2826.333986] usb-storage 1-1.4:1.0: USB Mass Storage device detected
Jun 24 14:15:57 pi kernel: [ 2826.334472] scsi host2: usb-storage 1-1.4:1.0
Jun 24 14:15:58 pi-mao kernel: [ 2827.332761] scsi 2:0:0:0: CD-ROM? ? ? ? ? ? MediaTek Flash autorun? ? 0.01 PQ: 0 ANSI: 0 CCS
Jun 24 14:15:58 pi kernel: [ 2827.334241] sr 2:0:0:0: [sr0] scsi3-mmc drive: 52x/52x cd/rw xa/form2 cdda tray
Jun 24 14:15:58 pi kernel: [ 2827.335913] sr 2:0:0:0: Attached scsi generic sg0 type 5
不認(rèn)設(shè)備啊剃法,google了一下,手工可以使用eject /dev/sr0路鹰,彈出存儲設(shè)備,設(shè)備就會做為網(wǎng)卡
#eject /dev/sr0
dmesg看輸出:
Jun 24 14:18:37 pi kernel: [ 2986.274120] usb 1-1.4: USB disconnect, device number 8
Jun 24 14:18:38 pi kernel: [ 2986.673329] usb 1-1.4: new high-speed USB device number 9 using dwc_otg
Jun 24 14:18:38 pi kernel: [ 2986.784543] usb 1-1.4: New USB device found, idVendor=148f, idProduct=7601
Jun 24 14:18:38 pi kernel: [ 2986.784569] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 24 14:18:38 pi kernel: [ 2986.784585] usb 1-1.4: Product: 802.11 n WLAN
Jun 24 14:18:38 pi kernel: [ 2986.784600] usb 1-1.4: Manufacturer: MediaTek
Jun 24 14:18:38 pi kernel: [ 2986.784615] usb 1-1.4: SerialNumber: 1.0
Jun 24 14:18:38 pi kernel: [ 2986.863351] usb 1-1.4: reset high-speed USB device number 9 using dwc_otg
Jun 24 14:18:38 pi kernel: [ 2986.966276] mt7601u 1-1.4:1.0: ASIC revision: 76010001 MAC revision: 76010500
Jun 24 14:18:38 pi kernel: [ 2986.967770] mt7601u 1-1.4:1.0: Firmware Version: 0.1.00 Build: 7640 Build time: 201302052146____
Jun 24 14:18:39 pi kernel: [ 2987.372699] mt7601u 1-1.4:1.0: Warning: unsupported EEPROM version 0d
Jun 24 14:18:39 pi kernel: [ 2987.372727] mt7601u 1-1.4:1.0: EEPROM ver:0d fae:00
Jun 24 14:18:39 pi kernel: [ 2987.374216] mt7601u 1-1.4:1.0: EEPROM country region 01 (channels 1-13)
看到系統(tǒng)已經(jīng)識別出網(wǎng)卡雁竞,但是不能每次使用都手工輸入eject啊碑诉,于是使用udev德挣,在設(shè)備初始化的時候自動eject sr0/sg0
在/etc/udev/rules.d目錄下增加一個725.udev
#148f:2878#
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="148f", ATTRS{idProduct}=="2878", RUN+="/usr/bin/logger detected WN725"
KERNEL=="sr0", RUN+="/usr/bin/eject /dev/sr0"
這樣就在每次插入后自動eject設(shè)備格嗅,下面開始配置無線玄柏,使用 wpa_supplicant套件禁荸。
配置/etc/network/interfaces
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
其中最后一句是重點,網(wǎng)上的資料基本上都沒有?說陷嘴,我是通過查看日志才知道應(yīng)該這么寫的
然后需要配置/etc/wpa_supplicant/wpa_supplicant.conf,其中psk通過wpa_passphrase生成
也可以使用wpa_gui
最后配置文件是這個樣子:
network={
? ? ? ? ssid="xxxx"
? ? ? ? psk=a0de260342bf0bf270966b1ac100b7174ab733c26c1d24f875cba1f98abc6447
? ? ? ? key_mgmt=WPA-PSK
? ? ? ? pairwise=CCMP
? ? ? ? auth_alg=OPEN
? ? ? ? priority=1
}
配置完了就可以再測試一下了劳澄,重新插撥一下網(wǎng)卡,日志如下:
Jun 24 14:28:01 pi kernel: [ 3550.123212] scsi 3:0:0:0: CD-ROM MediaTek Flash autorun 0.01 PQ: 0 ANSI: 0 CCS
Jun 24 14:28:01 pi kernel: [ 3550.124648] sr 3:0:0:0: [sr0] scsi3-mmc drive: 52x/52x cd/rw xa/form2 cdda tray
Jun 24 14:28:01 pi kernel: [ 3550.126224] sr 3:0:0:0: Attached scsi generic sg0 type 5
Jun 24 14:28:02 pi kernel: [ 3550.393264] usb 1-1.4: USB disconnect, device number 10
Jun 24 14:28:02 pi kernel: [ 3550.812474] usb 1-1.4: new high-speed USB device number 11 using dwc_otg
Jun 24 14:28:02 pi kernel: [ 3550.923690] usb 1-1.4: New USB device found, idVendor=148f, idProduct=7601
Jun 24 14:28:02 pi kernel: [ 3550.923716] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 24 14:28:02 pi kernel: [ 3550.923732] usb 1-1.4: Product: 802.11 n WLAN
Jun 24 14:28:02 pi kernel: [ 3550.923747] usb 1-1.4: Manufacturer: MediaTek
Jun 24 14:28:02 pi kernel: [ 3550.923762] usb 1-1.4: SerialNumber: 1.0
Jun 24 14:28:02 pi kernel: [ 3551.002474] usb 1-1.4: reset high-speed USB device number 11 using dwc_otg
Jun 24 14:28:02 pi kernel: [ 3551.105431] mt7601u 1-1.4:1.0: ASIC revision: 76010001 MAC revision: 76010500
Jun 24 14:28:02 pi kernel: [ 3551.106925] mt7601u 1-1.4:1.0: Firmware Version: 0.1.00 Build: 7640 Build time: 201302052146____
Jun 24 14:28:03 pi kernel: [ 3551.509358] mt7601u 1-1.4:1.0: Warning: unsupported EEPROM version 0d
Jun 24 14:28:03 pi kernel: [ 3551.509387] mt7601u 1-1.4:1.0: EEPROM ver:0d fae:00
Jun 24 14:28:03 pi kernel: [ 3551.509948] mt7601u 1-1.4:1.0: EEPROM country region 01 (channels 1-13)
Jun 24 14:28:04 pi kernel: [ 3553.144356] cfg80211: Exceeded CRDA call max attempts. Not calling CRDA
Jun 24 14:28:04 pi kernel: [ 3553.316305] wlan0: authenticate with 20:76:93:42:ec:c4
Jun 24 14:28:05 pi kernel: [ 3553.355888] wlan0: send auth to 20:76:93:42:ec:c4 (try 1/3)
Jun 24 14:28:05 pi kernel: [ 3553.357961] wlan0: authenticated
Jun 24 14:28:05 pi kernel: [ 3553.362475] wlan0: associate with 20:76:93:42:ec:c4 (try 1/3)
Jun 24 14:28:05 pi kernel: [ 3553.372739] wlan0: RX AssocResp from 20:76:93:42:ec:c4 (capab=0xc31 status=0 aid=8)
Jun 24 14:28:05 pi kernel: [ 3553.401508] wlan0: associated
Jun 24 14:28:05 pi kernel: [ 3553.402884] cfg80211: Calling CRDA to update world regulatory domain
ifconfig可以看到ip已經(jīng)分配庵芭。
ps -ef | grep wlan0可以看到啟動的進(jìn)程:
root? ? ? 3903? ? 1 0 14:28 ?? ? ? ? 00:00:00 /usr/sbin/ifplugd -i wlan0 -q -f -u0 -d10 -w -I
root? ? ? 3923? ? 1? 0 14:28 ?? ? ? ? 00:00:00 /sbin/wpa_supplicant -s -B -P /var/run/wpa_supplicant.wlan0.pid -i wlan0 -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf
root? ? ? 3989? ? 1? 0 14:28 ?? ? ? ? 00:00:00 dhclient -v -pf /run/dhclient.wlan0.pid -lf /var/lib/dhcp/dhclient.wlan0.leases wlan0
這樣每次插入網(wǎng)卡的時候,就會自動啟動網(wǎng)絡(luò)了好乐,但是還有個問題:
就是如果是插著網(wǎng)卡上電或者重啟曹宴,udev可能不會執(zhí)行笛坦,sr0就無法彈出废离,后面的步驟就無法執(zhí)行蜻韭,不知道有沒有?好的方法肖方?