Thursday, September 3, 2015

BBB: Kernel - USB WIFI support


At NezaRobot, BBB will communicate with smart phone to receive object detection information, such as ball and goal location.
BBB has one USB port, I insert it with a USB Wifi, it happens to be rt2800 which Kernel support this.
After compile Kernel and driver, you can copy following drivers and install them after reboot.  You can put following commands into one script.

#install all necessary drivers
insmod rfkill.ko
insmod cfg80211.ko
insmod mac80211.ko
insmod lib80211.ko
insmod rt2x00lib.ko
insmod rt2800lib.ko
insmod rt2x00usb.ko
insmod rt2800usb.ko

#like eth0 is ethernet, wlan0 is for Wifi
ip link set wlan0 up

#turn off power save, otherwise it is not stable
iw dev wlan0 set power_save off

#read configure file and set user name, password to your home Wifi server
wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf

#you can scan your Wifi server now
#iw dev wlan0 scan | grep SSID

#ip addr show wlan0
#ip link show wlan0

iw dev wlan0 link

#my home router is 192.168.2.1
ifconfig wlan0 192.168.2.77 up

configure file:
vi /etc/wpa_supplicant.conf


ctrl_interface=/var/run/wpa_supplicant
network={
    ssid="BELL647"
    proto=WPA2
    pairwise=CCMP
    group=CCMP
    key_mgmt=WPA-PSK
    #psk="password"
    psk=generated 64 hex
}
psk is generated by wpa_passphrase tool. For example, my router ssid is BELL647, password is 12345678

wpa_passphrase BELL647 12345678

network={
        ssid="BELL647"
        #psk="12345678"
        psk=ab2c7c0b8e0d9abe8c28418fd47365b7efb834fafd9d4c21986c648b39a0e0a2
}

so /etc/wpa_supplicant.conf should be:
ctrl_interface=/var/run/wpa_supplicant
network={
        ssid="BELL647"
        proto=WPA2
        pairwise=CCMP
        group=CCMP
        key_mgmt=WPA-PSK
        #psk="12345678"
        psk=ab2c7c0b8e0d9abe8c28418fd47365b7efb834fafd9d4c21986c648b39a0e0a2
}

Save file, reboot, run above script, Wifi should work.

ifconfig:
root@beaglebone:~# ifconfig
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:71

eth0      Link encap:Ethernet  HWaddr C8:A0:30:AC:87:22
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:56

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1760 (1.7 KiB)  TX bytes:1760 (1.7 KiB)

wlan0     Link encap:Ethernet  HWaddr 00:87:34:1D:96:BA
          inet addr:192.168.2.77  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:282 (282.0 B)  TX bytes:3534 (3.4 KiB)

Congratulation! Now you can ping to and from 192.168.2.77
For wpa_supplicant please refer to:
WPA supplicant

No comments:

Post a Comment