Skip to content

Building the code for OpenWRT ar71xx

Saumitra Aditya edited this page Apr 24, 2015 · 14 revisions

These are the build instructions for the OpenWRT D-LINK DIR-505 that we have purchased from Amazon for testing. Click here for instructions on how to flash your router.

Go on the Building the code for Linux page and follow the instructions for the first two sections:

  • Download dependencies
  • Download source code

Download OpenWRT toolchain

  1. Install dependencies

    sudo dpkg --add-architecture i386; sudo apt-get update
    sudo apt-get install ccache libncurses5-dev zlib1g-dev gawk unzip libc6:i386 libstdc++6:i386 zlib1g:i386
  2. Go to trunk/third-party directory and download OpenWRT SDK for openwrt ar71xx

    cd ../../third-party
    wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2
    tar xjvf OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2
  3. Set up OpenWRT environmental variables

    export OPENWRT_SDK=`pwd`/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2
    export STAGING_DIR=$OPENWRT_SDK/staging_dir
    export TOOLCHAIN=$STAGING_DIR/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/
    export CC="$TOOLCHAIN/bin/mips-openwrt-linux-uclibc-gcc"
    export CXX="$TOOLCHAIN/bin/mips-openwrt-linux-uclibc-g++"
    export AR="$TOOLCHAIN/bin/mips-openwrt-linux-uclibc-ar"
    export CC_host="gcc"
    export CXX_host="g++"
    export GYP_DEFINES="target_arch=mips use_openssl=1"
  4. Install libexpat for OpenWRT toolchain

    cd $OPENWRT_SDK
    svn export svn://svn.openwrt.org/openwrt/branches/packages_12.09/libs/expat package/expat; make
    cp build_dir/target-mips_r2_uClibc-0.9.33.2/expat-2.0.1/.libs/libexpat.a $TOOLCHAIN/lib
    cp build_dir/target-mips_r2_uClibc-0.9.33.2/expat-2.0.1/lib/*.h $TOOLCHAIN/include/
    cp -r /usr/include/X11 $TOOLCHAIN/include/
    cd ../../

##Some miscellaneous tricks to get things working

Comment out the "latebindingsymbol" source in trunk/talk/libjingle.gyp so no ninja files are created for it.

   ['os_posix==1', {
       'sources': [
         #'base/latebindingsymboltable.cc',
         #'base/latebindingsymboltable.h',
         'base/posix.cc',
         'base/posix.h',
         'base/unixfilesystem.cc',
         'base/unixfilesystem.h',
       ],

Build ipop-tincan for OpenWRT

  1. Create ninja build files

    gclient runhooks --force
  2. Update ninja build files to use -msoft-float and -fno-stack-protector

    sed -i 's/mhard-float/msoft-float/g' `find out/Release -name *.ninja`
    sed -i 's/fstack-protector/fno-stack-protector/g' `find out/Release -name *.ninja`
    sed -i 's/mhard-float/msoft-float/g' `find out/Debug -name *.ninja`
    sed -i 's/fstack-protector/fno-stack-protector/g' `find out/Debug -name *.ninja`
  3. Update some files file

    wget https://github.com/pstjuste/ipop-tincan/raw/75e2c5fae7b6375ef2ead4a93595275492a6a259/build/typedefs.h
    wget https://github.com/pstjuste/ipop-tincan/raw/75e2c5fae7b6375ef2ead4a93595275492a6a259/build/ipop-tincan.ninja
    move typedefs.h webrtc/typedefs.h
    move ipop-tincan.ninja out/Release/obj/talk/ipop-tincan.ninja
    cd ..
    
  4. Build tincan for OpenWrt (binary located at out/Release/ipop-tincan)

    ninja -C out/Release ipop-tincan
  5. To build debug version with gdb symbols (but creates 25 MB binary)

    ninja -C out/Debug ipop-tincan
  6. The generated binary is located at out/Release/ipop-tincan or out/Debug/ipop-tincan

Download controllers

  1. Download socialvpn and groupvpn controllers

    wget http://github.com/ipop-project/socialvpn/raw/master/src/svpn_controller.py
    wget http://github.com/ipop-project/groupvpn/raw/master/src/gvpn_controller.py
    
Clone this wiki locally