Skip to content
Leonard edited this page Jan 2, 2020 · 2 revisions

README

(Official) Build guide

These steps are taken from the official build guide in the readme.txt from the latest release.

Install the needed packages

On a debian-based system (upstream uses Ubuntu 14.04.2 i386) install the following packages:

# apt install automake libncurses5-dev libstdc++6-4.4-dev g++ bison flex zlib1g-dev
# dpkg-reconfigure dash # select 'no'
# apt install doxygen build-essential

Setup the build environment

Extract the buildroot and compile lzma:

$ tar xvf toolchain_$VERSION.tar.xz # Replace with your specific version
$ cd toolschain # Yes, with the typo
$ tar -C /opt xvf build.tar.bz2 # Yes, we need this systemwide, the paths are hardcoded in the gcc binaries.
$ cd lzma-XXX # Replace XXX
$ chmod +x configure
$ ./configure --prefix=../local-lzma # Or whereever you want to install it to.
$ make && make install

Afterwards you should have the following layout:

$ ls toolschain
local-lzma/  build.tar.bz2  lzma-XXX/
$ ls /opt
buildroot-gccXXX/

Get the source

In a separate directory, clone or extract the source code to a folder called $srcdir:

$ git clone -b $VERSION https://github.com/LeonardKoenig/DIR882A1-GPL.git # 'DIR882A1-GPL' will be $srcdir

or

$ wget https://github.com/LeonardKoenig/DIR882A1-GPL/archive/$VERSION.tar.gz
$ tar xvf $VERSION

You now should have the following layout in $srcdir:

$ ls $srcdir
config         lib              PatchList  uClibc++         vendors
decompress.sh  linux-3.10.14.x  romfs      uClibc-0.9.33.2
History        Makefile         tools      user

Setup environment variables

With $toolchain referring to the absolute path to the 'toolschain' directory from step 2, we need to add our local lzma to the search path:

$ export PATH=$toolchain/local-lzma/bin/:$PATH

Build the image

Setup the KConfig, build intermediate dependency files and build image:

$ make DIR-882 # Exit and Save config
$ make dep
$ make # parallel make is not supported, unfortunately.

The result will be ./DIR882_uImage.img

Known Issues

  1. Build failes with "Problem while running initial CMake":

    CMake Warning at Modules/FindQt4.cmake:659 (message):
      /usr/bin/qmake reported QT_INSTALL_LIBS as "/usr/lib" but QtCore could not
      be found there.  Qt is NOT installed correctly for the target build
      environment.
    Call Stack (most recent call first):
      Tests/RunCMake/CMakeLists.txt:104 (find_package)
    
    
    CMake Error at /usr/lib64/cmake/Qt5Core/Qt5CoreConfig.cmake:3 (message):
      Qt 5 Core module requires at least CMake version 3.1.0
    Call Stack (most recent call first):
      Tests/RunCMake/CMakeLists.txt:105 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    See also "/home/leonard/Documents/router/DIR882A1-GPL/user/cmake/cmake-2.8.12.2/CMakeFiles/CMakeOutput.log".
    See also "/home/leonard/Documents/router/DIR882A1-GPL/user/cmake/cmake-2.8.12.2/CMakeFiles/CMakeError.log".
    ---------------------------------------------
    Error when bootstrapping CMake:
    Problem while running initial CMake
    ---------------------------------------------
    make[1]: *** [Makefile:38: configure] Error 11
    make[1]: Leaving directory '/home/leonard/Documents/router/DIR882A1-GPL/user/cmake'
    make: *** [Makefile:229: cmake] Error 2
    

    The shipped cmake version under user/cmake/cmake-XXX tries to be smart about detecting Qt when it's not even supposed to be included into the build.

    Fix: I've found that only uncommenting the Qt-parts under Tests able to deactivate that. After running make initially, the source files of cmake are extracted. Now edit Tests/CMakeLists.txt and Tests/RunCMake/CMakeLists.txt and remove all references to Qt. Then run the top-level make again.

  2. Build fails with "cannot use gawk builtin `namespace' as variable name":

    gawk: fatal: cannot use gawk builtin `namespace' as variable name
    make[5]: *** [Makefile:889: errnos-sym.h] Error 2
    make[5]: Leaving directory '/home/leonard/Documents/router/DIR882A1-GPL/lib/libgpg-error/libgpg-error-1.10/src'
    make[4]: *** [Makefile:321: all-recursive] Error 1
    make[4]: Leaving directory '/home/leonard/Documents/router/DIR882A1-GPL/lib/libgpg-error/libgpg-error-1.10'
    make[3]: *** [Makefile:251: all] Error 2
    make[3]: Leaving directory '/home/leonard/Documents/router/DIR882A1-GPL/lib/libgpg-error/libgpg-error-1.10'
    make[2]: *** [Makefile:29: libgpg-error-1.10] Error 2
    make[2]: Leaving directory '/home/leonard/Documents/router/DIR882A1-GPL/lib/libgpg-error'
    make[1]: *** [Makefile:421: _dir_libgpg-error] Error 2
    make[1]: Leaving directory '/home/leonard/Documents/router/DIR882A1-GPL/lib'
    make: *** [Makefile:917: lib_only] Error 2
    

    In the files

    1. lang/cl/mkerrcodes.awk
    2. src/Makefile.am
    3. src/Makefile.in
    4. mkerrcodes.awk
    5. src/mkerrcodes1.awk
    6. src/mkerrcodes2.awk
    7. src/mkerrnos.awk
    8. src/mkstrtable.awk replace all occurances of
    -  sub (/\#.+/, "");
    +  sub (/#.+/, "");

    and namespace with pkg_namespace

  3. Build fails with "C++ preprocessor "/lib/cpp" fails sanity check" for libgmp:

    checking how to run the C++ preprocessor... /lib/cpp
    configure: error: C++ preprocessor "/lib/cpp" fails sanity check
    See `config.log' for more details.
    

    Edit lib/libgmp/makefile and add in the rule for Makefile the definition of the variable CXX:

    Makefile:
        CXX=$(CROSS_COMPILE)g++ AR=$(CROSS_COMPILE)ar AS=... ./configure $(CONFOPTS)
    
  4. Build fails with "'EOF' was not declared in this scope":

    /opt/buildroot-gcc463/usr/bin/mipsel-linux-g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include -g -O2 -c fcgio.cpp -MT fcgio.lo -MD -MP -MF .deps/fcgio.TPlo  -fPIC -DPIC -o .libs/fcgio.lo
    fcgio.cpp: In destructor 'virtual fcgi_streambuf::~fcgi_streambuf()':
    fcgio.cpp:50:14: error: 'EOF' was not declared in this scope
    fcgio.cpp: In member function 'virtual int fcgi_streambuf::overflow(int)':
    fcgio.cpp:70:72: error: 'EOF' was not declared in this scope
    fcgio.cpp:75:14: error: 'EOF' was not declared in this scope
    fcgio.cpp: In member function 'virtual int fcgi_streambuf::sync()':
    fcgio.cpp:86:18: error: 'EOF' was not declared in this scope
    fcgio.cpp:87:41: error: 'EOF' was not declared in this scope
    fcgio.cpp: In member function 'virtual int fcgi_streambuf::underflow()':
    fcgio.cpp:107:35: error: 'EOF' was not declared in this scope
    make[4]: *** [Makefile:311: fcgio.lo] Error 1
    

    The library fastcgio has a bug that surfaces for GCC versions newer than v4.4. Fix this by adding the needed include to lib/fcgio.cpp

    #include <limits.h>
    +#include <cstdio>
    #include "fcgio.h"

Flash image

Since the image is not signed with the D-Link key, it can only be flashed in recovery mode.