Make a WiFi  Aceess Point with the  BeagleBoneBlack from scratch.     Introduction. If you surf the Internet, you can find several articles about the creation of a Wi Fi Access Point using the Beagle Bone Black. But going deeper and trying to transform what you read into a working device is another story. After wasting much time trying to realise an access point following the instructions found on the web, I decided to write this article where step by step I describe what I did. My aim was the realisation of standalone AP by means of a BBB powered by a battery; the AP was part of a small robot and for that reason, my main goal was the creation of a reliable working  device, not caring about the latest version of linux or something like that; what I wanted was a reliable device working as an AP standalone peripheral. When I started the realisation I already had the wifi usb dongle: TP LINK TL -WN725N, the BBB was the REV.C and even the battery was among the old hardware; for that my hardware was unchangeable, and starting from them I had to build my AP. Why did I say that? Because to realise an AP you have to find out the right combination of hardware, software and correct configuration. So, I made use of a BBB REV.C and  a TP LINK TL -WN725N (with Realtek chipset) as wifi usb dongle; following the details of the AP realisation from scratch. Warning attach the usb wifi dongle to the BBB by means of an extension cord, the HDMI chip makes interferences with the wifi chip.  Installing the image: linux 3.8.13-bone79 The linux image used is the: linux 3.8.13-bone79. Yes, isn’t the latest but as I already stated the right combination of imange, software and setting makes an AP working and reliable. Download the image from Internet (if you want in the download section the image is available). After downloaded it copy it into a usb stick and  carry out then next  steps; attach the usb key to the laptop (I work on my macbook) diskutil list is the command to identify the usb disk; unmount the disk diskutil unmountDisk /dev/disk2 (disk2 is the disk previously found) extract the image( unzip it ) and type the following instuction to write on the usb key. sudo dd bs=1m if=BBB-eMMC-flasher-debian-7.9-lxde-4gb-armhf-2015-11-03-4gb.img of=/dev/disk2 Note: if you want to check teh status of the image transfer press CTRL + i to see the uploading status. With the BBB switched off attach the usb key and switch on the board. There’s not  need to push any button on the board, the boot will begin from the usb stick? How you can have evidence of that ? You’ll see the 4 leds on the BBB linearly blinking. After some minutes you’ll see all the four leds either lit or switched off . Ok It’s time to extract the usb key from the usp port of the BBB and restart the board. Working on the BBB Warning all instructions are thought for the root user. Carry out the following statements to update the BBB and install what we need     apt-get update apt-get install lsb-release apt-get install git apt-get install make apt-get install gcc apt-get install build-essential python-dev python-pip python-smbus  -y This is optional # apt-get install chkconfig after that, go to  /usr/src    cd /usr/src Download kernel sources, you need it to make the modules.  wget https://github.com/beagleboard/linux/archive/3.8.13-bone79.tar.gz extract it gunzip < 3.8.13-bone79.tar.gz | tar xv cd linux-3.8.13-bone79/ make oldconfig make prepare make modules_prepare Now we have the modules. To compile the driver for the usb wifi stick we also need of the source headers. For that, type the following statements. cd /usr/src sudo apt-get install linux-headers-`uname -r` (uname -r give us the current linux version) cd ~ (go to the home directory) Ok, after the propedeutical section, now it’s time to play with our needs: the driver.  There’re a plenty of wifi stick, but there’re a few chipset producers. In our case the vendor (producer) is Realtek, and the model driver fitting our chip(8179) is the 8188. Differently from windows or mac, here we have to download, compile and install the chip driver. Clone from the following address to get the correct driver source. git clone git://github.com/lwfinger/rtl8188eu.git After the downloading  go to the driver directory, and make it; if you see some strange error relative to header missing or modules error read again the upper section; cd rtl8188eu make Install the driver  make install Reboot the BeagleBoneBlack. reboot After rebooted, detach the usb device, and start obesrving the system log with the below statement  tail -f /var/log/messages  attach the usb device, you should see something similar to Feb 13 01:11:14 beaglebone kernel: [10787.843632] usb 1-1: new high-speed USB device number 3 using musb-hdrcFeb 13 01:11:14 beaglebone kernel: [10787.984167] usb 1-1: New USB device found, idVendor=0bda, idProduct=8179Feb 13 01:11:14 beaglebone kernel: [10787.984194] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3Feb 13 01:11:14 beaglebone kernel: [10787.984206] usb 1-1: Product: 802.11n NICFeb 13 01:11:14 beaglebone kernel: [10787.984218] usb 1-1: Manufacturer: RealtekFeb 13 01:11:14 beaglebone kernel: [10787.984229] usb 1-1: SerialNumber: 00E04C0001Feb 13 01:11:14 beaglebone kernel: [10788.000438] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0)Feb 13 01:11:14 beaglebone kernel: [10788.026363] EEPROM ID = 0x8129 Ok press [esc] key,  [:] key,  and [q] key to exit. It’s time to install the wifi listening daemon. If all went good, go ahead and install hostapd:  hostapd is a user space daemon for wireless access point and authentication servers. It’s the core of our access point. Before install it, we need to have the default configuration file modified. so use vi to edit the /etc/default/hostapd file; if you ‘re a newbie vi is one of most old and famous unix editor. Installation and management of  hostapd.  Type the following command vi /etc/default/hostapd Change the following line like the following one; we are telling linux where the configuration file is. DAEMON_CONF="/etc/hostapd/hostapd.conf" Save and exit; to do it, press [:] key, after [w] key and [q] key. Now we create the file previously inserted in  /etc/default/hostapd. touch /etc/hostapd/hostapd.conf vi /etc/hostapd/hostapd.conf Add the following lines to basically configure hostapd interface=wlan0driver=rtl871xdrvhw_mode=gcountry_code=ITssid=beaglebonechannel=7wpa=2wpa_passphrase=yourPasswordwpa_key_mgmt=WPA-PSKwpa_pairwise=TKIPrsn_pairwise=CCMPauth_algs=1macaddr_acl=0ignore_broadcast_ssid=0 the interace is your wlan interface, you’ll set it in some while; the driver is rtl871xdrv in our case (Realtek driver); the hw_mode is g; look at the different wifi modes: a,b g, n; ssid id the identifier of your wifi hot spot;  channel in my case is 7; it’s the wi fi channel to be used; wpa equal to 2 means you’re using WPA2 only; auth_algs=1 means you’re using only wpa, no wep , no both; wpa_passphrase is the password for your hot spot; let the other rows as they are. Save and exit; to do it, press [:] key, after [w] key and [q] key. Now let configure the network interfaces file  vi /etc/network/interfaces Uncomment the chunks relative to the wlan0 or make the below lines. Note the lines  wpa-ssid, wpa-psk and gateway are commented; if you see over  Internet somebody posting a solution for an AP using these lines uncommented he’s cheating,  because in this case the board is connecting to an existing wi fi hot spot.   # WiFi auto wlan0iface wlan0 inet static    #wpa-ssid "TISCALI"    #wpa-psk  “password”    address 192.168.1.150    netmask 255.255.255.0    network 192.168.1.0    broadcast 192.168.1.255    #gateway 192.168.1.151 Moreover, comment the whole  eth0 section, I suppose your BBB is connected to your computer by means of the USB cable. Install the apd. You’ve probably seen several article on the web suggesting how to realise an access point with the BBB, but, I’m sure that you’ll have a working AP with a probability of 10%. I lost much time, with the base BBB image, with hostapd and the DHCP; anyway, after several articles and tries, I found a site where it is available the hostapd patch for our Realtek driver; so you have to download the patch first, and hostapd after;  move the hostapd into the patch directory and follow the instructions. Move to your home directory and download the patch for hostapd (also available on this site): git clone https://github.com/pritambaral/hostapd-rtl871xdrv.git get hostapd from the official site (also available on this site); wget http://w1.fi/releases/hostapd-2.5.tar.gz unzip hostapd gunzip> .config vi .config comment this line, or you’re going to catch an error: CONFIG_DRIVER_NL80211=y this is the line commented #CONFIG_DRIVER_NL80211=y Save and exit; to do it, press [:] key, after [w] key and [q] key. make Proceed  to debug it. NOTE hostapd is already present in /usr/sbin so debug  this way (from the make directory). What are you doing? You’re calling hostapd from the current directory and pointing to the .conf file located in /etc/hostapd ./hostapd /etc/hostapd/hostapd.conf If all went ok you should see hostapd running. restart the networking service /etc/init.d/networking restart Installation of dhcp. Once you got the connection with the BBB you need of an IP address. The next section explains how to download and configure isc-dhcp-server. To install isc-dhcp-server type the statement  apt-get install isc-dhcp-server Edit the .conf file  vi /etc/dhcp/dhcpd.conf For a minimum configuration, and add the following lines:   subnet 192.168.1.0 netmask 255.255.255.0 {  range 192.168.1.151 192.168.1.160;  option routers 192.168.1.150;} In the first line we provide the subnet and the netmask (you can use them); after you see the range of IP addresses assigned from the BBB to the connecting clients; in this configuration the range starts from 192.168.1.151 and ends with 192.168.1.160; so the clients are going to take one of the 10 provided addresses. During my tries I lost much time, because I forgot to put in my configuration the second line: option routers 192.168.1.150. In my configuration the router equals the IP address of the board (the static IP address within /etc/network/interfaces) without that line, the BBB cannot send packets in a right manner and your client doesn’t join correctly to the BBB, and when you try to connect your mobile device to the BBB, you’ll see the WIFI spinner turn around indefinitely, so there will be a not finished handshaking. Put that line in the configuration. Now restart the DHCP service: restart the service: service isc-dhcp-server restart Check the status of the service service isc-dhcp-server  status  if the dhcp fail to start, try to manually start the wlan:  ifup wlan0  (start the wlan0) Make hostapd autorunning. We want the hostapd runs at boot  time, so that the BBB can be a standalone peripheral. To do that, follow the below instructions: cd  /usr/bin  create the run_hostapd_world.sh file; it’s a shell file; touch run_hostapd_world.sh change the permission so that it be executable chmod +x run_hostapd_world.sh edit the file vi run_hostapd_world.sh add lines #! /bin/sh echo wait a few seconds the USBsleep 15ifup wlan0echo starting DHCP serverservice isc-dhcp-server restartecho starting hostapd/root/hostapd-2.5/hostapd/hostapd /etc/hostapd/hostapd.conf create another file; this is the service touch /lib/systemd/run_hostapd_world.service vi /lib/systemd/run_hostapd_world.service add these lines, they are the service configuration [Unit]Description=run_hostapd_worldAfter=syslog.target network.target[Service]Type=simpleExecStart=/usr/bin/run_hostapd_world.sh[Install]WantedBy=multi-user.target change the permission so that it be executable chmod +x run_hostapd_world.service now we have to make the symbolic between /lib/systemd/ and /etc/systemd/system/,  follow the instructions below cd /etc/systemd/system/ ln -s /lib/systemd/run_hostapd_world.service run_hostapd_world.service we have to reload by systemctl all daemons systemctl daemon-reload start the new service systemctl start run_hostapd_world.service enable the service; it will start at reboot systemctl enable  run_hostapd_world.service reboot the BBB reboot After 30 seconds  ping it; you should have something like that ping 192.168.1.150 PING 192.168.1.150 (192.168.1.150): 56 data bytes64 bytes from 192.168.1.150: icmp_seq=0 ttl=64 time=3.171 ms64 bytes from 192.168.1.150: icmp_seq=1 ttl=64 time=2.726 ms connect to BBB and enjoy ssh -o StrictHostKeyChecking=no root@192.168.1.150
written by Ivan Cerrato
next
back to home
LINUX  BeagleBoneBlack Wi Fi Access Point
hostapd-2.5.tar.gz
BBB-eMMC-flasher-debian-7.9-lxde-4gb-armhf-2015-11-03-4gb.img.xz
back
[if gte mso 9]> 0 0 1 40 232 extech 1 1 271 14.0 Normal 0 false false false EN-US JA X-NONE
rtl8188eu.tar.gz
hostapd-rtl871xdrv.tar.gz