what is the difference between zImage (kernel) and boot.img? and question about 'fastboot boot'

16,770 views
Skip to first unread message

kenny

unread,
Mar 26, 2012, 8:08:18 PM3/26/12
to android-...@googlegroups.com
Hi.

I am confused about the zImage and boot.img and how 'fastboot boot' works..

after I compiled the kernel, it generates the zImage.
can I use the zImage to boot the phone?
eg. 'fastboot boot zImage'  
or do I have to compile with the whole android system to create boot.img ?
what is the difference between zImage and boot.img?

thanks for your help!

Jean-Baptiste Queru

unread,
Mar 27, 2012, 2:04:28 PM3/27/12
to android-...@googlegroups.com
boot.img contains a ramdisk image after the kernel, which becomes the
root filesystem.

I'm not sure which of the two is used by fastboot boot.

JBQ

> --
> You received this message because you are subscribed to the "Android
> Building" mailing list.
> To post to this group, send email to android-...@googlegroups.com
> To unsubscribe from this group, send email to
> android-buildi...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-building?hl=en

--
Jean-Baptiste M. "JBQ" Queru
Software Engineer, Android Open-Source Project, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.

ruZZ

unread,
Mar 27, 2012, 3:00:59 PM3/27/12
to android-...@googlegroups.com
You need to fastboot boot the boot.img. 

I'm not sure if there is a shortcut to create the boot.img, but once you've already compiled the system it's often one of the first things built in the next build so if you arent building often, just build with the system.

You will have to build once at least since you need to create the files which will be part of the initial ram file system image.

Interestingly, some systems beg to differ (samsung cough cough), and the initramfs is baked into the zImage. This actually makes it simpler since you use your usual kernel make system, just link it with a pre-built initramfs. They don't use fastboot though (samsung galaxy nexus does use fastboot though).

There are ways to unpack a pre-built boot.img, replace the zImage and re-pack, eg: 


Even if you don't use this method, glancing over it may be interesting. 

ogdobber

unread,
Mar 27, 2012, 3:03:53 PM3/27/12
to Android Building
to fastboot you will need to have a boot.img (e.g. fastboot boot
boot.img). to create search google for "mkbootimg"

Magnus Bäck

unread,
Mar 27, 2012, 3:40:57 PM3/27/12
to android-...@googlegroups.com
On Tuesday, March 27, 2012 at 15:00 EDT,
ruZZ <ruz...@gmail.com> wrote:

> You need to fastboot boot the boot.img.

"fastboot boot zImage" should work fine if you just want to update the
kernel. IIRC, "fastboot boot" loads the supplied boot.img (or generates
one from a kernel ELF image and optionally the initramfs) into RAM and
reboots the device without touching the flash memory.

> I'm not sure if there is a shortcut to create the boot.img, but once
> you've already compiled the system it's often one of the first things
> built in the next build so if you arent building often, just build
> with the system.

make out/target/product/$TARGET_PRODUCT/boot.img

will build just boot.img (even from a clean build tree). Add -j option
to taste, obviously.

[...]

--
Magnus B�ck
ba...@google.com

Mathew Says IdareYou

unread,
Mar 27, 2012, 6:42:33 PM3/27/12
to android-...@googlegroups.com

Just make bootimage works fine too

Magnus Bäck
ba...@google.com

kenny

unread,
Mar 27, 2012, 7:56:00 PM3/27/12
to android-...@googlegroups.com
Thanks for all the information!

I have a few more questions:

- when re-build whole android system with the my new 'kernel' image (everything else no change since last build), 
the following .img also get updated in addition to boot.img:
boot.img
ramdisk-recovery.img
recovery.img
system.img

Do i need to flash those into the phone too in order to use my kernel?
or flashing only the boot.img is good enough?

- what is purpose ramdisk and rootfs? initramfs ?

Thanks!

ruZZ

unread,
Mar 28, 2012, 2:06:41 AM3/28/12
to android-...@googlegroups.com
The boot.img alone is enough as long as it is compatible with the rest of your phone (if it already has the rest of your images on, it is. If it is the same android version without too many differences, it should be fine too).

initramfs=ramdisdk=rootfs.

It is a set of files used by the kernel to get the rest of the system going. 

For example, it holds the start up scripts which mount the rest of the partitions, giving the phone access to the rest of the system folder, where the rest of android is, which then starts to load up.

The recovery works on a similar principle, but instead of loading android it loads a much simpler system which  you can use to do other things on the phone, like backups and flashing other partitions. 


-ruZZ.

P.S Thanks for the heads up on boot.img make shortcuts :)
Reply all
Reply to author
Forward
0 new messages