Changes between Initial Version and Version 1 of Documentation/hAndroid/Kernel


Ignore:
Timestamp:
Jul 5, 2011, 5:37:29 PM (13 years ago)
Author:
choochootrain
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/hAndroid/Kernel

    v1 v1  
     1= Android Development On ORBIT =
     2
     3== 0. Setup device ==
     4
     5In order to flash a custom kernel on your Android device, it must be rooted.
     6
     7To root an HTC device, you can use [http://unrevoked.com/recovery/ unrevoked3]. Otherwise, you will probably be able to use [http://forum.xda-developers.com/showthread.php?t=803682 SuperOneClick].
     8
     9Once 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].
     10
     11== 1. Setup environment ==
     12
     13[http://www.orbit-lab.org/wiki/Documentation/Android Load the Android development image] onto a node and ssh into it.
     14
     15You will have to export some path files:
     16
     17{{{
     18PATH=$PATH:/root/android-sdk-linux_x86/platform-tools/:/root/android-sdk-linux_x86/tools
     19export PATH
     20}}}
     21
     22Which will allow you to use adb, emulator, fastboot and other commands from any location.
     23
     24== 2. Get Source Code ==
     25
     26The CyanogenMod source code is available at https://github.com/CyanogenMod/cm-kernel.
     27
     28If 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.
     29
     30You may have to download and extract the source code archive, or you can use git:
     31
     32{{{
     33git clone git://github.com/CyanogenMod/cm-kernel
     34}}}
     35
     36== 3. Configure Kernel ==
     37
     38Now we need to configure the kernel with all the features required. The default configuration files are located in arch/arm/configs
     39
     40Copy the correct file to .config in the kernel directory.
     41
     42{{{
     43cp arch/arm/configs/cyanogen_supersonic_defconfig .config
     44}}}
     45
     46You 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.
     47
     48If you manually edited this file, you can run
     49{{{
     50make ARCH=arm CROSS_COMPILE=arm-none-eabi- menuconfig
     51}}}
     52
     53and go to Load Alternate Config file and select .config.
     54
     55== 4. Compile Kernel ==
     56
     57To compile the kernel, just run
     58{{{
     59make ARCH=arm CROSS_COMPILE=arm-none-eabi- -j8
     60}}}
     61
     62If there is an error while compiling, that line will be prefixed by **, but the compilation will continue.
     63
     64Always run
     65{{{
     66make clean
     67}}}
     68before recompiling.
     69
     70If you get an error like 'Selected processor does not support ARM mode ...' then run make with the extra parameter:
     71{{{
     72make ARCH=arm CROSS_COMPILE=arm-none-eabi- EXTRA_AFLAGS=-mfpu=neon -j8
     73}}}
     74
     75Most other errors can be resolved with Google.
     76
     77If 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.
     78
     79== 5. Make an update .zip file ==
     80
     81ClockworkMod recovery installs .zip packages, so you will need to put everything into a template before you can flash it.
     82
     83Move to a different directory and get this source:
     84{{{
     85git clone git://github.com/choochootrain/kernel-template
     86}}}
     87
     88It 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.
     89
     90The template contains a precompiled zImage in kernel/ , kernel modules in system/lib/modules/ , and an updater-script in META-INF/com/google/android/
     91
     92Replace 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.
     93
     94navigate to the template directory and zip the files:
     95{{{
     96zip -r [name goes here].zip *
     97}}}
     98Make sure that the .zip contains kernel/, system/, and META-INF/ and not the whole containing directory.
     99
     100Now you need to push the .zip onto the device's sdcard.
     101{{{
     102adb push [zip file] /sdcard/[zipfile]
     103}}}
     104
     105== 6. Flash kernel ==
     106
     107Now 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.
     108
     109Make 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.
     110
     111Once 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.
     112
     113If there is an error and it aborts installation, check the updater-script file.
     114
     115If the installation completes, you can try rebooting your device.
     116
     117It will take longer to boot because it has to rebuild the dalvik cache
     118
     119== 7. Troubleshooting kernel ==
     120
     121If 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.
     122
     123Since 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
     124
     125Now your phone is back in working condition.
     126
     127You can see error messages during installation by following the log file after you install the .zip file.
     128{{{
     129adb shell
     130cd tmp
     131cat recovery.log
     132}}}
     133
     134You can see error messages while the phone is running through dmesg:
     135{{{
     136adb shell
     137dmesg
     138}}}