-
Notifications
You must be signed in to change notification settings - Fork 71
Building FrancoKernel from source
I'm writing this as a newbie to building Linux kernels. This is the first kernel I've ever built but not before failing miserably for a considerable while. I'm not going to try and reinvent the wheel here, mostly just an outline of what worked for me and the sources that helped me along.
I first attempted to build on Mac OS X and ran into enough problems that I decided to try a Linux virtual machine. This guide assumes you are working on Ubuntu 14.04 64-bit, but should work on other versions and distributions. If you're a Mac user, consider installing VirtualBox as your virtualization software with Ubuntu 14.04 as your guest machine.
- Update installed packages
sudo apt-get update && sudo apt-get dist-upgrade
- Install required packages (source)
sudo apt-get install build-essential kernel-package libncurses5-dev bzip2
- Download a prebuilt toolchain (source)
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
- Download the kernel source (source)
git clone [email protected]:franciscofranco/hammerhead.git
Much of the below is borrowed from here
- Expose you prebuilt toolchain. You'll need the path the "arm-eabi-4.8" directory, but we'll assume it's in your home folder
export PATH=~/arm-eabi-4.8/bin:$PATH
- You can probably get away without these variables since the default config seems to define them, but just in case
export ARCH=arm export CROSS_COMPILE=arm-eabi-
- Change directory into the kernel source folder (assuming it's in your home folder)
cd ~/hammerhead
- (Optionally) Customize your kernel config using GUI (source)
-
make xconfig
or via text editorvi arch/arm/config/franco_defconfig
-
- Create the build config file:
make defconfig franco_defconfig
- Build with your desired number of concurrent threads
make -j4
- On my quad core i7, it takes about 10 minutes to build and you'll know it's successful when the last messages tell you where to find
zImage
andzImage-dtb
.
You probably want to install this on your phone now. For this, we can use Franco's builds as a template for packaging a zip to be installed via TWRP or a similar recovery.
- Download a Franco build to use as a template
wget https://kernels.franco-lnx.net/Nexus5/6.0.1/anyKernel/fk-r106-anykernel2.zip
- Unzip the archive for editing
unzip fk-r106-anykernel2.zip -d fk-r106-anykernel2
- Place your newly built kernel into the template. Pay particular attention that we're copying
zImage-dtb
aszImage
cp -f arch/arm/boot/zImage-dtb fk-r106-anykernel2/zImage
- Change directory into the template
cd fk-r106-anykernel2
- Zip it up
zip -r9 custom-fk-r106-anykernel2.zip *
And there you have it, custom-fk-r106-anykernel2.zip
is your zip to flash in recovery. Nice work!