How to hack your fonera
This section describes the compilation of the middleware for OpenWrt, a Linux distribution widely used in embedded systems such as La Fonera. The compilation for other Linux-based embedded systems should be pretty similar to the one described here.
First of all, how to obtain a building environment for the cross-compilation process is described. This will provide the libraries, compilers, includes and some other general files needed to smoothly compile our software. Once the building environment is obtained, the compilation process itself is described and installation and running instructions follows.
Point out that you will need to enable SSH access to your La Fonera, this procedure is simple and is step by step explained in Stefans Datenbruch website.
Cross-compilation Environment
To obtain a cross-compilation environment we will need to build an OpenWrt image from the sources. This is so because the available libraries will depend on the image configuration, despite the image itself is not needed and will not be used its building is required.
1.- Download and uncompress the sources, they are available from the OpenWrt website or from its SubVersion repository.
$ svn checkout https://svn.openwrt.org/openwrt/trunk kamikaze
However, for La Fonera you must download its firmware sources instead, from here and use it to build the image.
There is also a OpenWrt-SDK that provides a cross-compiler and a set of scripts to help you packing your application, but an endianness conflict appears, by default it provides Little-endian MIPS compiler and La Fonera requires Big-endian.
$ wget http://download.fon.com/firmware/fonera/latest/fonera.tar.bz2
2.- Configure the desired options. OpenWrt is a whole operating system so the configuration options are quite endless. Here only the ones needed to execute the middleare are mentioned, many others may be useful. Hopefully, a kind user-friendly GUI is provided to dive through the available applications, libraries and drivers, to access it, from the source directory type:
$ make menuconfig
The middleware requires the following non-default libraries to run, make sure they all are included in the image compilation:
- libpthread (Threads management, to be found in Base System menu)
- libstdcpp (Standard C++, to be found in Base System menu)
- libopenssl (Open SSL, to be found in Libraries menu)
Once all the options are properly set, quit the GUI and the system should be ready to be build. A first build can take about one hour depending on the options selected and the machine, so sit tight and be patient.
$ make
Compile
If the compilation process went through without problems, all the needed files will be inside a folder called staging_dir. There you should find the headers, libraries and binaries needed to successfully cross-compile the middleware. To do so a simple and almost ready build script is available, called buildOpenWrt in the trunk folder itself. Only the gap CROSS_DIR need to be filled, with your own staging_dir, so to run the configuration script and compile the MW and all the available plugins just type.
$ buildOpenWrt
Install and run
Once the middelware is compiled and linked the hard part is over. It is not yet packetized so the installation consists in making sure that the target system has all the required dependencies installed and fetch the binary file into the router using HTTP, SCP or your favourite method.
$ ssh root@192.168.102.100
root@192.168.102.100's password:
BusyBox v1.4.1 (2007-09-03 10:39:50 UTC) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
______ __
/\ ___\ /\ \
\ \ \__/ __ ___ __ _ __ __ \_\ \___
\ \ _\/ __`\ /' _ `\ /'__`\/\`'__\/'__`\ /\___ __\
\ \ \/\ \L\ \/\ \/\ \/\ __/\ \ \//\ \L\.\_ \/__/\ \_/
\ \_\ \____/\ \_\ \_\ \____\\ \_\\ \__/.\_\ \ \_\
\/_/\/___/ \/_/\/_/\/____/ \/_/ \/__/\/_/ \/_/
-------------- Fonera 1.5 Firmware (v1.1.1.1) -----------------
* Based on OpenWrt - http://openwrt.org
* Powered by FON - http://www.fon.com
-----------------------------------------------------
root@OpenWrt:~# cd /usr/bin/
root@OpenWrt:/usr/bin#
root@OpenWrt:/usr/bin# wget http://192.168.102.56/tigmw
Connecting to 192.168.102.56 [192.168.102.56:80]
tigmw 100% |*********************************************| 501 KB 00:00:00 ETA
root@OpenWrt:/usr/bin# wget http://192.168.102.56/mw.conf
Connecting to 192.168.102.56 [192.168.102.56:80]
mw.conf 100% |*********************************************| 122 --:--:-- ETA
root@OpenWrt:/usr/bin# chmod 755 tigmw
root@OpenWrt:/usr/bin# tigmw
With this the middleware is properly installed and running, congratulations!
