Sunday, April 29, 2012

[HOW TO] Inject Android kernel or zImage in to Boot Image (boot.img)

After you successfully build  android kernel 3.0.8 of TI-Omap 3630 devices then the next step is inject that zImage file into the boot.img. Your device should be rooted, and the software required is:
  •  Linux Ubuntu (if you use windows so you can intall Ubuntu using Oracle VM VirtualBox or wubi or by way of dual booting or other means, please ask for directions to Google)
  • BootScript Perl and mkbootimg, please download here.
  • Prepare a cup of coffee and a plate of fried bananas
Once everything is ready, use this stance:
1. Create two directories and sub directories:

$ mkdir -p old-boot/ramdisk
$ mkdir new-boot
2. Copy the zImage file which ye have made to the "new-boot"
3. Put your old directory boot.img to the "old-boot"
4. Extract the directory bootimgutils.zip to "old-boot"
5. Split boot.img with the command:
$ cd old-boot
$ ./boot.img split_bootimg.pl

                or
$ perl split_bootimg.pl boot.img
there will be an appearance of more or less like this (depending on the type of your device):
Page size: 2048 (0x00000800)
Kernel size: 1388548 (0x00153004)
Ramdisk size: 141 518 (0x000228ce)
Second size: 0 (0x00000000)
Board name:
Command line: no_console_suspend = 1
Writing boot.img-kernel ... complete.
Writing boot.img-ramdisk.gz ... complete.
of the split will produce two files, namely boot.img-kernel and boot.img-ramdisk.gz
boot.img-kernel = kernel/zImage
boot.img-ramdisk = ramdisk
6. If you want to edit the ramdisk then unpack the boot-img-ramdisk.gz with the following command (if you do not intend to edit the ramdisk, skip this step):
$ cd ramdisk
$ gzip-dc .. / boot.img-ramdisk.gz | cpio-i
unpack the boot.img-ramdisk will produce directories and files. more or less as follows:

Directories:
- Bootimages
- Chargerimage
- Data
- Dev
- Proc
- Sbin
- Sys
- System

The files:
- default.prop
- init
- init.goldfish.rc
- init.rc
- ueventd.goldfish.rc
- ueventd.lge.rc
- ueventd.rc
For example: change ro.secure = 0 in the file default.prop

- After you've finished editing the ramdisk, then repack ramdisk (do not remember any other file or directory in the ramdisk directory during repack).
$ find. | cpio -o -h newc | gzip> .. /newramdisk.cpio.gz
7. Then we repack zImage and ramdisk into a new boot.img:
$ cd ..
$ ./mkbootimg --kernel /home/your user_id/new-boot/zImage --ramdisk /home/your user-id/old-boot/newramdisk.cpio.gz --base 0x80000000 --pagesize 2048 -o /home/user-id/new-boot/boot.img
or if you do not edit the ramdisk, then use this command:
$ ./mkbootimg --kernel /home/your user_id/new-boot/zImage --ramdisk /home/your user-id/old-boot/boot.img-ramdisk --base 0x80000000 --pagesize 2048 -o /home/user-id/new-boot/boot.img

note: the command line "--base 0x80000000 --pagesize 2048" depends on type of your device.
Meaning that the command is:
- zImage file in the directory 'new-boot "
- Ramdisk is in the directory "old-boot"
- Its output will be stored in the directory 'new-boot "

Completed, a new boot.img file stored in the directory new-boot and you are ready to install into your device

1 comment:

  1. hi
    i have this problem with me galaxy i9000
    FAILED TO MOVE APPLICATION
    NOT ENOUGH MEMORY
    I HAVE 13 GB Free on my phone and i can't not move app usb storage
    HEPL PLZ....

    ReplyDelete