Differences

This shows you the differences between the selected revision and the current version of the page.

howto:crosscompile 2009/11/03 14:13 howto:crosscompile 2017/09/06 18:38 current
Line 1: Line 1:
====== Cross Compile Environment for DNS-323 ====== ====== Cross Compile Environment for DNS-323 ======
 +
 +===== Pre-compiled Binaries =====
 +
 +If, for whatever reason, you cannot compile the source code below, pre-compiled binaries are available from the uClibc website [[http://uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-armv5l.tar.bz2|here]] as of May 17th. You can also download a native compiler, to compile programs for the device, on the device [[http://uclibc.org/downloads/binaries/0.9.30.1/mini-native-armv5l.tar.bz2|here]]. The cross-compiler is around 55MB when unpacked, and the native compiler around 35MB.
 +
 +To set up the build environment, you simply need to un-tar the files and add the necessary folders to the PATH:
 +
 +For the cross-compiler ('user' is an example username):
 +<code bash>cd /home/user
 +tar xjf cross-compiler-armv5l.tar.bz2
 +rm cross-compiler-armv5l.tar.bz2
 +export PATH=/home/user/cross-compiler-armv5l/bin:$PATH</code>
 +Then you would compile programs with armv5l-tool, e.g. armv5l-gcc
 +
 +If you are using configure/make programs, you will need to follow the documentation for cross-compilation. You will also want the programs to be installed in a different directory from /usr/local so you can copy them later. For GNU and compatible programs, it is usually this:
 +<code bash>export CC=armv5l-gcc
 +./configure --host=arm-unknown-linux --prefix=/home/user/arm # example directory
 +make
 +make install</code>
 +
 +For the native compiler:
 +<code bash>cd /mnt/HD_a2
 +tar xjf mini-native-armv5l.tar.bz2
 +rm mini-native-armv5l.tar.bz2
 +export PATH=/mnt/HD_a2/mini-native-armv5l/usr/bin:$PATH</code>
 +Then you would compile programs simply with the normal tool name e.g. gcc
 +
 +Oh, I might point out, these images actually use newer versions of the source components than D-Link used.
 +
 +==== __cxa_atexit error ====
 +
 +You might get this error when using make with the native compiler. You can either download a patched version here: {{:download:make.gz}} or recompile make, adding the following line to main.c after the includes:
 +<code c>int __cxa_atexit(void (*func) (void *), void * arg, void * dso_handle){}</code>
 +
 +==== Cross vs Native compile ====
 +
 +Since the DNS-323 has only a 400MHz processor, configuring and compiling programs can be a slow process, usually slow enough that you won't be able to just sit there while it processes, but not so slow you have to do something else entirely or leave it on overnight. Native compiling has the advantage of building programs that exactly match the specifications of the device, only linking to libraries that are present, and warning of any errors properly.
 +
 +A cross-compiler takes advantage of your PC's CPU, meaning that it will work a lot faster, however the end result might not work 100% on the device. You also need to ensure that the program you are compiling is properly configured for cross-compilation to ARM devices.
 +
 +An ideal solution would be to emulate the DNS-323 architecture and kernel, but at much faster speeds. I haven't managed to do this with qemu, it is just as slow as the device itself.
 +
 +Usually the best solution, if you are compiling large programs, is to construct your own configuration file, check all the dependencies manually, ensure libraries are linked dynamically, then cross-compile it.
===== Firmware 1.05 ===== ===== Firmware 1.05 =====
Line 9: Line 52:
tar zxvf dns323_GPL.tgz tar zxvf dns323_GPL.tgz
cd dns323_GPL</code> cd dns323_GPL</code>
 +
Line 30: Line 74:
</code> </code>
-Now you are ready to build the toolchain, but dont forget to set a symolic link back to ''/usr/bin/gcc-4.3'' when it's finished. +Now you are ready to build the toolchain, but dont forget to set a symbolic link back to ''/usr/bin/gcc-4.3'' when it's finished.
Line 163: Line 207:
then continue with instructions for firmware 1.05 above. then continue with instructions for firmware 1.05 above.
 +- didn't work for me, it generated "32-bit, no machine" executables, which of course, can't be executed on i686.
 +<code>
 +# workaround (just remove --build= and --host= from ./configure options):
 +sed -i.old 's/--build=$(GNU_HOST_NAME) \//g' make/gcc-uclibc-3.3.mk
 +sed -i.old 's/--host=$(GNU_HOST_NAME) \//g' make/gcc-uclibc-3.3.mk
 +
 +# for binutils too
 +sed -i.old 's/--build=$(GNU_HOST_NAME) \//g' make/binutils-uclibc.mk
 +sed -i.old 's/--host=$(GNU_HOST_NAME) \//g' make/binutils-uclibc.mk
 +</code>
__Note:__ to compile (optware-)packages for the DNS323, the correct **./configure** parameter is **-- --host=arm-linux-uclibc**. at least that worked for me... __Note:__ to compile (optware-)packages for the DNS323, the correct **./configure** parameter is **-- --host=arm-linux-uclibc**. at least that worked for me...
__Another note:__ i set this up with ubuntu 9.04 in a virtual machine (vmware, any other flavour should do too) and did a snapshot of the working environment. gives me a fully operational and (in a certain way) portable solution for cross compiling. __Another note:__ i set this up with ubuntu 9.04 in a virtual machine (vmware, any other flavour should do too) and did a snapshot of the working environment. gives me a fully operational and (in a certain way) portable solution for cross compiling.
 +
 +__And yet another note:__ For 1.6, you need also to comment out or remove the 'gdb' target in gcc-uclibc-3.3.mk, i.e. before making, run:
 +<code>
 +sed -i.old 's/gdb//' make/gcc-uclibc-3.3.mk
 +</code>
 +
===== Firmware ?.?? ===== ===== Firmware ?.?? =====
**Please feel free to update, cleanup or correct this page** **Please feel free to update, cleanup or correct this page**
 +
 +**Note**: The **wget-gpl** script now no longer works: instead the GPL directory has a readme file redirecting you [[http://www.dlink.com/support/gpl/|here]]. The actual GPL files are found [[ftp://gpl.dlink.com/|here]], with the DNS-323 specific file [[ftp://gpl.dlink.com/DNS-323/dns323_GPL_v1.08_12182009.tgz|here]] as of May 10th. Simply copy this file into GPL/zips and continue.
What is this? What is this?

Navigation

Personal Tools