Table of Contents
Toolchain to develop software for DNS-300
Toolchain is set of tools to compile software for some device/platform.
Two types of toolchains are possible:
- toolchain for crosscompile - to compile software on PC compatible computer
- native toolchain - to compile software directly on DNS-300
I've created my toolchains using following software:
- binutils-2.17
- gcc-4.1.1
- glibc-2.2.5 (binaries from OpenRG toolchain)
- header files for glibc-2.2.5 from OpenRG toolchain
- Linux kernel header files from DLink's Linux kernel for DNS-312H
I've created this manual some time later after successful creating of toolchain, so I can forget something…
Toolchain for crosscompile
How to create Crosscompile toolchain
Prepare directories structure
mkdir -p /opt/src mkdir -p /opt/build mkdir -p /opt/toolchain mkdir -p /opt/toolchain-native
Create symlinks for native compiler
cd /usr/bin/ ln -s ar i686-pc-linux-gnu-ar ln -s as i686-pc-linux-gnu-as ln -s cpp i686-pc-linux-gnu-cpp ln -s gcc i686-pc-linux-gnu-gcc ln -s gcov i686-pc-linux-gnu-gcov ln -s ld i686-pc-linux-gnu-ld ln -s ldd i686-pc-linux-gnu-ldd ln -s nm i686-pc-linux-gnu-nm ln -s objcopy i686-pc-linux-gnu-objcopy ln -s objdump i686-pc-linux-gnu-objdump ln -s ranlib i686-pc-linux-gnu-ranlib
Configure and make binutils
cd /opt/src tar -xzf ./binutils-2.17.tar.gz mkdir -p /opt/build/bilutils-2.17 cd /opt/build/binutils-2.17/ ../../src/binutils-2.17/configure \ --prefix=/opt/toolchain \ --target=armv4lt-dns300-linux \ --with-sysroot=/opt/toolchain-native/usr/local/ make make install
Configure GCC
cd /opt/src tar -xzf ./gcc-4.1.1.tar.gz mkdir -p /opt/build/gcc-4.1.1-cross cd /opt/build/gcc-4.1.1-cross/ PATH=/opt/toolchain/bin:$PATH \ ../../src/gcc-4.1.1/configure --prefix=/opt/toolchain \ --build=i686-pc-linux-gnu \ --host=i686-pc-linux-gnu \ --srcdir=../../src/gcc-4.1.1 \ --with-sysroot=/opt/toolchain/armv4lt-dns300-linux \ --with-as=/opt/toolchain/bin/armv4lt-dns300-linux-as \ --with-ld=/opt/toolchain/bin/armv4lt-dns300-linux-ld \ --enable-languages=c \ --target=armv4lt-dns300-linux \ --with-build-time-tools=/opt/toolchain/armv4lt-dns300-linux/bin \ --with-float=soft \ --disable-multilib
To be continued…
Native toolchain for DNS-300
I've compiled native toolchain by my crosscompile toolchain. Maybe sometime, I'll describe compilation procedure, but now you can just download my native toolchain and use it.
How to install native toolchain
- First you should have installed IPKG package libfloat, because it's necessary for my toolchain
- Download my archive http://dns-300.sergeyzh.org/files/dns300-toolchain-1.1.tar.gz
- Copy archive to DNS-300.
- Unpack this to somewhere. For example I have it in
/home/sergey/toolchain/
.
cd /home/sergey/toolchain ; tar -xzf dns300-toolchain-1.1.tar.gz
- Create symbolic link /opt/toolchan-native/ pointing to your unpacked toolchain.
For my system it is command:ln -s /home/sergey/toolchain /opt/toolchain-native
How to use native toolchain
Note: my toolchain contains only compiler + gcc libraries from OpenRG. To compile most programs you should compile and install additional binaries like: awk, automake, findutils, etc…
- Add path to toolchain to PATH.
export PATH=/opt/toolchain-native/usr/local/bin:$PATH
- Run gcc. You should see message:
root@DNS-300:/# gcc gcc: no input files root@DNS-300:/#
So now you can use GCC to compile very simple programs, like hello-world.c. To compile complex project you should compile additional binaries. First try to compile sed to test.
How to compile sed for Toolchain
- Download sed archive from GNU FTP.
- Unpack it somewhere. For example:
/home/sergey/src/sed/
- Configure this with your toolchain.
./configure --prefix=/opt/toolchain-native/usr/local/
- Compile this:
make
- Install this:
make install
. This step is unecessary, because toolchain contains sed already, but you can test how 'install' works.
How to compile something to use with IPKG system
- Configure source with –prefix=/home/root/opt/usr , because other programs in IPKG for DNS-300 are compiled with the same prefix.
- Install your program into /home/root/…, by
make install
- Test your program.
- Create IPKG module for this.