How to compile own kernel for DNS-313

This website has been moved to


Forum provides few threads and posts in different places about compiling own kernel. I tried use it but unsuccessfuly. Unfortunately all people who compiled own kernel didn’t share their .config. I decided to describe for everyone step by step how to do it. If don’t want to play, or just don’t have enough knowledge please feel free to download my kernel. My configuration works for sure with DNS-313 rev A. I have no idea what is the difference beetwen A and B revision (Amount of memory and?). I guess that is possible to adjust it with little effort.

Installing own linux

First time when I tried to compile my kernel I thought that I have to do it under ARM. You don’t. Everything what we need is some piece of i386 architecture linux – any distro even you don’t need any developer stuff. Rest files you can download from D-Link ftp server and run it in chroot jail.

Build evironment

First we should download GPL Source Code for Firmware v1.01 which provides toolchain, compilers, and kernel source.

lenovo src # cd /usr/src

lenovo src # wget

lenovo src # ln -s Gemini_v2_6_3-n_BSP linux-arm

lenovo src # wget

lenovo src # wget

lenovo src # tar xzvf dns313v1.01_GPL_20080723.tgz -C /usr/src

lenovo src # tar zxvf image_tools.tgz -C linux-arm/root

lenovo src # unzip -d linux-arm/root/

Next download .config file from here and copy to kernel source.

lenovo src # cp .config linux-arm/source/kernel/linux

Chroot and move on!

lenovo src # chroot linux-arm

bash-2.05b# cd /source/kernel/linux

bash-2.05b# make clean

bash-2.05b# make menuconfig

just exit and write changes and finally:

bash-2.05b# make -j3 zImage

(-j means compile in few threads) after couple of minutes when zImage be ready copy it to root for further processing

bash-2.05b# cp arch/arm/boot/zImage /root/zImage_noheader

In next section few words about headers.

Removing/adding headers

Raw zImage is not going to be bootable. It needs to add some headers. Wecan do that using tool called mkimage. It uses kernel.cfg where you can change version for your number. Idea is that you have to have 3 files with the same header: zImage, rootfs.gz and rd.gz. Then all of them should be in .boot/ folder.

You can copy rd.gz and rootfs.gz from your existing dns-313 debian installation or downloaded latest firmware like in this case. You are still in chroot.

Removing header from firmware:

bash-2.05b# dd if=DNS-313_A2__FW_1.04 bs=8 skip=13 of=DNS-313_A2__FW_1.04.tar

bash-2.05b# tar xvf DNS-313_A2__FW_1.04.tar





For us usefull is only rootfs.tgz and rd.gz. Let remove headers from them.

bash-2.05b# dd if=rd.gz bs=8 skip=13 of=rd_noheader.gz

bash-2.05b# dd if=rootfs.gz bs=8 skip=13 of=rootfs_noheader.gz

Edit kernel.cfg and set some common version.

Now it is time to add our headers:

bash-2.05b# image_tools/mkimage -f image_tools/kernel.cfg -d zImage_noheader zImage

bash-2.05b# image_tools/mkimage -f image_tools/kernel.cfg -d rd_noheader.gz rd.gz

bash-2.05b# image_tools/mkimage -f image_tools/kernel.cfg -d rootfs_noheader.gz rootfs.gz

First part of success…

Now copy zImage, rd.gz and rootfs.gz to .boot directory on your DNS-313.

Restart disk and wait few minutes. It takes some time but finally you should see green led.


My .config contains kernel support for:

  • NFS,
  • vfat,
  • central europe codepages
  • ext3
  • fuse – I preffer ntfs-3g instead of NTFS kernel support

Everything is compiled into kernel. No modules.

If you want to add someting, do it carefully and be minimalist. Change only one thing and try to compile again (even boot).

You can learn how to make own firmware by studying this image GPL Source Code for Firmware v1.00 There are applications and kernel sources for DNS-313. Next step is trying the same with much newer kernel. I have already tried with 2.6.24, I got image bud unfortunately it doesn’t boot up properly. Investigation is on going. Chaotic descriptions are my special. If something is not clear just a comment. 🙂

Links <-GPL stuff for D-link devices <- where everything has begun…


9 thoughts on “How to compile own kernel for DNS-313

  1. Pingback: How to compile own kernel for DNS-313 « owcapage | Linux Affinity

  2. Hi,
    Sorry for my english, i am a french man.

    When i do a ‘chroot linux-arm’, i have this error message : must be installed for pthread_cancel to work
    H>elp me please.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s