DiskStation Toolchains¶
Toolchains to compile your own stuff.
Introduction¶
Many (e.g. the Optware folks) seem to prefer cross-compiling. I prefer native compiling, i.e. compiling stuff directly on the Diskstation. While this may not be the fastest and most optimal way, it works pretty well for me (e.g. SSODS is made like this). I do this using the Embedded Linux Development Kit (ELDK).
Synology now offers toolchains and a manual for all Diskstations in the 3rd party application integration guide.
And EmbDebian has a good cross-toolchain, too. See also guruplug debian.
How to use ELDK to compile stuff on the Diskstation¶
I have been asked this question several times. So here is a short introduction.
A working toolchain which targets the Synology system would be optimal. I don’t know if Synology’s include all necessary headers and libraries, which would be necessary. With the new Optware (for Marvell/ARM based Diskstations) we probably have one now (see software for details).
However, I use a completely different approach.
I use the Embedded Linux Development Kit (ELDK). There are versions for ppc and arm. Usually one installs this on a Linux (i386) host and the cross-compiles stuff. I don’t do that either.
ELDK includes a minimal target system which includes the usual tools (ls
, rm
, etc.) as well as a GCC. Usually one mounts this target system as the root FS on the (embedded) target host via NFS.
I just copied the whole system (directory tree) on my DS, mount /proc
and chroot(1) into it. Then I compile stuff using a few special configure/GCC flags. They are:
CFLAGS=-I/volume1/SSODS/include -O2 CPPFLAGS=-I/volume1/SSODS/include -O2 LDFLAGS="-L/volume1/SSODS/lib -L/volume1/SSODS/lib_eldk -Wl,-dynamic-linker,/volume1/SSODS/lib_eldk/ld.so.1 -Wl,-rpath,/volume1/SSODS/lib_eldk:/volume1/SSODS/lib" PATH=/volume1/SSODS/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin LD_LIBRARY_PATH=/volume1/SSODS/lib
And then, inside the chroot, the following will do for most programs:
./configure --prefix=/volume1/SSODS make make install
Furthermore I copy the necessary libraries (basically the contents of ELDK’s /lib
, consisting mainly of the glibc and the GCC libs) to /volume1/SSODS/lib_eldk
.
Check $LDFLAGS
above: I set the dynamic linker (the ELF loader, or whatever that is called) to /volume1/SSODS/lib_eldk/ld.so.1
and set the default rpath (library search path) to my two library dirs /volume1/SSODS/lib_eldk:/volume1/SSODS/lib
.
Once everything is compiled (and stripped and cleaned up) I copy the /volume1/SSODS
directory from the chroot to the real root and the binaries will use the libc from ELDK. I don’t need to set any $LD_LIBRARY_PATH
or paths in /etc/ld.so.conf
.
This has two advantages:
- My binaries are completely independent from the DS› system, they just depend on the kernel.
- My libraries do not interfere with the DS programmes (which was the case with earlier versions of SSODS where I used
/etc/ld.so.conf
). Listing own library dirs in/etc/ld.so.conf
is a bad idea since can render internal functionality unusable due to conflicting library versions.
The main disadvantage is that it is probably not optimal. E.g. the arm compiler in ELDK does not (yet) support the Marvell CPU fully (no floating point stuff, maybe less optimal code generation). It should be ok for ppc, though. And there a few things which don’t work. E.g. I never got netcat(1) running properly, both on the arm and the ppc DS. It can connect but it cannot listen. Don’t know why.
You can download ELDK, install it on a Linux (i386) box and transfer the target root to the DS and use it as the chroot. Or you just download the chroots below:
- eldk-target-bin-arm-2007-01-21.tar.gz (152 MB)
- eldk-target-bin-ppc-2007-01-19.tar.gz (104 MB)
- goeldk.sh (1kb) – a handy script to start an ELDK chroot.
- debian-lenny386.tar.bz2 (176 MB)
- eldk-target-bin-arm-2008-11-24.tar.bz2 (149 MB)
- eldk-target-bin-armVFP-2008-11-24.tar.bz2 (145 MB)
- eldk-target-bin-ppc_85xx-2008-04-01.tar.bz2 (176 MB)
- eldk-target-bin-ppc_4xx-2008-04-01.tar.bz2 (175 MB)
- eldk-target-bin-ppc_4xxFP-2008-04-01.tar.bz2 (173 MB)
Links¶
- http://www.golden-gryphon.com/blog/manoj//miscellaneous/build_cross_toolchain.html
- http://www.kegel.com/crosstool/