Skip to content

Cross compiling Click Modular Router for Odin

Luis Sequeira edited this page Apr 29, 2016 · 14 revisions

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

About Click Modular Router

You can find information here http://read.cs.ucla.edu/click/ You can find the code here: https://github.com/kohler/click/

Prepare the toolchain and SDK in the machine where you want to compile

Note: You can skip this step if you have already compiled OpenWRT.

Create the folder were the source will be downloaded (e.g. openwrt )

  ~$ mkdir openwrt
  ~$ cd openwrt

Download the sources from the OpenWrt git (14.07 version):

  ~$ git clone git://git.openwrt.org/14.07/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/

Prepare the variables for cross-compiling

Modify the CC variable in order to make the compiler be the MIPS one (the location of the c compiler):

   ~$ 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.

###Download Click 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/

Copy Odin Agent element

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

Note: Original Odin files are at https://github.com/Wi5/odin-agent/tree/master/src

Copy the files odinagent.hh and odinagent.cc to that directory:

  ~$ cp odin-wi5-agent/src/odinagent.* openwrt/trunk/click/elements/local/

###Run configure If you want to compile Click with Odin, you will need the options --enable-local, --enable-userlevel and --enable-wifi, so use (OpenWrt 14.07):

  ~$ /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/

###Run make 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).

###Result from the compilation process:

  • 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.

Clone this wiki locally