Document directory
- Install cyanogenmod on your phone
- Take a backup
- Install Repo
- Build cyanogenmod
- Complete the build
- Obtaining the code
- Create Build Environment
- Configure build
- Get proprietary files from your device
- Build it
From cyanogenmod Wiki
How do I compile the cyanogenmod kernel from source
The following instructions will enable the build of A cyanogenmod kernel, not the build of the cyanogenmod itself. as a matter of fact you will download the Google's Android source without the cyanogenmod modifications. if you want to build the cyanogenmod itself from source you shoshould look at the following section (2. * of this document) "Building for passion/Nexus One ". even if you don't go for these targets it shoshould be a good help.
Beware! Inexperienced users may brick their phones!
These instructions have only been tested4.2.10.1On25 dec 2009.This information may be out-of-date.
These instructions are forDebian/Ubuntu 32bit System. If you have a different platform, more information can be found here and here.
Install cyanogenmod on your phone
- Install cyanogenmod on your phone.
Take a backup
Better safe than sorry, boot into recovery and take a backup of your working phone.
Install Repo
- Install the various tools you will need.
sudo aptitude install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
And for 64bit only:
sudo aptitude install ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
- Make sure you have a/bin directory in your/Home Directory
cd ~/
mkdir bin
cd bin
echo $PATH
You shoshould see something like '...:/home/user_name/bin:...' in a line of text. If you don't see this, try restarting your computer.
- Download repo and make it executable
curl http://android.git.kernel.org/repo >~/bin/repo
chmod a+x ~/bin/repo
- Create a directory to hold you working files:
mkdir ~/mydroid
cd ~/mydroid
- Download the latest repo:
repo init -u git://android.git.kernel.org/platform/manifest.git
If everything was successful, you should see a message like 'repo initialized in/mydroid'
- Next, get the latest files:
repo sync
This step may take a while.
- Create an environment variable denoting the location of the android toolchain as follows:
export CCOMPILER=/home/$USER/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
Prepare kernel from source
- Create a new directory in which to place the kernel source
mkdir androkern
- Enter the kernel directory
cd androkern
- Download the kernel
git clone git://github.com/cyanogen/cm-kernel.git
- Enter the source directory
cd cm-kernel
- Retrieve a kernel. config file. This can be pulled from the phone or from a boot. img
- Retrieve a working kernel config from your phone:
adb pull /proc/config.gz /home/user_name/androkern/cm-kernel/config.gz
- Unzip the config.gz and rename it to. config
gunzip config.gz && mv config .config
- Alternatively, you can pull the. config from the Newest boot. img
scripts/extract-ikconfig boot.img > .config
- Run
make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig
Provide answers to the questions it asks, if any, or just keep pressing enter to accept defaults.
- Customize the kernel
make ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig
- Make the build
make ARCH=arm CROSS_COMPILE=$CCOMPILER
This step may take from minutes to hours.
At this point you shoshould have a kernel stored in cm-kernel/ARCH/ARM/boot/zimage
Build cyanogenmod
cd ~/mydroid
source build/envsetup.sh
- Now you need choose which product you want to build, you can list all buildable product
sed -n -e "s/^add_lunch_combo//gp" vendor/*/vendorsetup.sh
lunch cyanogen_dream_us-eng
This load cyanogenmod Product
make -j4
Build process is long... take a pizza, a beer and watch TV. the-J flag specifies how many threads the compiler shocould use. rule of thumb is # of processors + 1 but will vary with who you ask.
Next soon.
Complete the build
You need to merge this file with a working cyanogen ramdisk in order to create a boot image suitable for flashing.
Follow these instructions here in order to do so.
If all goes well, you shoshould now be running your own cym cyanogenmod Kernel on your phone.
If you are building for Nexus One then you shoshould use -- Base 0x20000000 when running mkbootimg.
Building for passion/Nexus One
This will explain how to build cm, using the code from cyanogen's GitHub repository.
Obtaining the code
Read the introduction and how-to on obtaining the source from the http://source.android.com/This is quite similar but won't cover the basics.
We use cyanogens manifest file instead of theirs, it has all the good stuff in it.
Initialize Your repository
mkdir ~/android-cm
cd ~/android-cm
repo init -u git://github.com/cyanogen/android.git -b eclair
repo sync
The sync can take quite some time, it pulls about 2gig of files.
Create Build Environment
cd ~/android-cm
source build/envsetup.sh
Build ADB (only required if you haven't built it yet)
make -j4 adb
Configure build
- Now you need choose which product you want to build, you can list all buildable products
sed -n -e "s/^add_lunch_combo//gp" vendor/*/vendorsetup.sh
lunch cyanogen_passion-userdebug
Select a cyanogenmod build type
Get proprietary files from your device
cd ~/android-cm/vendor/google/passion
./extract-files.sh
cd -
Build it
Looks like we're ready to build
- Start building
make -j4
Now this takes from 30 min to 2 hours, depending on your computer.
Once ready, all files will be placed in
~/android-cm/out/target/product/passion
You can now create a ROM or just flash them with fastboot like this
cd ~/android-cm/out/target/product/passion
fastboot flash system system.img
fastboot flash boot boot.img
fastboot flash userdata userdata.img
fastboot reboot
Todo
- Todo: Explain how to compile WLAN. KO in order to enable wifi.
- Todo: Explain how to provide other kernel modules for a chroot Debian install on the G1.
- Todo: Explain how to compile the rest of cyanogenmod
Retrieved from "http://wiki.cyanogenmod.com/index.php/Building_from_source"