I haven't seen this all written down in one place so I thought I'd put it together in a single post. Here's one way to build and boot an android kernel.
- Get the android repo and build it - you'll need to build system/core/fastboot if it isnt built by default - your tools will be in a directory like out/host/linux-x86/bin. You'll probably want these in your path. - under linux you'll need to run fastboot and adb as root to access the usb device - Get the ramdisk image from your phone. We'll boot a kernel using the existing ramdisk. - I used JFreke's recovery image. Get http://andblogs.net/downloads/JFv1.41_RC33.zip - unzip JFv1.41_RC33.zip and extract recovery.img from it - put your phone into fastboot mode and hook it up using a usb cable - on adp1 power on while holding camera, then when its on hit back. - run "fastboot boot recovery.img" to boot into recovery mode. - after it boots hit ALT+B to backup your flash to your sdcard. - hit HOME+BACK to reboot your phone normally - use "adb pull" to get the boot.img from your sdcard - it will be under /sdcard/nandroid. the path will vary based on the date and your device - "adb pull /sdcard/nandroid/HTxxxxxxx/2009xxxx-xxxx/boot.img - Extract the ramdisk.img from the boot.img - grab the attached getramdisk.py and run it - getramdisk.py boot.img; mv ram ramdisk.img - you can manually extract the data if you dont have python. Offsets 8 and 16 in the file have byte lengths of the kernel and ramdisk. Round up to 2048-byte page sizes. The format is 1 page header + kernel + ramdisk + .... - if kernel is 779 pages and ramdisk is 73 pages then: - dd if=boot.img of=ramdisk.img bs=2048 skip=780 count=73 - Get the kernel sources and build. (my android repo is in /mydroid) $ git clone git://android.git.kernel.org/kernel/msm.git $ cd msm $ export PATH=$PATH:/mydroid/prebuilt/linux-x86/toolchain/arm- eabi-4.2.1/bin/ $ ARCH=arm CROSS_COMPILE=arm-eabi- make - Boot the phone with your new kernel - go into fastboot mode again - run "fastboot boot arch/arm/boot/zImage ramdisk.img" - you can use mkbootimg to create a boot.img from the kernel and ramdisk and flash it to your device using fastboot if you wish to permanently boot your new kernel or you can use "fastboot flash:raw boot zImage ramdisk.img" to automatically create the boot.img and flash it ---- getramdisk.py ---- #!/usr/bin/env python """ extract a ramdisk from a boot image. Usage: getramdisk.py boot.img Outputs to "ram" """ import sys, struct if len(sys.argv) != 2 : print "usage: %s fn" % sys.argv[0] raise SystemExit(1) fn = sys.argv[1] pgsz = 2048 f = file(fn, "rb") hdr = f.read(pgsz) kernlen,dummy,ramlen = struct.unpack("<III", hdr[8:20]) kernpg = (kernlen + pgsz - 1) / pgsz rampg = (ramlen + pgsz - 1) / pgsz f.seek(pgsz * (1+kernpg)) d = f.read(pgsz * rampg) of = file("ram", "wb") of.write(d) of.close() ---- end getramdisk.py ---- --~--~---------~--~----~------------~-------~--~----~ unsubscribe: android-kernel+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-kernel -~----------~----~----~----~------~----~------~--~---