Step-by-step Native Compiling a Kernel

From odroid US

Revision as of 22:31, 2 February 2013 by Osterluk(Talk | contribs)(Created page with "WATCH THE SIZE OF YOUR BOOT PARTITION, MAYBE YOU HAVE TO DELETE SOME OF THE BACKUP FILES! DO THIS ON YOUR ODROID, NOT ON YOUR PC! These procedures assume you have an Debian-...")

Unpacking the source

Configuring the kernel

Now is the time to consider whether you want to work as root user or to logout and proceed as a normal user. Usually file permissions trip up users new to Linux. Working as root can make things easier, but there is a risk of wrecking your system. On the plus side, with odroid, we can just re-flash it and get back to work.

You might want to install the sudo package if you don't have it already. This next section is optional

sudo apt-get install
# You need to add yourself to the "sudoers list", and how exactly that is done depends on the distribution.
# This hack works for Debian Wheezy
# as root, add normal user (named user) to adm group
adduser user adm
# configure the adm group to have no restrictions
echo "%adm ALL=(ALL) ALL" >> /etc/sudoers
# sudo will complain if it cannot resolve the hostname
echo "127.0.0.1 $(hostname )" >> /etc/hosts

Move to the linux source tree and change ownership to the normal user named user. Substitute your own username.

cd /usr/src
chown -R user:user linux
cd linux

Make sure to select the correct config for your device in the next step.
execute the following to get a list of odroid kernel configs:

# This step prepares for building and copies the configuration from arch/arm/configs to .config
make odroidx2_ubuntu_defconfig

Now you can build the kernel according to the configuration you chose, or you and make configuration changes.

You can configure the kernel using either text mode or GUI. The results are the same. The search functions in the GUI are nice. If you only have the serial console, you need to use text mode.

Text mode:

apt-get install libncurses5-dev
make menuconfig

Graphical mode:

apt-get install qt4-dev-tools
make xconfig

change everything to your needs (use / for searching)

Building the kernel

make -j8
# If you are building as root:
make modules_install
# If you are building as user:
sudo make modules_install
make zImage

Building the initial ram filesystem

This is not always needed -- unless you need changes in phase 1 of the Linux boot, it is best to leave this alone.

If you need a custom filesystem driver, or you want to directly mount your root file system on a thumb drive or NAS drive, this would be the area to work in. You would need to know that this is a busybox-based system completely separate from the eventual distro you intend to boot.

The #1 came from the file: /usr/src/linux/.version. Each time you build, this number will be incremented.

warnings

Your new kernel built kernel modules that may not be compatible with other builds.

Please don't post a private kernel without giving a warning. If could break another system. If you make small changes, like select an additional module, the result will probably not segfault other systems. On the other hand, if you select some networking options (especially) you may find that structs don't quite line up and eventually someone will segfault.