Note:
For how to make pcDuino v2 as a WiFi AP, please refer to: http://learn.linksprite.com/?p=1138
The kernel in the 4/28 release only contains wifi STA driver and doesn’t have the driver for IP forwarding software iptables. So we need to replace the kernel uImage first.
All files mentioned in the following can be downloaded here.
Copy wifiAP to ubuntu directory.
- ubuntu@ubuntu:~$ ls
- Desktop Downloads Pictures Templates c_enviroment wifiAP
- Documents Music Public Videos sample
$ sudo mount /dev/nanda /boot
$ sudo cp uImage /boot -f
$ sudo cp evb.bin /boot -f
$ sudo cp 3.4.292B.tar.bz2 /lib/modules/
$ cd /lib/modules/
ubuntu@ubuntu:/lib/modules$sudo tar -xvf 3.4.292B.tar.bz2
$sudo reboot
We can use ‘$lsmod’ to check the modules.
- root@ubuntu:/home/ubuntu# lsmod
- Module Size Used by
- rt5370sta 617141 0
- 8192cu 537048 0
- rt2800usb 11321 0
- rt2800lib 40721 1 rt2800usb
- crc_ccitt 1094 1 rt2800lib
- rt2x00usb 7245 1 rt2800usb
- rt2x00lib 31040 3 rt2800usb,rt2800lib,rt2x00usb
- mali_drm 2087 1
- drm 157060 2 mali_drm
- mac80211 257514 3 rt2800lib,rt2x00usb,rt2x00lib
- cfg80211 150671 2 rt2x00lib,mac80211
- mali 91258 0
- disp_ump 823 0
- ump 44002 4 mali,disp_ump
After reboot, edit /etc/modules, and comment out the rt5370sta.
$sudo modprobe rt2800usb
$echo 148F 5370 > /sys/bus/usb/drivers/rt2800usb/new_id
The above commands can also be entered through the serial debug port.
Now, if we do “$ifconfig wlan3 up”, we will get the following error message:
root@ubuntu:~# ifconfig wlan3 up
[ 1043.640000] phy0 -> rt2x00lib_request_firmware: Error – Failed to request Firmware.
SIOCSIFFLAGS: No such file or directory
That means that the firmware of USB wifi dongle is not in place, and we need to place it in right place.
We can use “$modinfo rt2800usb” to find out that the firmware name is rt2870.bin.
root@ubuntu:~# modinfo rt2800usb
filename: /lib/modules/3.4.29+/kernel/drivers/net/wireless/rt2x00/rt2800usb.ko
license: GPL
firmware: rt2870.bin
description: Ralink RT2800 USB Wireless LAN driver.
version: 2.3.0
author: http://rt2x00.serialmonkey.com
$sudo cp rt2870.bin /lib/firmware/
Now we can run ”$sudo ifconfig wlan3 up” again.
Now we get Wifi connection again.
$sudo apt-get install iptables vim iw
After the installation is done, we can check if iptables is installed Okay by:
$sudo iptables -L
root@ubuntu:~# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Now we need to download hostapd and build it.
The build dependency is “libnl-dev” and “libssl-dev”.
We can install them by:
$sudo apt-get install libnl-dev libssl-dev
Hostpad 1.0 can be downloaded from: http://hostap.epitest.fi/releases/
We can use the following command:
ubuntu@ubuntu:~$ wget http://hostap.epitest.fi/releases/hostapd-1.0.tar.gz
ubuntu@ubuntu:~$ tar xvf hostapd-1.0.tar.gz
ubuntu@ubuntu:~$ cd hostapd-1.0
ubuntu@ubuntu:~/hostapd-1.0$ cd hostapd/
ubuntu@ubuntu:~/hostapd-1.0/hostapd$ vim defconfig
Locate the line “#CONFIG_IEEE80211N=y”, and remove the ‘#’. Save and exit.
ubuntu@ubuntu:~/hostapd-1.0/hostapd$ cp defconfig .config
ubuntu@ubuntu:~/hostapd-1.0/hostapd$ make
CC main.c
CC config_file.c
CC ../src/ap/hostapd.c
CC ../src/ap/wpa_auth_glue.c
CC ../src/ap/drv_callbacks.c
CC ../src/ap/ap_drv_ops.c
CC ../src/ap/utils.c
CC ../src/ap/authsrv.c
ubuntu@ubuntu:~/hostapd-1.0/hostapd$ sudo make install
mkdir -p /usr/local/bin
for i in hostapd hostapd_cli; do cp -f $i /usr/local/bin/$i; done
Let’s check if hostpad is installed Okay:
ubuntu@ubuntu:~/hostapd-1.0/hostapd$ hostapd -v
hostapd v1.0
User space daemon for IEEE 802.11 AP management,
IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi> and contributors
Now we begin to config hostpad.
We would like to have:
SSID: ssid=pcduino
Password: wpa_passphrase=1234567890
Encryption: wpa_key_mgmt=WPA-PSK
root@ubuntu:~# nano /etc/hostapd.conf
interface=wlan3
driver=nl80211
ssid=pcduino
hw_mode=g
channel=11
dtim_period=1
rts_threshold=2347
fragm_threshold=2346
macaddr_acl=0
auth_algs=1
ieee80211n=0
wpa=2
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Note: wlan3 can be changed! Please alway use ‘ifconfig” to check.
After the configure file is created, we can use the following command to check the configuration.
root@ubuntu:~# hostapd -dd /etc/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd.conf
nl80211: interface wlan4 in phy phy0
rfkill: initial event: idx=0 type=2 op=0 soft=0 hard=0
rfkill: initial event: idx=1 type=1 op=0 soft=0 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
nl80211: Register frame match – hexdump(len=1): 06
nl80211: Failed to register Action frame processing – ignore for now
nl80211: Add own interface ifindex 5
nl80211: Set mode ifindex 5 iftype 3 (AP)
nl80211: Create interface iftype 6 (MONITOR)
nl80211: New interface mon.wlan4 created: ifindex=7
nl80211: Add own interface ifindex 7
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information – country=00
nl80211: 2402-2472 @ 40 MHz
nl80211: 2457-2482 @ 40 MHz
nl80211: 2474-2494 @ 20 MHz
nl80211: 5170-5250 @ 40 MHz
nl80211: 5735-5835 @ 40 MHz
nl80211: Added 802.11b mode based on 802.11g information
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm
Completing interface initialization
Mode: IEEE 802.11g Channel: 11 Frequency: 2462 MHz
nl80211: Set freq 2462 (ht_enabled=0 sec_channel_offset=0)
RATE[0] rate=10 flags=0×1
RATE[1] rate=20 flags=0×1
RATE[2] rate=55 flags=0×1
RATE[3] rate=110 flags=0×1
RATE[4] rate=60 flags=0×0
RATE[5] rate=90 flags=0×0
RATE[6] rate=120 flags=0×0
RATE[7] rate=180 flags=0×0
RATE[8] rate=240 flags=0×0
RATE[9] rate=360 flags=0×0
RATE[10] rate=480 flags=0×0
RATE[11] rate=540 flags=0×0
Flushing old station entries
We can then install dhcp server:
$sudo apt-get install dhcp3-server
After installation, we need to configre the dhcp server too.
$sudo nano /etc/dhcp/dhcpd.conf
Append the following statements to the end:
subnet 192.168.0.0 netmask 255.255.255.0
{
range 192.168.0.2 192.168.0.10;
option routers 192.168.0.1; #router address
option domain-name-servers 8.8.8.8;
}
root@ubuntu:~# killall hostapd
hostapd: no process found
root@ubuntu:~# hostapd -B /etc/hostapd.conf
Configuration file: /etc/hostapd.conf
Using interface wlan4 with hwaddr 00:c3:16:a0:03:00 and ssid ‘pcduino’
Set the WiFi IP address of pcDuino:
root@ubuntu:~# ifconfig wlan4 192.168.0.1
Turn on DHCP:
root@ubuntu:~# dhcpd wlan4 -pf /var/run/dhcp-server/dhcpd.pid
Internet Systems Consortium DHCP Server 4.1-ESV-R4
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Wrote 0 leases to leases file.
Listening on LPF/wlan4/00:c3:16:a0:03:00/192.168.0.0/24
Sending on LPF/wlan4/00:c3:16:a0:03:00/192.168.0.0/24
Sending on Socket/fallback/fallback-net
Enable IP forwarding:
root@ubuntu:~# echo 1 >/proc/sys/net/ipv4/ip_forward
Set NAT:
root@ubuntu:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Now we are all set, you should be able to see a hotspot named ‘pcduino’!
Leave a Reply
You must be logged in to post a comment.