EAP Controller Software on a Raspberry Pi

The EAP Controller from TP-Link is provided for x86 architecture. I will detail how to install the EAP Controller on a Raspberry Pi with armhf architecture. It worked successfully on a Raspberry Pi zero W. Unfortunately, it ran out of memory on a Raspberry Pi 2 Model B.

Skip the intro for step-by-step tutorial, it simply provides some context. Also, you may want to first try to use this script to install the patched version automatically: https://gist.github.com/Arth-ur/ea1a6709055cec3dab196c3490af6d99

Last week, I had to install a wifi hotspot for a house welcoming parents who have hospitalized children in neighboring hospital. It is run by is a charity who attributes the room, do the cleaning… It is very similar to a youth hostel. The charity provides Internet access by giving the WPA key of the wifi to residents. Resident who desires Internet access must pay 5€ to get the key. This approach has the following problems:
 — lack of expiration: some residents stay 3 months and pay the same as residents who stay only one night,
 — returning resident keep access to the network,
 — residents can share the code among themselves or with neighbours,
 — in France, law requires internet providers to protect their access point.

I had little experience in this domain, so I offer to do the installation to gain knowledge and address some of these issues. The requirements are:
 — low cost solution: less than 60€
 — reliable with little to no maintenance by non tech-savvy people
 — fast to install, I only had 2 days to experiment and install the system

I wanted to make a captive portal, so I googled “captive portal access point” and chose the EAP115. The Captive Portal feature requires the EAP Controller software to be always running in the same network as the access point. I chose to use the Raspberry PI Zero W because it is cheap and has built-in wifi, so no need for cables! Now I just had to install the EAP Controller on the Raspberry…


Installation of the EAP Controller on the RPI

TP-Link provides binaries for Windows, Windows Server and Linux x86. However, the Raspberry Pi is not compatible with x86. Fortunately, the software is written in Java and one can patch the installation by following a few simple steps. I am using Raspbian Lite.

Step 0: follow installation instructions from TP-LINK

Pretty easy: download the archive from http://www.tp-link.com/us/download/EAP-Controller.html, extract it, install it

mkdir EAP_Controller
cd EAP_Controller
wget http://static.tp-link.com/EAP_Controller_v2.4.8_linux_x64.tar.gz
tar -xvf EAP_Controller_v2.4.8_linux_x64.tar.gz
sudo ./install.sh

An error should appear at the end of the installation. Ignore it for now and go to install directory:

cd /opt/tplink/EAPController

Step 1: portt

If you try to start the controller with:

sudo tpeap start

an error appears:

/opt/tplink/EAPController/bin/portt: Cannot execute binary file: Exec format error

Indeed, portt has been compiled for x86 and we are on a armhf architecture. At this point, I tried to use qemu for virtualisation, but it did not work. Then I started to think how to replace the portt executable. It is pretty straightforward: portt returns 0 if port 8088 is open, 1 if it is closed. Luckily, other softwares exists for this task!

Open file bin/controller.sh and replace line

${PORTT_TOOL} 127.0.0.1 8088 500

by

netstat -plnt | grep :::8088

Step 2: Java

Try to start the service, the error should have changed! The error is now that the EAP Controller is bundled with its own version of the JRE. This version is compiled for x86, simply replace it by the raspberry’s version and it works! To do so, start by installing java:

sudo apt-get install oracle-java7-jdk

Then in bin/controller.sh, replace the line

JAVA_TOOL=${JRE_HOME}/bin/java

by the path of raspberry’s java, by default:

JAVA_TOOL=/usr/bin/java

To get the path of the Java command, type

which java

This version of Java does not support the Server VM, simply replace it by the Client VM by replacing the switch accordingly in line:

nohup $JAVA_TOOL -server -Xms128m -Xmx1024m -XX:MaxHeapFreeRatio=60 -XX:MinHeapFreeRatio=30 -XX:+UseSerialGC -XX:+HeapDumpOnOutOfMemoryError -Deap.home="${eapHome}" -cp ${eapHome}"/lib/com.tp-link.eap.start-0.0.1-SNAPSHOT.jar:"${eapHome}"/lib/*:"${eapHome}"/external-lib/*" com.tp_link.eap.start.EapMain start > ${eapHome}/logs/startup.log 2>&1 &

By:

nohup $JAVA_TOOL -client -Xms128m -Xmx1024m -XX:MaxHeapFreeRatio=60 -XX:MinHeapFreeRatio=30 -XX:+UseSerialGC -XX:+HeapDumpOnOutOfMemoryError -Deap.home="${eapHome}" -cp ${eapHome}"/lib/com.tp-link.eap.start-0.0.1-SNAPSHOT.jar:"${eapHome}"/lib/*:"${eapHome}"/external-lib/*" com.tp_link.eap.start.EapMain start > ${eapHome}/logs/startup.log 2>&1 &

Step 3: Mongo

The EAP Controller is bundled with its own x86 version of mongodb in the bin directory. We will replace them by the raspberry’s compatible binaries:

sudo apt-get install mongodb
cd /opt/tplink/EAP_Controller/bin
rm mongo mongod
ln -s /usr/bin/mongo mongo
ln -s /usr/bin/mongod mongod

Disable autostart of the mongo service at startup using utility tool such as rcconf. You might need to enable autostart of tpeap at startup as well.


Finally, connect the Pi to your own wifi network and reboot it. The tpeap service is very slow to start, taking ~10min on mine. You have now the EAP Controller on a Raspberry Pi!