Dienstag, 22. November 2011

Cross Compiling Netatalk 2.2.1 for DD-WRT on Ubuntu 11.10

Here is an update on how to cross compile netatalk for dd-wrt. Once again I have my Netgear WNR3500L as my target device. I recently upgraded to Ubuntu 11.10 which to my surprise works pretty good! I am very satisfied with  it. But let's get started. Fire up you terminals.

In case you want to take a shortcut here are the modified makefiles:

netatalk.mk
libdb.mk


If you did not already do so you have to install  bison, flex, texinfo and subversion:


> sudo apt-get install bison flex texinfo subversion


Now we can retrieve the optware packages und install our toolchain. Change to a directory you want this workspace located and execute:

> svn co http://svn.nslu2-linux.org/svnroot/optware/trunk optware



Setup the target environment once the checkout returns successfully:


> cd optware
> make ddwrt-target
> cd ddwrt
> make directories ipkg-utils toolchain



Note: the target depends on your router and the build of dd-wrt you have installed! The dd-wrt-target happens to fit in this case. Read up on what target system you need before starting out!


The compiling of the toolchain might take some time. I ran into some trouble building the toolchain. In two cases the packages were not found. For the binutils package I changed to a different mirror. In order to do so I modified the binutils.mk in optware/ddwrt/toolchain/buildroot/toolchain/binutils/. I replaced all references of the kernel.org site with http://ftp-stud.hs-esslingen.de/Mirrors/ftp.kernel.org/pub/linux/devel/binutils/. Beware this mirror might change in the future. A more suitable fix should be used. This was just a quick fix!


Also I had to change the version indicator for the gdb package. The character 'a' was appended. I updated the gdb.mk file in optware/ddwrt/toolchain/buildroot/toolchain/gdb/ to reflect this modification (around line 8):


GDB_SOURCE:=gdb-$(GDB_VERSION)a.tar.bz2


Now we can get started. First we need to build the dependencies (openssl, libgcrypt and libdb):


> make openssl-stage
> make libgcrypt-stage


I use libdb 4.7.25. In order to build that particular version I altered the libdb.mk in optware/ddwrt/make/:


LIBDB_VERSION=4.7.25
LIBDB_LIB_VERSION=4.7



Secondly we need to add a configuration flag (around line 127):

--with-mutex=MIPS/gcc-assembly \

This configuration flag is important so libdb is not linked against libpthread. When this flag is not set libdb will not play nice with netatalk and OS X will create a warning each and every time you want to access a share. Save the changes and compile!



> make libdb-ipk
> make libdb-stage


Next we modify the netatalk.mk file in optware/ddwrt/make/ to reflect the new version. Also I disabled one patch and added support for the cnid-cdb-backend:


NETATALK_VERSION=2.2.1 #(around line 8)


NETATALK_PATCHES +=#$(NETATALK_SOURCE_DIR)/afp_asp_include.patch #(around line 55)


--with-cnid-cdb-backend \ #(around line 149)



#$(PATCH_LIBTOOL) $(@D)/libtool #(around line 162)
#sed -i -e "s/db_strerror/db_strerror$(DB_VERSION)/g" $(@D)/etc/cnid_dbd/dbif.c
#sed -i -e "s/db_create/db_create$(DB_VERSION)/g" $(@D)/etc/cnid_dbd/dbif.c
#sed -i -e "s/db_env_create/db_env_create$(DB_VERSION)/g" $(@D)/etc/cnid_dbd/dbif.c
#touch $@



That should be it. Build the netatalk 2.2.1 ipk:


> make netatalk-ipk


In optware/ddwrt/builds the netatalk_2.2.1-2_mipsel.ipk should have appeared. Transfer the package to you router and proceed with the install. Remove the previous version of libdb first and install the new libdb package:


> ipkg install libdb_4.7.25-3_mipsel.ipk


Then backup your netatalk settings for they will be replaced. Mine are in /opt/etc/netatalk/. Upgrade the previous netatalk version to the new one.


> killall afpd
> ipkg install netatalk_2.2.1-2_mipsel.ipk


Now you can restore your settings and start netatalk again:


> afpd -D

7 Kommentare:

  1. Good information. I'm trying to replicate but run into trouble at the end of 'make toolchain'

    AntwortenLöschen
  2. What kind of trouble do you run into, mate?

    AntwortenLöschen
  3. Hard to say since the output from the build process is so extensive, I've given up on my ordinary Opensuse environment. Instead I put up Ubuntu on a VM instead to have an identical environment as you and made some progress. The toolchain is now in place but I fail miserably when trying to build a customized version of php. Seem to be a problem with the php.mk file, it seems the process fail when building the actual ipkg-package . I tried to build a random package and that worked.

    AntwortenLöschen
  4. Came through with Ubuntu 8.04 LTS which is the recommended environment at www.optware-project.org
    Seems the build of php is very sensitive to the build environment. Suspect libtool, automake and autoconf must be the *right* version.
    I had to install g++, ncurses5-dev to make things compile. Also used:
    svn co -r 12529 http://svn.nslu2-linux.org/svnroot/optware/trunk optware
    to setup the crosscompiler

    AntwortenLöschen
  5. Well done and thanks for sharing wabe! :)

    AntwortenLöschen
  6. When I cross compile I am getting
    ../../include/atalk/atp.h:96: error: field 'atpbuf_addr' has incomplete type
    ../../include/atalk/atp.h:105: error: field 'atph_saddr' has incomplete type
    ../../include/atalk/atp.h:188: warning: 'struct at_addr' declared inside parameter list
    ../../include/atalk/atp.h:188: warning: its scope is only this definition or declaration, which is probably not what you want

    AntwortenLöschen
    Antworten
    1. Hi Bala!

      Did you try using the newest version yet? Netatalk 2.2.2 is out... maybe the error disappears *fingers crossed* :)

      Löschen