In this post I’ll show you the steps necessary to build your own custom kernel to run on your NAS. In this post i only show to build it for Orion and Kirkwood LaCie devices, as i own these myself and know how to build it for them. I also use Ubuntu 32-bit to prepare and build the software on.
Note to 64-bit users:
The toolchain used here is 32-bit. If you want to crosscompile the kernel on a 64-bit machine you’ll need one extra package:
apt-get install ia32-libs
This will install the 32-bit shared libraries needed for building 32-bit apps on 64-bit systems.
First we need to prepare thing, which will consist of downloading the kernel source, ARM toolchain and necessary packages needed to build:
First we’ll install the necessary packages needed to build:
apt-get install uboot-mkimage build-essential libncurses5-dev
Navigate to your home directory (cd ~/) and lets start building!
Then we need to download the required software, starting with the kernel (as of writing, the current stable version is 3.8.4).
Unpack the kernel:
tar vxf linux-3.84.tar.xz
Download the ARM Toolchain:
Unpack the toolchain:
tar vxjf arm-2012.09-64-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
Then we need to create the kernel modules directory, create a dir called kernelmodules:
Set some environment variables to enhance the building process:
Dive in the kernel source directory:
For Orion devices do the following to configure the kernel for that board:
For Kirkwood devices do the following to configure the kernel for that board:
The rest of the steps are the same for both boards, continue to customize the kernel (you will enter a menu where you add extra modules for your kernel, like extra filesystem support):
Optionally you can save the configuration file you just created with menuconfig, when leaving menuconfig you have saved the config in the current directory as:
If you make a copy of that file to a safe location you can use that configuration file again whenever you need to build a new kernel for the device the config is created for, this can be helpful if there are kernel updates or you want to extend or slim down the config.
Once you have set the options and modules you want and saved your configuration, you can start building the uImage needed by uBoot:
If you have a multicore processor you may append the number of cores to the make instruction, this will greatly speed up the compile process, so if you have a quadcore system you can make the image with:
make uImage -j4
When the build is complete there will be a file called uImage in
arch/arm/boot/, copy that file to your homedir:
cp arch/arm/boot/uImage ../
Now build your kernel modules:
If you have a multicore processor you may append the number of cores to the make instruction, this will greatly speed up the compile process, so if you have a quadcore system you can make the modules with:
make modules -j4
And install them (will be in ~/kernelmodules):
Create a tarball with your modules in it, so you can deploy them on your new to boot system:
tar vczf kernelmodules.tgz *
mv kernelmodules.tgz ../
That’s it! Now you have built your own ARM kernel with the latest kernel sources available. For LaCie based NAS devices the kernel can be booted in 2 ways, that’s the secret partition (/dev/sda6 or 7) using
dd of creating a
ext3 filesystem on those partitions with uImage in the following directory:
/snaps/00/boot/, but I will get back to you for this in the next round. You can also boot this via the uBoot console using TFTP.
48 responses to “Crosscompiling your own kernel”
I followed your instructions exactly, even cut&paste to avoid any typos.
I get to “make proper” and get this error:
chris@ubuntu:~/linux-2.6.37$ make mrproper
make: arm-none-eabi-gcc: Command not found
Is there a typo in your instructions or am I missing a module?
Hi! Have you set the environment options as well? What version of ubuntu are you using? You can also check if in the 2010.09 folder is arm-none-eabi-gcc? Also make sure you are running as root!
On ubuntu you can be root with “sudo su -“.
I did set the environment options.
I am using Ubuntu 10.10
Under arm-2010.09 folder there is an arm-none-linux-gnueabi but *NOT* an arm-none-eabi-gcc folder.
I was not using sudo. I will try that now.
running as sudo did not make a difference 🙁
This is one of your environment variables:
I do not have a bin directory under arm-2010.09
Ignore last comment. I am going senile.
I deleted all of it and reinstalled from beginning, with all parts done as root. Same error.
You are right, but i found the solution, with the newer toolchain the prefix has been changed, i’ve updated the post and the fix is:
Try it! 🙂
re-tried. Used the new EXPORT command.
Same result 🙁
Can you paste the contents of your
arm-2010.09folder? Because i have recreated the setup on a fresh machine and that worked for me with the new CROSS_COMPILE variable.