Probably you'll never need to build your own kernel due to the huge amount of drivers you have already on the base system we provide to you, but if you need to recompile it this "how to" will be really usefull.
To compile your own kernel you have to build a toolchain able to produce binary files that can run on your Netus system. Netus board is powered by a ARM926EJ-S™ ARM® Thumb® Processor, this means that you have to prepare a compiler for ARMV5TEJL architecture.
Requirements
A Gentoo Linux 2008.0 running system on your PC
You can simply install GENTOO by downloading it from here:
Gentoo 2008.0 LiveCD
(up to 710 megabytes depending on arch)
i686 amd64
Boot your PC from the live cd and use the wizard to install the system.
Gentoo installation, network and system configuration is fully explained in the handbook available here.
What we are going to do
First of all you need to create a cross-compiler. What is cross compiling? Cross-compiling is building binaries for one architecture (the target) on another (the host). The target is NETUS the host is your PC. To perform this job Gentoo offers you a great tool, crossdev.
What is crossdev? Gentoo created the crossdev script to automate the complex process of building a cross compiler.
Let's go! Crossdev installation
On the host machine check if you have a overlay. A overlay is a "portage layer". To check if you have this launch:
This will provide you with the crossdev script. This script automates the steps necessary to build a toolchain. These steps are, in short:
All cross toolchains will be kept locally in the overlay, separate from native tools.
PORTDIR_OVERLAY="/usr/local/portage" source /usr/portage/local/layman/make.conf PORTDIR_OVERLAY="/usr/local/portage $PORTDIR_OVERLAY"
The script I have used is:
This will build a cross-compiling toochain for ARM® armv5te machines.
The meaning of armv5tejl-softfloat-linux-gnueabi is arch-vendor-OS-libc, arch specifies the CPU architecture, vendor specifies the hardware platform or vendor, OS is the operating system, and libc is the C library to use. Only arch is strictly required in all cases—if you omit one or more of the remaining fields crossdev attempts to fill in the missing values with its best guess. Nevertheless—for Linux machines at least—it's good practice to specify all four fields. The libc field is not supported for Gentoo/FreeBSD, so for these machines it must always be omitted.
By default, the newest stable version of the binutils, libraries, and C compiler will be used, but generally they do not work and you have to search for the right tuple, use the suggested tuple that is running for me. It is quite often the case they will not compile themselves through the entire build process. Less bleeding edge versions can be specified with additional flags:
--b 2.18-r3 # specifies the version of binutils --g 4.3.3 # specifies the version of gcc --l 2.6.1 # specifies the version of the tuple-specified libc --k 2.6.28-r3 # specifies the version of the kernel headers
It is recommended trying older versions, particularly of gcc an binutils, if the script fails.
If you want to remove a toolchain, use the clean flag:
This will unmerge the packages created by crossdev, everytime it fails compiling restart always from clean.
I have also created a toolchain using UCLIBC using the following tuple:
USE=-* crossdev -v --b 2.19.1 --g 4.1.2 --l 2.9_p20081201-r1 --k 2.6.28-r1 --target armv5te-softfloat-linux-uclibceabi
But I have opted for GLIBC because due to the lot of space on the system I prefer to use the standard library that is usually compatible with a wide range of applications.
If the toolchain compiles correctly we can proceed with cross scripts for compiling and emerging sources.
To check if the toolchain works simply launch:
localhost ~ # armv5tejl-softfloat-linux-gnueabi-gcc --version
armv5tejl-softfloat-linux-gnueabi-gcc (Gentoo 4.3.3 p1.0, pie-10.1.5) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
localhost ~ #
If all is ok you'll obtain the output above.
PREPARING THE HOST ENVIRONMENT
Setting up sysroot for cross development
When cross developing, you'll usually want to avoid polluting the host system's environment with the products of cross development activity, and to also provide Portage with an alternate configuration and environment for cross emerge operations. The simplest solution for this is to use sysroot.
For convenience let's set the environment variable SYSROOT on our host system to point to the directory of the cross toolchain we'll be working with.
Now you have to create the make.conf inside the SYSROOT /usr/armv5tejl-softfloat-linux-gnueabi/etc/make.conf
The make.conf file should look like this:
#VIDEO_CARDS="fbdev dummy"
INPUT_DEVICES="keyboard"
#USE_EXPAND="video_cards input_devices"
MARCH_TUNE="-march=armv5t -mtune=arm926ej-s"
CFLAGS="-Os -pipe ${MARCH_TUNE} -fomit-frame-pointer -I${ROOT}/usr/include/ -I${ROOT}/include/"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-L${ROOT}/usr/lib -L${ROOT}/lib"
PKG_CONFIG_PATH="${ROOT}/usr/lib/pkgconfig/"
MAKEOPTS="-j8"
FEATURES="-collision-protect sandbox buildpkg noman noinfo nodoc"
PORTDIR_OVERLAY="/usr/local/portage"
PKGDIR=${ROOT}/packages/
PORTAGE_TMPDIR=${ROOT}/tmp/
PORTAGE_WORKDIR_MODE=2775
PORTAGE_ECLASS_WARNING_ENABLE=0
CLEAN_DELAY=0
EPAUSE_IGNORE=1
EBEEP_IGNORE=1
Then copy the host system's /etc/make.globals to the sysroot and create the directory for local profile configuration files:
We need to create a symlink for the sysroot Portage profile. Our example target system calls for uClibc, so we'll choose a pre-existing Portage profile for a minimal PPC uClibc base system:
xmerge: A simple cross emerge wrapper
Creating cross-compiled binaries usually entails using emerge in conjunction with a few modified environment variables. This can become tedious, so we can make things easier by handling everything in a script that wraps emerge. Here's an example of such a wrapper we'll call xmerge:
create a file named /bin/xmerge and give it execute permisison
Script content will be:
#!/bin/sh
CHOST=armv5tejl-softfloat-linux-gnueabi
export CBUILD=$(portageq envvar CHOST)
export PORTAGE_CONFIGROOT=${SYSROOT}
if [ "$1" = "--root" ] ; then
export ROOT=$2
shift 2
else
export ROOT=${SYSROOT}
fi
exec emerge "$@"
Now create another command /bin/xmake
xkmake: A cross kernel make wrapper
#!/bin/sh
exec make ARCH="arm" CROSS_COMPILE="armv5tejl-softfloat-linux-gnueabi-" INSTALL_MOD_PATH="${SYSROOT}" "$@"
Cross-compiling a Kernel
This will put kernel sources inside your /usr/armv5tejl-softfloat-linux-gnueabi/usr/src/linux-2.6.28-gentoo-r2 folder
After the sources will be merged edit the main Makefile
ORIGINAL:
# Set the ARCH and CROSS_COMPILE default values
#ARCH ?= $(SUBARCH)
#CROSS_COMPILE ?=
CHANGE IT IN:
# Set the ARCH and CROSS_COMPILE default values
ARCH ?= arm
CROSS_COMPILE ?= armv5tejl-softfloat-linux-gnueabi-
Then launch
And configure the kernel parameters for the CPU Atmel ATSAM9G20 as in the screenshots below:
first of all under System type set
ARM system type (Atmel AT91) --->

Atmel AT91 System-on-Chip ---> Atmel AT91 Processor (AT91SAM9G20) --->

Disable [ ] VGA text console Under device drivers > Graphics support ---> Console display driver support ---> [ ] VGA text console

Under Character devices ---> Serial drivers --->

enable
[*] AT91 / AT32 on-chip serial port support
[*] Support for console on AT91 / AT32 serial port
[*] Support DMA transfers on AT91 / AT32 serial port
After you have completed this configuration you are ready to lauch xmake
The kernel will be compiled with the selected options an the Image will be locate into:
/usr/armv5tejl-softfloat-linux-gnueabi/usr/src/linux-2.6.28-gentoo-r2/arch/arm/boot/Image
Now you need to emerge mkimage on your HOST system to create the uImage to flash inside your NETUS target
Now to create the image just launch
Flash your new kernel using Atmel SAM-BA inside your NETUS
http://www.linux4sam.org/twiki/bin/view/Linux4SAM/GettingStarted
This how to is extracted and adapted to Netus starting from http://en.gentoo-wiki.com/wiki/Crossdev