Before reading through this article, to build and install GNU/Linux on embedded board,
read through this link.
To bring WiFi client feature on your embedded board,
read through this link.
----
Follow these simple steps below to bring your board as AP.
-
Install necessary tools
Install hostapd and dnsmasq necessary for an Access Point.
# apt-get install hostapd dnsmasq --no-install-recommends
-
Configure network interface
Add or modify /etc/network/interface to contain the following.
# cat /etc/network/interface
auto lo wlan0
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
iface wlan0 inet static
address 192.168.1.1
network 192.168.1.0
netmask 255.255.255.0
allow-hotplug wlan0
The above file says how our system get connected through eth0, wlan0 and lo. Check man page of interfaces for more details.
-
Configure hostapd
# cat /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
DAEMON_OPTS="-dd"
# cat /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=zilogic
channel=1
-
Configure dnsmasq with Client IP range
# cat /etc/dnsmasq.conf
interface=wlan0
dhcp-range=192.168.1.10,192.168.1.100,12h
dhcp-option=3,192.168.1.1
-
Start hostapd and dnsmasq services.
# service hostapd start
# service dnsmasq start
Note: Now, you can try Raspberry Pi 3 that comes with WiFi and Bluetooth on-board for IoT applications.
More Reading
-
What is the significance of firmware-atheros package?
-
What is the significance of wireless-tools utility?
-
What is iw and iwconfig? How do they differ?
-
What is wpa_supplicant? How to connect to an encrypted connection?
-
What is Wireless Extensions(WE)?
-
What are nl80211 and cfg80211 and how do they differ from WE?
-
What is Bridging in network connections?
To prepare your embedded board with GNU/Linux running on it,
read through this link.
To bring Wi-Fi Access Point feature,
read through this link.
----
To bring Wi-Fi client feature with the given NIC on your Embedded board running Linux, we may need
-
Device driver for the given NIC enabled in the Kernel.
-
Some HAL layer firmware, if required by the device driver. (Ref. ath9k_htc firmware - github.com)
-
Certain utilities to configure and manage Wi-Fi.
(iw, ip, iwconfig, wpa_passphrase, wpa_supplicant, firmware-atheros)
Installing custom packages
You may require some software utilities like, iwconfig, iw, etc., which may be required to solve your purpose. To install them there are the following possibilities.
-
Download .deb packages of required utilities to a USB Stick or to the SD Card and install them using dpkg with -i
option. But, we have to know all the dependencies for evey package you
install and have them downloaded and installed prior to installing the
main package.
-
Include the packages while building the rootfs.
-
Connect to internet through any possible interface available (ethernet, wlan) and using apt-get install them from your favorite repository. But, your board should have any such interface enabled and available for use.
-
Use chroot on your host Linux System to change from the host’s rootfs to the SD Cards rootfs/(target fs). This method is followed in this case.
Installing custom packages using chroot
-
This requires super user access. VirtualBox together with Vagrant can be
used to get super user access by normal user.
-
Also, chroot will work only if the target architecture is same as that of the host.
-
When configuring kernel during compilation, enable support for ath9k_htc under device drivers in menuconfig. ath9k_htc is a device driver specific to atheros AR9271 which is the chipset used in our given NIC (TP-Link TL-WN722N).
-
qemu-arm-static is a binary that can be installed in host and
copied to target file system. This is used as an interpreter to run arm
binaries of target file system(SD Card rootfs/). This will fix the
architecture issue while using chroot.
$ sudo apt-get install binfmt-support qemu-user-static
$ cp /usr/bin/qemu-arm-static /home/user/rootfs/usr/bin
Here, SD Card is mounted at /home/user/. The option binfmt-support says the binfmt_misc kernel module to use qemu-arm-static as the interpreter to execute arm binaries.
-
Mount proc/ and sys/
$ cd rootfs
$ sudo mount -t proc none proc/
$ sudo mount -t sysfs sysfs sys/
$ sudo mount -o bind /dev dev/
-
Change rootfs
(need to be super user to do this)
$ sudo chroot rootfs/
root@emdebian:/#
-
Update list and install packages (firmware-atheros, wireless-tools, wpasupplicant, wireless-tools, iw, kmod) and then exit and unmount proc, sys and dev. firmware-atheros is required for our case but not mandatory for all the atheros devices[3].
# apt-get update
# apt-get install firmware-atheros wpasupplicant wireless-tools iw kmod
# exit
$ unmount /rootfs/proc/
$ unmount /rootfs/sys/
Unmount the SD Card from the PC and connect to
the board and boot it. In SAMA5D3_Xplained board, a dedicated DEBUG
console is provided which can be used to connect to system terminal
through a USB-Serial converter. After the system boots up and logged in,
plug the NIC in the USB port. The device should be automatically
detected and will be ready to use.
-
Enable wlan0
# ifconfig /* To check if wlan inteface is listed */
# ifconfig wlan0 up
The second command will enable the default WLAN interface wlan0. Now the interface will be up and ready to use.
Connecting to an open network as Client
-
Connecting to an open network is simple. It can be achieved using the iwconfig utility.
# iwconfig dev wlan0 connect <SSID>
You can also try iw.
-
Get IP assigned from AP
You can check -r option for dhclient to release the current IP lease when necessary.
More Reading
-
What is the significance of firmware-atheros package?
-
What is the significance of wireless-tools utility?
-
What is iw and iwconfig? How do they differ?
-
What is wpa_supplicant[4]? How to connect to an encrypted connection?
-
What is Wireless Extensions(WE)?
-
What are nl80211 and cfg80211 and how do they differ from WE?
-
What is Bridging in network connections?