Step-by-step Native Compiling a Kernel
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-based distribution loaded on your odroid. The kernel building is not different between the distros, but getting ready to build is.
Debian/Ubuntu/Mint and others use "Debian packages", .deb files. They use tools like dpkg, apt, synaptic and so on to manage a package database.
RedHat, Centos, Fedora and Gentoo would not know about apt-get and friends -- so these instructions will not be of much use.
Grabbing the source
you can easily build the kernel on your own. grab the source from github:
- browse to https://github.com/hardkernel/linux
- choose your branch (as of today -2013-01-12- it's odroid-3.0.y)
wget --no-check-certificate https://github.com/hardkernel/linux/archive/odroid-3.0.y.zip
Unpacking the source
mv odroid-3.0.y.zip /usr/src/linux.zip cd /usr/src 7z x -y linux.zip > /dev/null mv linux-odroid* linux
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:
ls /usr/src/linux/arch/arm/configs/ | grep odroid
now choose your config and copy it to /usr/src/linux/.config (i chose odroid-x2s ubuntu config)
# 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.
apt-get install libncurses5-dev make menuconfig
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.
mkinitramfs -c gzip -o ./initramfs-$kernelversion $kernelversion mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d ./initramfs-$kernelversion ./uInitrd cp uInitrd /boot
Copying the kernel and initramfs to the boot partition
kernelversion=`cat ./include/config/kernel.release` cp /boot/zImage /boot/zImage.prev cp /boot/uInitrd /boot/uInitrd.prev cp arch/arm/boot/zImage /boot cp .config /boot/config-$kernelversion
cp System.map /boot/System.map-$kernelversion
shutdown -h 0
power cycle after that.
The new kernel will show something like this:
Linux odroidu2-1 3.0.57 #1 SMP Sun Jan 13 21:53:37 UTC 2013 armv7l GNU/Linux
The #1 came from the file: /usr/src/linux/.version. Each time you build, this number will be incremented.
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.