Android Development On ORBIT - Device setup
- Setup device: In order to flash a custom kernel on your Android device, it must be rooted. To root an HTC device, you can use unrevoked3. Otherwise, you will probably be able to use SuperOneClick.
Once you are rooted, you may use the recovery to flash new kernels, as well as custom ROMS. The only prerequisite is that you have ClockworkMod recovery installed. Download ROM Manager from the Android market, and select "Flash ClockworkMod Recovery". Now you have a custom recovery installed that will let you flash custom kernels. The complete guide is available http://www.androidpolice.com/2010/05/08/complete-guide-how-to-flash-a-custom-rom-to-your-android-phone-with-rom-manager-full-backup-restore/ here].
- Setup environment:
Load the Android development image onto a node and ssh into it. You will have to export some path files:
PATH=$PATH:/root/android-sdk-linux_x86/platform-tools/:/root/android-sdk-linux_x86/tools export PATHWhich will allow you to use adb, emulator, fastboot and other commands from any location.
- Get Source Code
The CyanogenMod? source code is available at https://github.com/CyanogenMod/cm-kernel. If you would like to use a different kernel, you can find most active ones at http://forum.xda-developers.com in the Android Development forum for your device. You may have to download and extract the source code archive, or you can use git:
git clone git://github.com/CyanogenMod/cm-kernel
- Configure Kernel
Now we need to configure the kernel with all the features required. The default configuration files are located in arch/arm/configs, copy the correct file to .config in the kernel directory.
cp arch/arm/configs/cyanogen_supersonic_defconfig .configYou can edit this with a text editor, or use make ARCH=arm CROSS_COMPILE-arm-none-eabi- menuconfig. Change CONFIG_LOCALVERSION so you can identify your kernel in About Phone on your device. If you manually edited this file, you can run
make ARCH=arm CROSS_COMPILE=arm-none-eabi- menuconfigand go to Load Alternate Config file and select .config.
- Compile Kernel
To compile the kernel, just run
make ARCH=arm CROSS_COMPILE=arm-none-eabi- -j8If there is an error while compiling, that line will be prefixed by , but the compilation will continue. Always run
make cleanbefore recompiling. If you get an error like 'Selected processor does not support ARM mode …' then run make with the extra parameter:
make ARCH=arm CROSS_COMPILE=arm-none-eabi- EXTRA_AFLAGS=-mfpu=neon -j8Most other errors can be resolved with Google. If your kernel compiled successfully, you will have a zImage file in arch/arm/boot, and it will print the path to the kernel modules that were also compiled.
- Make an update .zip file
ClockworkMod? recovery installs .zip packages, so you will need to put everything into a template before you can flash it. Move to a different directory and get this source:
git clone git://github.com/choochootrain/kernel-templateIt is a fork of koush's AnyKernel? template that is modified for the HTC EVO (Supersonic). If you are using a different device, you can use koush's template or modify this one. The template contains a precompiled zImage in kernel/ , kernel modules in system/lib/modules/ , and an updater-script in META-INF/com/google/android/. Replace the zImage and kernel modules with yours. The updater-script is what is run to modfiy your device. If first dumps the kernel modules onto your phone, and then unpacks the current boot partition from the phone and repacks it with your zImage and then writes it to the boot partition.
Navigate to the template directory and zip the files:zip -r [name goes here].zip *
Make sure that the .zip contains kernel/, system/, and META-INF/ and not the whole containing directory. Now you need to push the .zip onto the device's sdcard.adb push [zip file] /sdcard/[zipfile]
- Flash kernel Now you need to boot into recovery to flash the .zip. You can do this from ROM Manager, or by holding power and volume down (on most phones) when you turn the phone on and going to recovery from the bootloader. Make sure you have a backup in case the kernel doesnt boot. Before you flash the kernel, you need to wipe the dalvik cache which is located under Advanced from the main menu. Once the dalvik cache is wiped, you can install the .zip file. Go to Install zip from sdcard > choose zip from sdcard > [zip file] > yes and then the updater-script will be run. If there is an error and it aborts installation, check the updater-script file. If the installation completes, you can try rebooting your device. It will take longer to boot because it has to rebuild the dalvik cache
- Troubleshooting kernel
If the kernel causes your phone to hang on the splash screen or enters a boot loop, your kernel most likely has a problem. Pull the battery out, enter recovery by holding power and volume down and select recovery. Since the kernel only affects the boot partition, you can do a partial restore to fix your device. Go to Backup and restore > Advanced restore > [your latest backup] > boot.img
Now your phone is back in working condition. You can see error messages during installation by following the log file after you install the .zip file.
adb shell cd tmp cat recovery.logYou can see error messages while the phone is running through dmesg:
adb shell dmesg