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

howto:crosscompile 2011/05/10 22:51 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/|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/|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 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 =====


Personal Tools