learningbydeveloping.com

 

Learning by developing

...because practice teaches you

First of all, this is only valid for the wifi dongle TP-link TL-WN722N. If you want to use another one you might need to use some other modules. This one is based in the ath9k chipset.

 

1st. Install the libraries required:

$ opkg install kmod-ath9k-htc kmod-ath9k-common

 

root@OpenWrt:~/usbboot# opkg install kmod-ath9k-htc_2.6.39.4+2011-12-01-2_ar71xx.ipk

Installing kmod-ath9k-htc (2.6.39.4+2011-12-01-2) to root…

Configuring kmod-ath9k-htc.

root@OpenWrt:~# opkg install kmod-ath9k-common

Upgrading kmod-ath9k-common on root from 2.6.39.4+2011-12-01-2 to 3.2.14+2012-04-13-1…

Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-ath9k-common_3.2.14+2012-04-13-1_ar71xx.ipk.

Multiple packages (kernel and kernel) providing same name marked HOLD or PREFER. Using latest.

Multiple packages (kernel and kernel) providing same name marked HOLD or PREFER. Using latest.

Upgrading kernel on root from 2.6.39.4-1-a61666a8bc8129df4e90e18a2723f7d7 to 3.2.14-1-eb30a01493673f9c92acd8243277c304…

Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kernel_3.2.14-1-eb30a01493673f9c92acd8243277c304_ar71xx.ipk.

Removing obsolete file /lib/modules/2.6.39.4/ath9k_hw.ko.

Removing obsolete file /lib/modules/2.6.39.4/ath9k_common.ko.

Configuring kernel.

Configuring kmod-ath9k-common.

 

 

2nd. Insert the module(with the usb connected):

$ insmod kmod-ath9k-htc

$ insmod kmod-ath9k-common

 

3rd. Now the device should be seen in /proc/bus/usb/devices:

T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#=  5 Spd=480  MxCh= 0

D:  Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs=  1

P:  Vendor=0cf3 ProdID=9271 Rev= 1.08

S:  Manufacturer=ATHEROS

S:  Product=USB2.0 WLAN

S:  SerialNumber=12345

C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA

I:* If#= 0 Alt= 0 #EPs= 6 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)

E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=125us

E:  Ad=04(O) Atr=03(Int.) MxPS=  64 Ivl=125us

E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

 

 

4th. check the “$ iwconfig” output:

root@OpenWrt:~# iwconfig

lo        no wireless extensions.

 

eth0      no wireless extensions.

 

eth1      no wireless extensions.

 

br-lan    no wireless extensions.

 

wlan0     IEEE 802.11bgn  ESSID:off/any

Mode:Managed  Access Point: Not-Associated   Tx-Power=18 dBm

RTS thr:off   Fragment thr:off

Encryption key:off

Power Management:off

wlan1     IEEE 802.11bgn  ESSID:off/any

Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm

RTS thr:off   Fragment thr:off

Encryption key:off

Power Management:off

 

Now wlan1 would be the dongle. Thus we just need to configure it now.

 

5th. Use “$ wifi detect” so that the basic configuration will be written by openwrt’s tool:

root@OpenWrt:~# wifi detect

config wifi-device  radio1

option type     mac80211

option channel  11

option macaddr           XX:XX:XX:XX:XX:XX

option hwmode           11ng

option htmode HT20

list ht_capab    SHORT-GI-20

list ht_capab    SHORT-GI-40

list ht_capab    RX-STBC1

list ht_capab    DSSS_CCK-40

# REMOVE THIS LINE TO ENABLE WIFI:

option disabled 1

 

config wifi-iface

option device   radio1

option network  lan

option mode     ap

option ssid     OpenWrt

option encryption none

 

 

5th.Then copy that content into /etc/config/wireless. Another option would be just to do “$wifi detect >> /etc/config/wireless”.

 

Then you can configure, as shown in other articles, the wifi through UCI or through modifying /etc/config/wireless.

 

Some useful commands that we might need would be:

ifup/ifdown INTERFACE_NAME Activates/deactivates the interface.
ifconfig and iwconfig Check the active interfaces
iwlist $IF scan Detect the active access points through the $IF interface

Note: If you see a message like Device or resource busy, a wpa_supplicant instance is most likely locking the interface. In this case kill the running process and repeat the scan.

 

Associating your interface to a detected access point:

 

1st.  Take the information we need from “$ iwlist $IF scan”

2nd. Configure the SSID:

$ iwconfig $IF essid “$SSID”

3rd. Set the key for that SSID:

$ iwconfig $IF key $KEY

4th. Set the channel that the AP is using:

$ iwconfig $IF channel $CHANNEL

5th. Set the AP name:

$ iwconfig $IF ap $AP

 

That is all I wanted to explain for today. I hope it is useful.

 

Take care and see you next week!

 

David

Leave a Reply