imx6ul之OpenWRT添加無線USB網卡

說明

要完成網線網卡的驅動需要在內核中添加驅動,同時還需要將固件放入rootfs中正確的位置,如果需要固件的話。


內核驅動添加

因爲內核中對常規的USB網卡均支持,所以直接添加即可, 例如下面是對9170的支持:



Firmware添加

在menuconfig中直接添加:


啓動確認

啓動後,我們需要等待rootfs完成後再插入, 這樣子可以比較容易看到log, 對於TPLink的其中一款,對應的log如下:

[plain]  view plain  copy
  1. [ 1015.718981] usb 1-1.2.4: new high-speed USB device number 9 using ci_hdrc  
  2. [ 1015.978998] usb 1-1.2.4: reset high-speed USB device number 9 using ci_hdrc  
  3. [ 1016.136841] usb 1-1.2.4: driver   API: 1.9.7 2012-12-15 [1-1]  
  4. [ 1016.145314] usb 1-1.2.4: firmware API: 1.9.6 2012-07-07  
  5. [ 1016.497852] ath: EEPROM regdomain: 0x809c  
  6. [ 1016.497905] ath: EEPROM indicates we should expect a country code  
  7. [ 1016.497942] ath: doing EEPROM country->regdmn map search  
  8. [ 1016.497976] ath: country maps to regdmn code: 0x52  
  9. [ 1016.498010] ath: Country alpha2 being used: CN  
  10. [ 1016.498040] ath: Regpair used: 0x52  
  11. [ 1016.500103] ieee80211 phy3: Selected rate control algorithm 'minstrel_ht'  
  12. [ 1016.510419] input: phy3 WPS Button as /devices/soc0/soc.0/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2.4/1-1.2.4:1.0/ieee80211/phy3/input4  
  13. [ 1016.526387] evbug: Connected device: input4 (phy3 WPS Button at ieee80211/phy3/input0)  
  14. [ 1016.526430] usb 1-1.2.4: Atheros AR9170 is registered as 'phy3'  

從log看,加載了對應的固件。配置country code。這個FW位於:

[plain]  view plain  copy
  1. [email protected](none):/# ls /lib/firmware/carl9170-1.fw -lu  
  2. -rw-r--r--    1 root     root         13388 Feb  1 02:53 /lib/firmware/carl9170-1.fw  
  3. [email protected](none):/#   

因爲這個網卡具備WPS功能,有一個按鍵,所以有一個input設備。

對於另外一個USB網卡:

[plain]  view plain  copy
  1. [ 1022.368886] usb 1-1.2.1: new high-speed USB device number 10 using ci_hdrc  
  2. [ 1022.608872] usb 1-1.2.1: reset high-speed USB device number 10 using ci_hdrc  
  3. [ 1022.740356] ieee80211 phy4: rt2x00_set_rt: Info - RT chipset 3070, rev 0201 detected  
  4. [ 1022.804614] ieee80211 phy4: rt2x00_set_rf: Info - RF chipset 0005 detected  
  5. [ 1022.813948] ieee80211 phy4: Selected rate control algorithm 'minstrel_ht'  


然後就可以看到對應的網卡設備了:

[plain]  view plain  copy
  1. wlan0     Link encap:Ethernet  HWaddr 7c:dd:90:b2:73:b1    
  2.           BROADCAST MULTICAST  MTU:1500  Metric:1  
  3.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
  4.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
  5.           collisions:0 txqueuelen:1000   
  6.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  
  7.   
  8. wlan1     Link encap:Ethernet  HWaddr 94:0c:6d:7c:12:f6    
  9.           BROADCAST MULTICAST  MTU:1500  Metric:1  
  10.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
  11.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0  
  12.           collisions:0 txqueuelen:1000   
  13.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)  

網卡功能查詢

使用USB網卡來做AP那麼就需要確定時候具備AP功能

使用iw list命令, 然後找到對應的modes:

[plain]  view plain  copy
  1. Supported interface modes:  
  2.                  * IBSS  
  3.                  * managed  
  4.                  * AP  
  5.                  * AP/VLAN  
  6.                  * monitor  
  7.                  * P2P-client  
  8.                  * P2P-GO  

另外一個網卡具備的modes:

[plain]  view plain  copy
  1. Supported interface modes:  
  2.           * IBSS  
  3.           * managed  
  4.           * AP  
  5.           * AP/VLAN  
  6.           * WDS  
  7.           * monitor  
因此可以確定兩個網卡均具備AP模式, 還有一個具備monitor模式。生成了Network Interface後,接下來我們將完成AP功能。