I managed to build an Android kernel using basically the steps outlined by Casey Anderson here:
http://headlessandroid.blogspot.hu/2012/07/android-raspberry-pi-kernel-build.htmlIt worked basically flawlessly!
For anyone else doing this, here is what I did (but credits to Casey for the awesome guide):
Firstly, I used the toolchain provided with the Android NDK (as I already had it installed). I assume that it is installed
~/android/ndk.
That means I set:
- Code: Select all
export PATH=$PATH:~/android/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
export CROSS_COMPILE=~/android/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
For newbies like me, be careful modifying the path; I mucked it up the first time and overwrote my existing one...
I decided to build the whole thing in
~/pi, so set the rest of the stuff up like this:
- Code: Select all
export RASP_SRC_BASE=~/pi
export ARCH=arm
export CCACHE_DIR=~/.ccache/
export USE_CCACHE=1
I needed to install
patch because I didn't have it:
- Code: Select all
sudo apt-get install patch
Then everything then runs like clockwork to build the normal kernel:
- Code: Select all
mkdir -p $RASP_SRC_BASE/kernel/patches
cd $RASP_SRC_BASE/kernel
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.1.9.tar.bz2
tar jxvf linux-3.1.9.tar.bz2
cd $RASP_SRC_BASE/kernel/patches/
wget http://www.cnx-software.com/patch/r-pi_linux_3.1.9.patch.gz
gunzip r-pi_linux_3.1.9.patch.gz
cd $RASP_SRC_BASE/kernel/linux-3.1.9
patch -p1 < ../patches/r-pi_linux_3.1.9.patch
cd $RASP_SRC_BASE/kernel/linux-3.1.9
cp arch/arm/configs/bcmrpi_cutdown_defconfig .config
make oldconfig
make -k -j6
I'm guessing it is possible to download and patch together a standard Linux kernel for the Pi in other (better?) ways, e.g. via the official Git repo, I'll try this too soon.
If this all works you're pretty much done, now the idea is to apply the Android patches. Following the guide:
- Code: Select all
cd $RASP_SRC_BASE/kernel/patches/
wget https://dl.dropbox.com/u/24888185/android_3.1.9_patch.tar.gz
gunzip android_3.1.9_patch.tar.gz
The thing is now you also want to extract the actual patches from the
android_3.1.9_patch.tar that is in
$RASP_SRC_BASE/kernel/patches/ into this directory. I did this with Ubuntu's archive, this can also be done with tar.
Once that is done, the final steps are:
- Code: Select all
cd $RASP_SRC_BASE/kernel/linux-3.1.9
patch -p1 < ../patches/linux-3.1.9-stock-to-android.patch
patch -p1 < ../patches/linux-3.1.9-fs-proc-base.patch
patch -p1 < ../patches/linux-3.1.9-yaffs2.patch
patch -p1 < ../patches/linux-3.1.9-power.patch
cd $RASP_SRC_BASE/kernel
wget https://dl.dropbox.com/u/24888185/rasp_android_defconfig.gz
gunzip rasp_android_defconfig.gz
mv rasp_android_defconfig .config
make -k -j6
Again this process could be streamlined quite a bit, but at the end, if all is well, you should end up with a
vmlinux 
Next step, build the rest of Android

Once again, a big thank you to Casey Anderson for your work

I hope you don't mind me reposting the steps here.