[RaspPi] How To Compile OpenWRT Trunk with latest Raspberry Pi Kernel 3.10 for the RPi on Ubuntu 12.04

EDIT: This post is from 30.09.2013 and should be the "how to" to this post. However, I never released it for a now unknown reason. Because of the interest in this topic, I still will publish it today so that it can stand as some kind of documentation of what I did back then. However, I might not work anymore.

This is the latest Guide.

What are we doing here?
Building OpenWRT Trunk with the offical RPi 3.10 (next) Kernel.

Packages:
You can use some packages of the offical OpenWRT 12.09 Attitude Adjustment repo.
However, most kernel modules and stuff has to be built but yourself, as I
got no repo. Sorry!

Dependencies needed

sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip

Prepare Enviroment (Trunk)

cd ~
mkdir rpi_openwrt
cd rpi_openwrt
git clone git://git.openwrt.org/openwrt.git
cd openwrt
mkdir dl

Install Packages

./scripts/feeds update -a
./scripts/feeds install -a

Check Enviroment

make defconfig
make prereq

Download Kernel and Prepare:

cd /tmp

wget https://github.com/raspberrypi/linux/archive/rpi-3.10.y.tar.gz

tar xfvz rpi-3.10.y.tar.gz
mv linux-rpi-3.10.y linux-3.10.13
tar -cJvf linux-3.10.13.tar.xz linux-3.10.13/
mv linux-3.10.13.tar.xz ~/rpi_openwrt/openwrt/dl/

Prepare Target

cd ~/rpi_openwrt/openwrt/target/linux/brcm2708/

Remove the RPi Kernel specific patches

we don't need them because we use the ORIGINAL kernel

- and not some retailored standard kernel!

mv patches-3.10 patches-3.10.bkp
mkdir patches-3.10

check wheter the makefile does try to catch the right kernel version

vi Makefile

change LINUX_VERSION to LINUX_VERSION:=3.10.13

Prepare Generic Patches

cd ../generic/patches-3.10

Normally it should be ok to just remove some of the patches like this.

if make target/linux/{clean,prepare} V=99 does fail in patching stage

you would need to remove another patch here

but for the time beeing, lets kill these files which are known to

wreck it:

rm 063-arm-fix-fiq-vivt.patch
rm 880-gateworks_system_controller.patch

#Make
cd ~/rpi_openwrt/openwrt/
make menuconfig # Choose BCM2708 Chipset, Raspberry Pi Board, Exit and Save
make target/linux/{clean,prepare} V=99 # does extract kernel and patch it
make kernel_oldconfig # builds some tools
make kernel_menuconfig # configures kernel
make menuconfig # to change RPi Patterns, i.e.:

Packages rep:

Image configuration -> Version configuration options -> Release Repo to:

http://downloads.openwrt.org/attitude_adjustment/12.09/%T/generic/packages

Main Partition Size from 48 to 64:

Target Options -> Root File System Size, change from 48 to 64 MB or more

Exit and Save

make V=99 -j 3

Files are in ~/rpi_openwrt/openwrt/bin/brcm2708
( i.e. openwrt-brcm2708-sdcard-vfat-ext4.img )
New build:
make kernel_menuconfig
make menuconfig
make V=99 -j 3

Odroid U3 Kernel Upgrade + Docker

I wrote this back in January 2017. Since then I had not much time to work on the Odroid - however, user hexdump did just came up with a new repo, supporting the Odroid U3 with Kernel 5.4.x - you can find the overview over his awesome work here and the repo with complete releases (i.e. Ubuntu Bionic or Debian Buster i.e. odroid_u3-armv7l-debian.img.gz) here

I am using an trusty old Odroid U3 which I acquired years ago. With its SAMSUNG Exynos 4412 Cortex-A9 Quad Core 1,7 Ghz, 1MB L2 cache and 2 GB of RAM, this little puppy was an real beast - compared to the Raspberry Pi 1 at that time. However, Hardkernel did drop the support - again, which left the Users back with very old Kernel versions. However, thanks to some users and the fact that all needed support for the Exynos is now included in the current kernel - well, we can build our own. This write up is the distilled result of days of work and a lot of research - and the work of other people which I found on the net (which I will try to give proper credits at the right locations :)).

EDIT: I upgraded the Kernel Configuration GIST for my Kernel Config + Docker on 10.02.2017. Thanks to an E-Mail from Tobias Jakobi I found the pieces I missed about adding the Kernel Internal Fanservice into the Config. This works now, however - I still like my tweaked program a bit better, as it cools the system more aggressivly, while the kernel default one is a lot more silent, but runs in the 80's°C while mine will stay at 70° on max load.

It is important that these instructions, especially if it comes down to installing stuff - is written for the usage of eMMC memory, NOT THE SDCARD! Also, there be dragons and something could go wrong - so please, as usual, advance at your own pace and risk! 🙂

0.) Get an Serial Interface for 1.8V
Important. The UART is 1.8V LVTTL ONLY! If you connect 3.3V or 5V, you'll blow the U3! I used an regular 5V TTL USB Adapter as well as an Sparkfun BiDir Level Converter: https://www.sparkfun.com/products/12009 With that set to 1.8V from the UART of the U3, it worked flawlessly with the usual 115000 BAUD.

Pinout:
http://odroid.com/dokuwiki/doku.php?id=en:u3_hardware

_____UART____
|Pin 4 - GND|
|Pin 3 - RXD|
|Pin 2 - TXD|
|Pin 1 - VCC|
___________|
1.8V LVTTL

1.) Build U-Boot
A lot of stuff is taken from here, thanks a lot for your great work, SnakeBite!
We asume you're working as root, as all this stuff will need root rights :).

# update your packages
apt-get update
# needed for building u-boot
apt-get install device-tree-compiler
# get ODROID signed u-boot
wget http://odroid.in/guides/ubuntu-lfs/boot.tar.gz
tar xzf boot.tar.gz
# get patched u-boot & build for the U3
git clone https://github.com/tobiasjakobi/u-boot
cd u-boot
make odroid_config
make
#copy fresh u-boot to ODROID directory
cp u-boot-dtb.bin ../boot/u-boot.bin
cd ../boot
## install on SDCard - not what we want, just as an remark for me
#bash sd_fusing.sh /dev/mmcblk0

Copy the needed files (u-boot.bin, E4412_S.bl1.HardKernel.bin, bl2.signed.bin, E4412_S.tzsw.signed.bin) to your PC, reboot your Odroid U3 into fastboot via connecting the UART to the U3 and aborting the boot. After that, you can issue the fastboot command on the UART. The U3 will now wait for filetransfer over the Micro USB Port, which you'll need to connect to your PC. Also, for the sake of an easy upgrade, use an Linux PC (more infos here: http://odroid.com/dokuwiki/doku.php?id=en:u3_building_u-boot ).

# install needed programs
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot
# and - being in the right folder, start the transfer
# u-boot.bin install
sudo fastboot flash bootloader u-boot.bin
# bl1.bin install
sudo fastboot flash fwbl1 bl1.HardKernel
# bl2.bin install
sudo fastboot flash bl2 bl2.HardKernel
# tzsw.bin install
sudo fastboot flash tzsw tzsw.HardKernel
# If installation is done, you can reboot your ODROID-U3 with fastboot.
sudo fastboot reboot

You should now have a more recent U-Boot install.

Old: U-Boot 2010.12-svn (May 12 2014 - 15:05:46) for Exynox4412
New: U-Boot 2016.11-rc3-g8a65327 (Jan 07 2017 - 23:00:56 +0100)

By the way, we needed to download this boot.tar.gz, because it contains the keys needed to sign our new U-Boot install. More Infos about U-Boot and Keys: https://github.com/dsd/u-boot/blob/master/doc/README.odroid

The Installation of a more recent U-Boot version was necessary to facilitate the boot of the to-be-build new Kernel zImage with bootz.

1b.) eMMC recovery in case something goes wrong:
http://forum.odroid.com/viewtopic.php?f=53&t=969
DL the tool [ exynos4412_emmc_recovery_from_sd_20140629.zip ]

  1. Prepare a microSD card and flash the attached image.
  2. Insert microSD into U2/U3, disconnect eMMC
  3. Turn on U2/U3 and wait for a few seconds and blue LED will blink.
  4. Plug your eMMC module into U2/U3
    4b - wait 10 seconds!
  5. Plug micro-USB cable into U2/U3 and connect other side to your PC USB host or ODROID's USB host port. (This is a trigger to start the recovery)
  6. After recovery process (only a few seconds), the blue LED will turn off automatically.
  7. Finish. Install OS on your eMMC with as usual.

2.) Building Next Kernel for Odroid U3 with eMMC
And now to start the real work:

apt-get update
apt-get install live-boot u-boot-tools
cd ~
git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git linux_odroid
cd linux_odroid
# we could make an default config, but this is not needed, we take rglinuxtech config in the next step
# make exynos_defconfig
# Odroid Config Kernel 4.4 from http://rglinuxtech.com/?p=1656
curl -o .config http://pastebin.com/raw/NveRajaZ
# Or you can use my Config which enables Docker as well (Gist at the End of the page)
curl -o .config https://gist.githubusercontent.com/nmaas87/81818c1db9dc292a4c21125bd2602658/raw/7e4e14fa15d7c68b177f31b9e2348d62c52cf83c/u3_docker_config
make menuconfig
make prepare modules_prepare
make -j4 bzImage modules dtbs
make modules_install
cp arch/arm/boot/dts/exynos4412-odroidu3.dtb /media/boot/exynos4412-odroidu3_next.dtb
cp arch/arm/boot/zImage /media/boot/zImage_next
cp .config /boot/config-`cat include/config/kernel.release`
update-initramfs -c -k `cat include/config/kernel.release`
mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n uInitrd -d /boot/initrd.img-`cat include/config/kernel.release` /boot/uInitrd-`cat include/config/kernel.release`
cp /boot/uInitrd-`cat include/config/kernel.release` /media/boot/
cd /media/boot/
vi boot.txt
# now we have to rework the boot.txt / config
# comment out the old values and set in the new ones
# please do NOT copy blindly, you need to adjust the zImage, uInitrd and eyxnos4412***.dtb file names according to your system!
setenv initrd_high "0xffffffff"
setenv fdt_high "0xffffffff"
#setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootm 0x40008000 0x42000000"
setenv bootcmd "fatload mmc 0:1 0x40008000 zImage_next; fatload mmc 0:1 0x42000000 uInitrd-4.10.0-rc2-next-20170106-v7; fatload mmc 0:1 0x44000000 exynos4412-odroidu3_next.dtb; bootz 0x40008000 0x42000000 0x44000000"
#setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=/dev/mmcblk0p2 rootwait ro mem=2047M"
setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=/dev/mmcblk1p2 rootwait ro mem=2047M"
boot

#After you have done that, write the commands to the boot.scr file
mkimage -C none -A arm -T script -d boot.txt boot.scr
# sync and reboot and it should work
sync
reboot now

With this in mind I really upgraded my system from kernel 3.8.13 from 2015 - to the most recent 4.10.0-rc2 next Kernel 🙂

Old: Linux odroid 3.8.13.30 #1 SMP PREEMPT Fri Sep 4 23:45:57 BRT 2015 armv7l armv7l armv7l GNU/Linux
New: Linux odroid 4.10.0-rc2-next-20170106-v7 #3 SMP PREEMPT Mon Jan 9 19:17:32 CET 2017 armv7l armv7l armv7l GNU/Linux

2b.) FAN does not work, warning!
The CPU Fan does somehow not work right out of the box, so we will now enable it manually. [EDIT, with the new Kernel Config it works out of the box, but you can still decide to use this software to have a more aggressiv cooling :)]

# Fan to full speed
echo 255 > /sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1
# Read out current temperature in °C
cat /sys/devices/virtual/thermal/thermal_zone0/temp

To get things working again, I forked and updated the odroidu2 fan tool. Install it via:

git clone --depth 1 https://github.com/nmaas87/odroidu2-fan-service.git
cd odroidu2-fan-service
make
# install it as upstart service, i.e. < Ubuntu 16.04
make usi
# install it as systemd, i.e. Ubuntu 16.04 / Xenial
make systemd
reboot

Useful Commands:

# Read max CPU Speed:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
# Get current CPU Speed:
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
# Torrture Test:
openssl speed -multi 4

2c.) Upgrade to Xenial
As I upgraded to Xenial with do-relase-upgrade, I had some problems:

Authentication Problem:
It was not possible to authenticate some packages. This may be a transient network problem. You may want to try again later. See below for a list of unauthenticated packages. create /etc/update-manager/release-upgrades.d/unauth.cfg with

[Distro]
AllowUnauthenticated=yes

After upgrade, remove this file.
from: http://askubuntu.com/questions/425355/error-authenticating-some-packages-while-upgrade

After that, apt-get clean did not work:
apt-get clean
W: Problem unlinking the file apt-fast - Clean (21: Is a directory)

Solution was:

rm -rf /var/cache/apt/archives/apt-fast

from: http://askubuntu.com/questions/765274/error-problem-unlinking-in-apt-get-clean

2d.) MAC address changes every reboot:
One solution, which did not work, was following:

rm /etc/smsc95xx_mac_addr

from: http://forum.odroid.com/viewtopic.php?f=7&t=1070

Which worked better, was to really set the MAC address to a static value:
add in /etc/network/interfaces

auto eth0
iface eth0 inet dhcp
hwaddress ether bb:aa:ee:cc:dd:ff

from: http://forum.odroid.com/viewtopic.php?f=111&t=8198

2e.) Control the CPU speeds via cpufrequtils:

apt-get install cpufrequtils
vi /etc/default/cpufrequtils

ENABLE="true"
GOVERNOR="ondemand"
MAX_SPEED=1704000
MIN_SPEED=200000

However, I chose "performance" as GOVERNOR and a MIN_SPEED=800000

from: http://forum.odroid.com/viewtopic.php?f=65&t=2795

2f.) Install Docker
If you chose my .config with Docker enabled, you can install Docker with a fast
curl -sSL https://get.docker.com/ | sh
Thanks a lot to the Guys over at Hypriot, I took their RPi Kernel Configs as an example and merged those with the U3 Configs to get to this results. And yes, AUFS is still missing but... it is ok 😉

Additional stuff:
- Gist of my Kernel Config: https://gist.github.com/nmaas87/81818c1db9dc292a4c21125bd2602658

Following sites helped:
- https://blogs.s-osg.org/install-ubuntu-run-mainline-kernel-odroid-xu4/
- http://rtisat.blogspot.de/search/label/odroid-u3
- https://github.com/umiddelb/armhf/wiki/How-To-compile-a-custom-Linux-kernel-for-your-ARM-device
- http://rglinuxtech.com/?p=1622
- http://rglinuxtech.com/?p=1656
- http://forum.odroid.com/viewtopic.php?f=81&t=9342

[Raspberry Pi] Warning - Kernel 4.4.38 breaks boot on RPi 1 & 2

About 14 days ago, RPi Kernel Version 4.4.38 was published. However, something went very wrong somewhere: Raspbery Pi Models 1 and 2 do not boot anymore. As a quickfix I would recommend to download the 4.4.37 Kernel from the Github Repo (https://github.com/raspberrypi/firmware/) and replace the boot Partition on your RPi 1 or 2 SDCard with the /boot path from the 4.4.37 ZIP file - and it should boot again.
If you're RPi is still working - do not update your kernel until this problem is solved! (Issue on Github).

EDIT: Reason for the issue was mostly the open

device_tree=

configuration in the config.txt

Removing this option solved the problem.

[RaspPi] How To Compile OpenWRT Trunk with latest Raspberry Pi Kernel 3.6 for the RPi on Ubuntu 12.04

What are we doing here?

As far as I understand the problem, there are two worlds:
Raspberry Pi Foundation on the one hand, the OpenWRT Team on the other one.
OpenWRT does try to patch "Default Kernels" until they work out with the intended Plattform, which does work in most cases very well.
The problem is, RPi is an new target for the latest OpenWRT Release - and does work - but it does not get much love of the devs:
No trunk compiles or nightlys of the Image or the packages - i.e.
And - the "so patched Kernel" does not represent the state of the art of the RPi Kernel Development at all:
I got many errors of the "first days of Pi", like the loved "SDcard error" which corrupted the whole filesystem and such.

User arsiskk of the raspberrypi-openwrt project had the same problem.
The rpi-openwrt project tried to deliever the first OpenWRT Experience to the RPi Users - competing with OpenWRT - and succeeded.
But the problem somehow remained: The old kernel was lingering there and the Team seemed to have given up the project after RPi
became an official target (https://code.google.com/p/raspberrypi-openwrt/).
So arsiskk developed a procedure to compile the raspberrypi-openwrt Code with the latest RPi Kernel - which worked awesome.
But as the project seems to be quite dead now - I tried to convert his idea and use it on the offical OpenWRT Trunk Sourcetree.
And that worked.

So long story short, what are we doing here?
We grab the trunk OpenWRT official source code, load the offical RPi Kernel into it, delete a bunch of files
which would only be needed to supply an standard kernel with a bit of RPi support and compile it.
In the end we will have the latest OpenWRT trunk with the latest RPi Kernel.
The only problem: You would sometimes need to rebuild packages which do not work with the official, but old (3.6.11, compared to OpenWRTs 3.10.4) Kernel.
And - you can't update the OpenWRT trunk that easily.
It is basically an "build and throw away" system.
But it works!
# Dependencies needed
sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip

# Prepare Enviroment (Trunk)
cd ~
mkdir rpi_openwrt
cd rpi_openwrt
git clone git://git.openwrt.org/openwrt.git
cd openwrt
mkdir dl
# Install Packages
./scripts/feeds update -a
./scripts/feeds install -a

# Check Enviroment
make defconfig
make prereq

# Download Kernel and Prepare:
cd /tmp
wget https://github.com/raspberrypi/linux/archive/rpi-3.6.y.tar.gz
tar xfvz rpi-3.6.y.tar.gz
mv linux-rpi-3.6.y linux-3.6.11
tar cvf - linux-3.6.11/ | lzma > linux-3.6.11.tar.xz
mv linux-3.6.11.tar.xz ~/rpi_openwrt/openwrt/dl/

# Prepare Target
cd ~/rpi_openwrt/openwrt/target/linux/brcm2708/
vi Makefile
change LINUX_VERSION to LINUX_VERSION:=3.6.11
mkdir patches-3.6
cp config-3.10 config-3.6
cd ../generic/
cd patches-3.6
#if not exists, dl latest official openwrt, copy files from openwrt/target/linux/generic/patches-3.6 to here
# Normally it should be ok to just remove some of the patches like this:
rm *-mips*
rm *-phy*
rm a*
rm 880-gateworks_system_controller.patch
#But in case there are still errors on the make target/linux/{clean,prepare} V=99 Stage,
#remove all files except these, keep these files: (openwrt specific patches)
200-fix_localversion.patch 621-sched_act_connmark.patch
201-extra_optimization.patch 630-packet_socket_type.patch
202-reduce_module_size.patch 640-bridge_no_eap_forward.patch
210-darwin_scripts_include.patch 641-bridge_always_accept_eap.patch
211-stddef_include.patch 642-bridge_port_isolate.patch
212-byteshift_portability.patch 643-bridge_remove_ipv6_dependency.patch
220-module_exports.patch 644-bridge_optimize_netfilter_hooks.patch
230-openwrt_lzma_options.patch 650-pppoe_header_pad.patch
250-netfilter_depends.patch 651-wireless_mesh_header.patch
251-sound_kconfig.patch 652-atm_header_changes.patch
252-mv_cesa_depends.patch 653-disable_netlink_trim.patch
253-ssb_b43_default_on.patch 655-increase_skb_pad.patch
254-textsearch_kconfig_hacks.patch 900-slab_maxsize.patch
255-lib80211_kconfig_hacks.patch 910-kobject_uevent.patch
256-crypto_add_kconfig_prompts.patch 911-kobject_add_broadcast_uevent.patch
257-wireless_ext_kconfig_hack.patch 920-unable_to_open_console.patch
258-netfilter_netlink_kconfig_hack.patch 921-use_preinit_as_init.patch
260-move_bcm963xx_tag.patch 930-crashlog.patch
600-netfilter_layer7_2.22.patch 940-ocf_kbuild_integration.patch
601-netfilter_layer7_pktmatch.patch 941-ocf_20120127.patch
602-netfilter_layer7_match.patch 950-vm_exports.patch
603-netfilter_layer7_2.6.36_fix.patch 960-decompress_unlzo_fix.patch
604-netfilter_cisco_794x_iphone.patch 970-remove-unsane-filenames-from-deps_initramfs-list.patch
610-netfilter_match_bypass_default_checks.patch 980-arm_openwrt_machtypes.patch
611-netfilter_match_bypass_default_table.patch 992-mpcore_wdt_fix_watchdog_counter_loading.patch
612-netfilter_match_reduce_memory_access.patch 993-mpcore_wdt_fix_wdioc_setoptions_handling.patch
613-netfilter_optional_tcp_window_check.patch 994-mpcore_wdt_fix_timer_mode_setup.patch
620-sched_esfq.patch

#Make
cd ~/rpi_openwrt/openwrt/
make menuconfig # Choose BCM2708 Chipset, Raspberry Pi Board, Exit and Save
make target/linux/{clean,prepare} V=99 # does extract kernel and patch it
make kernel_oldconfig # builds some tools
make kernel_menuconfig # configures kernel
make menuconfig # to change RPi Patterns, i.e.:
# Packages rep:
# Image configuration -> Version configuration options -> Release Repo to:
# http://downloads.openwrt.org/attitude_adjustment/12.09/%T/generic/packages
# Main Partition Size from 48 to 64:
# Target Options -> Root File System Size, change from 48 to 64 MB or more
# Exit and Save
make V=99 -j 3

Files are in ~/rpi_openwrt/openwrt/bin/brcm2708
( i.e. openwrt-brcm2708-sdcard-vfat-ext4.img )
New build:
make kernel_menuconfig
make menuconfig
make V=99 -j 3

Inspiration and Help:
http://wiki.openwrt.org/doc/howto/build
https://code.google.com/p/raspberrypi-openwrt/issues/detail?id=11

[RaspPi] Build Raspberry Pi Kernel for Debian Wheezy / Raspbian with eGalax Touchscreen Support on Ubuntu 12.04

# Preperations
sudo apt-get install git libncurses5 libncurses5-dev qt4-dev-tools qt4-qmake pkg-config build-essential gcc-arm-linux-gnueabi bc

# Clone Stuff
mkdir rpi_kernel
cd rpi_kernel
git clone https://github.com/raspberrypi/tools.git
git clone https://github.com/raspberrypi/linux.git
git clone https://github.com/raspberrypi/firmware.git
cd ~/rpi_kernel/firmware/.git
git branch -a
cd ~/rpi_kernel/firmware
git checkout -t -b next remotes/origin/next
git pull
cd ~/rpi_kernel

# Make Kernel
cd linux
make mrproper
mkdir ../kernel
# Kernel Types
# find . -name *bcmrpi*config -print
# ./arch/arm/configs/bcmrpi_emergency_defconfig
# ./arch/arm/configs/bcmrpi_defconfig
# ./arch/arm/configs/bcmrpi_cutdown_defconfig
make O=../kernel/ ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- bcmrpi_defconfig
make O=../kernel/ ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig #xconfig
#Device Drivers->Input Device Support->TouchScreens->USB Touchscreen Driver (Build it into or as module, check if eGalax here!)
make O=../kernel/ ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j3
cd ../
cd tools/mkimage
./imagetool-uncompressed.py ../../kernel/arch/arm/boot/Image
cd ../../

# Make Modules
cd kernel
mkdir ../modules/
make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/
# Install Kernel on existing RPi SD Card / Raspbian
# mount sdcard in your Ubuntu (I made an folder sdb1 for boot partiton and sdb2 for the root partition)
cd ~
mkdir sdb1 sdb2
mount /dev/sdb1 sdb1
mount /dev/sdb2 sdb2

# backup config
cp ~/sdb1/config.txt ~/rpi_kernel/
# boot partition
sudo rm -rf ~/sdb1/*
# Copy all Files from boot
cp -R ~/rpi_kernel/firmware/boot/* ~/sdb1/
#replace /sdb1/boot/kernel.img with the previously created kernel image
sudo rm ~/sdb1/kernel.img
cp ~/rpi_kernel/tools/mkimage/kernel.img ~/sdb1/
# restore config
cp ~/rpi_kernel/config.txt ~/sdb1/

# root partition
#replace /sdb2/lib/firmware with <modules_builded_above_folder>/lib/firmware
sudo rm -rf ~/sdb2/lib/firmware/
sudo cp -R ~/rpi_kernel/modules/lib/firmware/ ~/sdb2/lib/
#replace /sdb2/lib/modules with <modules_builded_above_folder>/lib/modules
sudo rm -rf ~/sdb2/lib/modules/
sudo cp -R ~/rpi_kernel/modules/lib/modules/ ~/sdb2/lib/
#replace /sdb2/opt/vc with firmware-next/hardfp/opt/vc/
sudo rm -rf ~/sdb2/opt/vc
sudo cp -R ~/rpi_kernel/firmware/hardfp/opt/vc/ ~/sdb2/opt/

# sync usb mount
sync

# Unmount sdcard
cd ~
umount sdb1
umount sdb2
# Boot Pi and calibrate Touchscreen
# This stuff happens on the Pi!
# Preperations
sudo apt-get install libx11-dev libxext-dev libxi-dev x11proto-input-dev

# Install Tool / xinput_calibrator
cd ~
wget http://github.com/downloads/tias/xinput_calibrator/xinput_calibrator-0.7.5.tar.gz
tar -xvzf xinput_calibrator-0.7.5.tar.gz
cd xinput_calibrator-0.7.5
./configure
make
sudo make install

# Calibrate (in Xserver, so open Terminal while beeing in Graphical User Mode)
xinput_calibrator

It will give output like this:
Calibrating EVDEV driver for "eGalax Inc. USB TouchController" id=8
current calibration values (from XInput): min_x=1938, max_x=114 and min_y=1745, max_y=341

Doing dynamic recalibration:
Setting new calibration data: 121, 1917, 317, 1741
--> Making the calibration permanent <--
copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'
Section "InputClass"
Identifier "calibration"
MatchProduct "eGalax Inc. USB TouchController"
Option "Calibration" "121 1917 317 1741"
Option "SwapAxes" "1"
EndSection

Use the Output after "--> Making the calibration permanent <--
copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'"
And copy the part after that into following file:

sudo mkdir /etc/X11/xorg.conf.d
sudo vi /etc/X11/xorg.conf.d/01-input.conf

After that, save, exit and reboot.
That should conclude your newly "Custom baked Kernel" and your EGalax Touchscreen Support.

Thanks a lot to http://engineering-diy.blogspot.de/2013/01/adding-7inch-display-with-touchscreen.html

Raspberry Pi Kernel Compile


and http://karuppuswamy.com/wordpress/2013/01/17/how-to-get-evtouch-touch-screen-kit-working-in-linux/
from which I learnt and borrowed most of the stuff and tips and rewrote this How To with minor changes
Upgrade
cd linux
make mrproper
git pull
cd ../tools
git pull
cd ../firmware
git pull
# then make and build like shown above

Check hard/softfp version of OS
${CCPREFIX}gcc -v 2>&1 | grep hard