FORUMS
Remove All Ads from XDA

[HOWTO][INFO] Update the kernel zImage in boot.img

816 posts
Thanks Meter: 470
 
By NFHimself, Senior Member on 10th November 2012, 07:48 PM
Post Reply Email Thread
Hi,

There seems to me to be the general idea that swapping kernels is just flashing a different boot.img, however, what seems to never be mentioned is that each boot.img has a unique ram disk or included set of files/folder structure. This ram disk was designed to work with a specific version of android and within that, a specific build of that version. The init.rc file could be totally different, there could be a different init compiled in, ro.secure could be 0 in default.prop, and so on.

When looking through some of the scripts out there, it is always flash boot.img, not extract the ramdisk and rebuilt boot.img first. This introduces a tad bit of randomness to the whole kernel swapping scenario.

This is an pseudo example of what I would do, if I had to swap kernels manually on the phone. I have attached the referenced phone compatible binaries. (I would normally do it from within linux on a PC)

With CWM running on your phone, start adb.

$ adb shell
# ~ cd /tmp
# /tmp dump_image /dev/block/mmcblk0p11 boot.img
# /tmp unpack boot.img
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk
# /tmp cp /sdcard/mynewkernel-zImage .
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk mynewkernel-zImage
# /tmp cat /proc/cmdline >cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp busybox vi cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp mkbootimg --cmdline cmdline.txt --kernel mynewkernel-zImage --ramdisk boot.img-ramdisk.gz -o boot.img
# /tmp flash_image /dev/block/mmcblk0p11 boot.img

the bits in green if you wanted to fix the missing [email protected] in your cmdline if applicable.

Replace the general sequence in your CWM install scripts when all you want is to swap the kernel, not potentially change the boot sequence/flags as well.

Cheers!
Attached Files
File Type: zip unpack.zip - [Click for QR Code] (214.3 KB, 1363 views)
File Type: zip mkbootimg.zip - [Click for QR Code] (217.2 KB, 963 views)
The Following 17 Users Say Thank You to NFHimself For This Useful Post: [ View ] Gift NFHimself Ad-Free
 
 
23rd November 2012, 09:26 PM |#2  
Hazem62's Avatar
Member
Flag Cairo
Thanks Meter: 60
 
More
hi

thanks for tutorial

but regarding this command :

Code:
 /tmp cp /sdcard/mynewkernel-zImage

what is mynewkernel-zImage ?
24th November 2012, 03:39 PM |#3  
NFHimself's Avatar
OP Senior Member
Flag Mount Pearl
Thanks Meter: 470
 
Donate to Me
More
Quote:
Originally Posted by Hazem62

hi

thanks for tutorial

but regarding this command :

Code:
 /tmp cp /sdcard/mynewkernel-zImage
what is mynewkernel-zImage ?

That would be whatever kernel image you wanted to replace your existing kernel with. As the ones around are in zip files with prepackaged boot.img files you would have to unzip and extract to get just the kernel part. Also, you would need any dependent libs copied over to /system/lib/[modules].

This is nothing really new, just not being done with the Atrix thus far.

Cheers!
The Following User Says Thank You to NFHimself For This Useful Post: [ View ] Gift NFHimself Ad-Free
14th January 2013, 10:54 PM |#4  
Member
Thanks Meter: 65
 
More
How do I get boot.img-ramdisk from this step

Quote:
Originally Posted by NFHimself

# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk

into boot.img-ramdisk.gz for mkbootimg? do I use the regular gzip?

Quote:
Originally Posted by NFHimself

# /tmp mkbootimg --cmdline cmdline.txt --kernel mynewkernel-zImage --ramdisk boot.img-ramdisk.gz -o boot.img

15th January 2013, 03:49 AM |#5  
If I wanted to edit and change the partition table, could I use the same method to pull and edit the partition file since it also exists in the same directory as cmdline?
16th January 2013, 12:02 PM |#6  
ravilov's Avatar
Senior Member
Thanks Meter: 1,354
 
Donate to Me
More
Quote:
Originally Posted by toyota86

do I use the regular gzip?

Yes.
16th January 2013, 11:38 PM |#7  
Member
Thanks Meter: 65
 
More
(deleted)
24th July 2016, 06:51 AM |#8  
Junior Member
Flag Lucknow
Thanks Meter: 0
 
More
Quote:
Originally Posted by NFHimself

Hi,

There seems to me to be the general idea that swapping kernels is just flashing a different boot.img, however, what seems to never be mentioned is that each boot.img has a unique ram disk or included set of files/folder structure. This ram disk was designed to work with a specific version of android and within that, a specific build of that version. The init.rc file could be totally different, there could be a different init compiled in, ro.secure could be 0 in default.prop, and so on.

When looking through some of the scripts out there, it is always flash boot.img, not extract the ramdisk and rebuilt boot.img first. This introduces a tad bit of randomness to the whole kernel swapping scenario.

This is an pseudo example of what I would do, if I had to swap kernels manually on the phone. I have attached the referenced phone compatible binaries. (I would normally do it from within linux on a PC)

With CWM running on your phone, start adb.

$ adb shell
# ~ cd /tmp
# /tmp dump_image /dev/block/mmcblk0p11 boot.img
# /tmp unpack boot.img
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk
# /tmp cp /sdcard/mynewkernel-zImage .
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk mynewkernel-zImage
# /tmp cat /proc/cmdline >cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp busybox vi cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp mkbootimg --cmdline cmdline.txt --kernel mynewkernel-zImage --ramdisk boot.img-ramdisk.gz -o boot.img
# /tmp flash_image /dev/block/mmcblk0p11 boot.img

the bits in green if you wanted to fix the missing [email protected] in your cmdline if applicable.

Replace the general sequence in your CWM install scripts when all you want is to swap the kernel, not potentially change the boot sequence/flags as well.

Cheers!

can any1 tell me how to extract boot.img-zimage for adding more drivers
24th July 2016, 10:30 AM |#9  
Senior Member
Thanks Meter: 438
 
More
Quote:
Originally Posted by Ni5hant

can any1 tell me how to extract boot.img-zimage for adding more drivers

Basically, you can't.
New drivers are either built into the kernel when it is compiled. Or built as kernel modules using the same kernel source and same compiler as the main kernel. In both cases, you need to know all about compiling a kernel.
24th July 2016, 06:52 PM |#10  
Junior Member
Flag Lucknow
Thanks Meter: 0
 
More
Quote:
Originally Posted by runekock

Basically, you can't.
New drivers are either built into the kernel when it is compiled. Or built as kernel modules using the same kernel source and same compiler as the main kernel. In both cases, you need to know all about compiling a kernel.

anyway ..i have an ARM kali 2.0 on my galaxy j7.. and i want to connect my TP-Link Tw722n wifi adapter to it....
"Dmesg | grep usb" shows the usb...bt i cant anything else with it..........any help would be appreciated
24th July 2016, 09:56 PM |#11  
Senior Member
Thanks Meter: 438
 
More
Quote:
Originally Posted by Ni5hant

anyway ..i have an ARM kali 2.0 on my galaxy j7.. and i want to connect my TP-Link Tw722n wifi adapter to it....
"Dmesg | grep usb" shows the usb...bt i cant anything else with it..........any help would be appreciated

If you are running Kali Linux on a Galaxy J7, then you are in entirely the wrong thread. This is about Android on Motorola Atrix. Try asking in a Kali Linux thread. Though I suspect the answer will be more or less the same -- that you need to learn how to compile a kernel to do anything.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes