HowTo Build Your Own Custom Kernel

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 23:04, 13 August 2009 by Smiley (Talk | contribs)

Jump to: navigation, search


Two Ways to Compile a Kernel

There are two ways to build a custom kernel for the LinkStation/Kurobox. If you have access to an i686 host running some flavor of Linux, you can cross-compile a kernel for ARM9 on an i686 host. Alternatively, if your NAS has enough RAM, you could compile the kernel on the NAS itself, using the system's native gcc. Both ways of these approaches to building a custom kernel are described in the instructions that follow.

Cross-compiling a Custom Kernel

Download All the Required Tarballs

To use the cross toolchain to compile a kernel for ARM9, you'll need access to an i686 host running some flavor of Linux. First, download the cross toolchain (arm-2005q3-2-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2), mkimage, and the source archive (linux-2.6.12_lsp.1.7.8.tgz):

$ cd /some_directory
$ wget -H -c
$ wget -H -c
$ wget -H -c

If the files were not at the locations indicated above, fear not! Just look in every directory on the server (like I did).

Prepare the Environment

Then, install (i.e., untar) the toolchain and mkimage:

$ cd /some_path
$ tar -xjf /some_directory/arm-2005q3-2-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
$ cd bin
$ export PATH=`pwd`:$PATH
$ cp -p /some_directory/mkimage .
$ chmod a+rx mkimage

Strictly speaking mkimage should not go into /some_path/bin. But, hey...

Now untar the source of the kernel in some directory:

$ cd /some_directory
$ tar -xzf linux-2.6.12_lsp.1.7.8.tgz
$ cd linux-2.6.12_lsp.1.7.8

Ready, Get Set, Build!

In some_directory you can find the configs Buffalo used to build the kernels shipped with their various firmwares:

$ ls buffalo/

and choose one to use as a template for yours.

$ cp buffalo/buffalo_lsgl_arm_110.config .config

Then you can modify the configuration as you want:

$ make menuconfig

and start up the build!

$ make uImage

If you selected some features to be built as modules, they need to be prepared too.

$ make modules

The kernel and modules will be ready at arch/arm/boot/uImage.


Compiling a Native Kernel

Software and Source Code Requirements

If the distribution installed on your nas has gcc, and enough RAM to compile a kernel, you can build a custom kernel directly on the box itself. To do this, you will need gcc, a utility called mkimage, and the Buffalo kernel sources for your device. Those using GenLink for ARM9 GenLink will already have sys-devel/gcc on their system. mkimage is part of the dev-embedded/u-boot-tools package:

 emerge --getbinpkg --usepkg dev-embedded/u-boot-tools

If you're running a different distribution, use the commands appropriate to your distribution to install gcc and u-boot-tools.

In case you're wondering, mkimage is a utility used to create kernel and/or initrd images for use with u-boot. u-boot is the standard bootloader used on the LS. The mkimage utility is run by the Makefile during the kernel build process, and is needed to package the kernel so it can be loaded by u-boot.

The Buffalo kernel sources for your NAS should be available on the [ Buffalo Source Code Download page]. Just look for the model device that you have, follow the link for the firmware version you want, look for a package name starting with "linux-", and download it.

For example, if you have a LS-CL, you would download linux-2.6.22_lsp.3.0.5.tar.bz2 from [1] this page.

Of course, that's only an example. Download the source package that matches your device.

Step 2