• XDA Forums have been migrated to XenForo. We are aware of several issues including missing threads, logins not working, and more. To discuss, use this thread.

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

NFHimself

New member
Mar 12, 2008
816
469
0
Mount Pearl
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!
 

Attachments

NFHimself

New member
Mar 12, 2008
816
469
0
Mount Pearl
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!
 
  • Like
Reactions: Hazem62

palmbeach05

Well-known member
Oct 12, 2012
4,330
1,794
113
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?
 

Ni5hant

New member
Apr 3, 2016
15
0
0
22
Lucknow
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
 

runekock

Well-known member
Apr 24, 2012
821
479
63
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.
 

Ni5hant

New member
Apr 3, 2016
15
0
0
22
Lucknow
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
 

runekock

Well-known member
Apr 24, 2012
821
479
63
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.
 

Ni5hant

New member
Apr 3, 2016
15
0
0
22
Lucknow
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.
Thnx for the answer buddy i have downloaded my kernel source and goind to recompile it...just looking for the right toolchain to download...anyways thnx for the replies
 

runekock

Well-known member
Apr 24, 2012
821
479
63
Thnx for the answer buddy i have downloaded my kernel source and goind to recompile it...just looking for the right toolchain to download...anyways thnx for the replies
BTW, this may not only be a question of drivers. The userspace networking code also needs to setup the new network port.
 

Ni5hant

New member
Apr 3, 2016
15
0
0
22
Lucknow
BTW, this may not only be a question of drivers. The userspace networking code also needs to setup the new network port.
Nopp..i have to just enable aethros driver support with cfg80211 module..and after flash dat kernel next time i can use my usb wifi adapter...although at this kernel i cant use my inbuilt wifi adapter...anyways i have. Build my kernel have to just compile it...if it will be a success i will upload it...
 
Our Apps
Get our official app! (coming soon)
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone