It is interesting deploying a small router using OpenWRT, turn a $20 into a multipurpose box. But, can we extend it’s awesomeness to something more? Yes, we can. We can write and develop an application for running inside of OpenWRT. Creating our own OpenWRT application in fact is not so difficult to do.
OpenWRT utilize machine with different architecture and system compared to our machine. Therefore, we can’t use our gcc on our machine to build an OpenWRT application. To do so, we will build the suitable compilers and other utils. In other words, we will create a cross-toolchain.
In this article, we will discuss about preparing environment for developing OpenWRT’s application. The language used for development is C\C++ and the IDE used will be Eclipse.
For this article I use:
- Slackware64 14.0
- OpenWRT Buildroot
- Eclipse Juno
For simplicity, we will break down the set up into smaller categories.
OpenWRT Buildroot Installation
OpenWRT Buildroot is a set of Makefiles and patches that allows us to easily generate both a cross-compilation toolchain and a root filesystem for embedded systems, especially OpenWRT. The OpenWRT buildroot is a heavy modification of Buildroot. The cross-compilation toolchain uses uClibc, a tiny C standard library.
- 350MB of hard disk space for source files to download.
- 3-4GB of available hard disk space for building process (OpenWRT).
Another things to prepared are packages for building the Buildroot. Make sure we have these all:
- GNU awk (gawk)
- working sdcc
Assume our build directory will be on ~/openwrt and when it is done, the cross-toolchain will be installed on /opt/OpenWRT.
Before proceeding, make sure you have svn installed!
First we need to create the working directory ~/openwrt and download the required source code form svn repository. It should be around 14.382 files with overall size of 150MB.
Now, do these commands as non-root user.
mkdir ~/openwrt cd ~/openwrt svn co svn://svn.openwrt.org/openwrt/trunk/ cd trunk
Check the missing packages on system used for building OpenWRT on. Use one of the following ommands:
make defconfig make prereq make menuconfig
Eclipse will act as our development environment. If you don’t install it yet, you should install it. You can follow this article for Eclipse installation on Linux.
Once Eclipse installed, all we have to do is install additional eclipse packages.
Start eclipse. Now navigate to:
Help -> Install New Software -> Add
enter the following information:
Name: Juno Download Location: http://download.eclipse.org/releases/juno/
Click on OK. Now expand the Mobile and Device Development section and check the C/C++ GCC Cross Compiler Support and Remo System Explorer End-User Runtime. Click Next to begin installation. After installation you will be prompted to restart the eclipse, do so.eclipse, embedded, linux, openwrt