-
Notifications
You must be signed in to change notification settings - Fork 17
Cross compiling Click Modular Router for Odin
UNDER CONSTRUCTION
There is a script that automatically builds an OpenWrt image which you can flash in your AP. It includes Click Modular Router. You can find it here: https://github.com/Wi5/odin-wi5/tree/master/Odin_Wi5_firmware_build
You can find information here http://read.cs.ucla.edu/click/ You can find the code here: https://github.com/kohler/click/
Note: You can skip this step if you have already an environment for compiling OpenWrt.
Create the folder were the source will be downloaded (e.g. openwrt )
~$ mkdir openwrt
~$ cd openwrt
Download the sources from the OpenWrt git (15.05 version):
~/openwrt$ git clone git://git.openwrt.org/15.05/openwrt.git trunk
and compile them with make
. As a result, this machine will have a complete OpenWrt toolchain and SDK including the sources in the directory ~openwrt/trunk/
Modify the CC
variable in order to make the compiler be the MIPS one (the location of the c compiler). Note: the name of the user in this example is 'proyecto':
~$ export CC=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc
Modify CXX
(the location of the c++ compiler):
~$ export CXX=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
Add this to the path:
~$ export PATH=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/:$PATH
Modify the STAGING_DIR
variable:
~$ export STAGING_DIR=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/
Use $set
to see the values of the variables and confirm that they have been changed.
Example. If your user name is proyecto
, in an OpenWrt 15.05, with a compiling directory called ‘openwrt’ you should run this:
export CC=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc
export CXX=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++
export PATH=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/:$PATH
export STAGING_DIR=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/
set
Download Click router source code to the directory:
~$ cd openwrt/trunk/
First, download the whole Click code:
~$ git clone git://github.com/kohler/click.git click
If you want to add some features to click (e.g. odin agent), you should add them to ~/openwrt/trunk/click/elements/local/
.
So now download the last version of the Odin elements from the repository (select the correct branch with the –b
option. master
branch is selected by default):
~$ git clone git://github.com/Wi5/odin-agent.git
Or (Development
branch):
~$ git clone git://github.com/Wi5/odin-agent.git -b Development
Note: Original Odin files are at https://github.com/Wi5/odin-agent/tree/master/src
Copy the files odinagent.hh
and odinagent.cc
to ~/openwrt/trunk/click/elements/local/
directory:
~$ cp odin-agent/src/odinagent.* ~/openwrt/trunk/click/elements/local/
If you want to compile Click with Odin, you will need the options --enable-local
, --enable-userlevel
and --enable-wifi
, so use (for OpenWrt 15.05). Note: the name of the user in this example is 'proyecto':
~$ /openwrt/trunk/click# ./configure --disable-app-fuzzer --disable-app-performance --disable-app-sniffer --enable-app-tunnel --disable-app-stats --disable-doc --disable-doc-man --enable-local --enable-userlevel --enable-wifi --host=mips-unknown-elf --build=mips --prefix=/home/proyecto/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/ --with-linux=/home/proyecto/openwrt/trunk/build_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/linux/
Note: You may see a message configure: WARNING: unrecognized options: --disable-app-fuzzer, --disable-app-performance, --disable-app-sniffer, --enable-app-tunnel, --disable-app-stats, --disable-doc, --disable-doc-man
. It is not important.
Build the list of elements:
~/openwrt/trunk/click$ make elemlist
For compiling Click, run make:
~/openwrt/trunk/click$ make
Note: if you want to rebuild click, run make clean
inside click directory:
~/openwrt/trunk/click$ make clean
You may obtain an error stating that click-mkmindriver could not be compiled
. However, it is not important since this application is not necessary to run Click: "the click-mkmindriver tool generates a build environment for a minimal Click driver -- that is, a driver containing only the elements necessary to run the configurations in the router-files” (http://www.read.cs.ucla.edu/click/docs/click-mkmindriver).
- The application
click
is generated in~/openwrt/trunk/click/userlevel
- The application
click-align
is generated in~/openwrt/trunk/click/tools/click-align
. If it is not generated (because of an error), enter in the~/click/tools/click-align
directory and run$make
- After compilation, an entry odinagent.cc should be found in
~/openwrt/trunk/click/userlevel/elements.conf
. Otherwise, it means that the odin element has not been found.
After cross-compiling click
and click-align
binaries, they have to be copied to the Wi-Fi routers.