What is the need for porting kernel image and rootfs separately?

Ayyappan Muthukrishnan
I bought mini 2440 2-3 years back.
In that purchase CD the kernel image and root filesystem are provided
separately and instructed to port separately.

Why it is so? Doesn't the root filesystem(yaffs2 type) contain the kernel
image in its filesystem hierarchy before building yaffs2 filesystem image?

Please reply for my doubt!

sean_h
The sequence of start-up events are: bootloader, kernel  and in the final
stages of the kernel start-up is the mounting of the root file system. "
The Linux kernel itself doesn't dictate any filesystem structure, but user
space programs do expect to find files ..... " Building Embedded Linux
Systems: Yaghmour,Masters,Ben-Yossef and Gerum.

Ayyappan Muthukrishnan
Yes that sequence was while mounting when the board is ready to boot
contained with all files. But my doubt is while flashing the files in the
board why we have to flash kernel and then rootfs image. according to
filesystem hierarchy standard the / directory or /boot directory contains
kernel image. Then we can flash the rootfs image itself which contains
kernel image in it right? why we are flashing kernel image at one time and
rootfs image at another time for mini2440 with the bootloader provided?

davef
Where do you find the kernel image in the mini2440 distro?  It has been
years since I used that image.

I know about vmlinux in Ubuntu etc http://en.wikipedia.org/wiki/Vmlinux but
not any mini2440 distro, that I know of

Ayyappan Muthukrishnan
Hi davef,

If you look at the download manual document for Linux dowloaded from this
page http://www.friendlyarm.net/downloads it says that through DNW tool we
have to use option 'k' for downloading kernel image and 'y' for downloading
yaffs2 root filesystem image. U can check with that..

davef
Sorry, I see I didn't ask the question correctly.

Where do you find the kernel image inside the root filesystem image?

davef
according to filesystem hierarchy standard the / directory or /boot
directory contains kernel image.

Re-reading carefully I now understand the point you are trying to make.  I
was not aware of this "standard".

Ayyappan Muthukrishnan
Can anybody please clarify my above doubt correctly?

sean_h
A guess: possibly the non bootable static linked kernel, vmlinux, for
debugging/symbol table that is stored in the rootfs???

Juergen
> Why it is so?

Just simple: if the kernel is part of the root filesystem the bootloader
must support the filesystem to be able to extract and run the kernel from
it.

How many filesystems should a bootloader support? And what about new
filesystems (UBIFS versus JFFS2) or filesystem improvements and bug fixes?

If you handle both components separately you can use whatever filesystem
you like and your kernel supports. And the bootloader and its capability
doesn't matter.

Ayyappan Muthukrishnan
Hi Juergen,

Then my questions are  

1:doesnot the kernel image reside in / directory in mini2440 board ? 

2: or if it resides in / directory how the offset is calculated to exactly
flash the kernel image in the / directory because we are giving physical
address as arguments in bootloader and not the directory information?

Please reply!

Juergen
Ayyappan,

what do you mean with "/ directory"? In our world the '/' is the root of
the currently mounted and used file system in a running system. This is
only a "view" into a filesystem, independent from the media this filesystem
is stored (can be a RAM disk, a JFFS2 on a flash, an EXT4 on an SD card and
so on).

To "2:" I believe you are talking about a partitioned flash device, don't
you? The offset into the NAND can't be calculated. Its defined and you must
know the offsets.

Ayyappan Muthukrishnan
So with your reply my understanding is "any directory in filesystem is not
fixed to a physical address they are only a relative location with respect
to the root of the currently mounted and used filesystem in a running
system". 

Am I right? Please correct if not.

And I am talking about partitioned flash device only and as you said offset
into the NAND can't be calculated and its defined and I must know the
offsets, where can I fix that address for any new board? Is there any logic
behind that?

And one more question if my bootloader has the capability for extracting
the kernel from my filesystem type, is it ok to place kernel image in /
directory or / boot directory and then build rootfs image and flash the
rootfs image containing the kernel image within itself at the same time?

Please reply!

Juergen
Your first question: hard to answer. In a Linux system you can mount
filesystems on your needs and elsewhere. Lets think about two partitions in
your NAND: one for the root filesystem and one for the home directories.
Each of these independent filesystems has its own '/'. It depends on the
way you mount them at runtime which '/' is the root from the Linux point of
view.

root filesystem        data filesystem
 /.                        /.
  |-bin/                    |-user_a
  |-etc/                    |-user_b
  |-home/                   |-user_c
  .                         .
  .                         .
  .                         .
At runtime:

 /. <- root filesystem's root and system's root
  |-bin/
  |-etc/
  |-home// <--- data filesystem's root
  .      |-user_a
  .      |-user_b
  .      |-user_c

So: about what '/' you are talking about?

> [...9 I must know the offsets, where can I fix that address

Don't know, because I don't know what you are doing.

> Is there any logic behind that?

A NAND memory has a special internal data layout. You must ensure your
partitions honor this layout. Otherwise it will not work. So the
restrictions where the offsets of the partitions are located depend on the
NAND type you are using (and must also honor bad blocks and so on).

Your last question: no idea, because I don't know what you are doing.

Ayyappan Muthukrishnan
1) first question was about root filesystem's root and system's root.

2) "I must know the offsets, where can I fix that address"

What I come to ask is how to decide physical address of kernel image and
rootfs image to be resided while flashing? A generic answer or the point of
reference to study will be good for me ,atleast how it was decided in
mini2440 is needed.

3) Is there any logic behind that?

2nd question answer will be useful for this question.

4) last question is about the following. 

I have built uboot bootloader image for mini2440 and I am trying to build
rootfs image of jffs2 type for learning purpose. So if uboot.bin supports
jffs2 type can I have kernel image within rootfs image and flash kernel
image along with rootfs image at the same time(if memory is also available
for both )as you said "the bootloader must support the filesystem to be
able to extract and run the kernel from it."

Please reply!

Ayyappan Muthukrishnan
for --> 4) last question is about the following. 

I planned to place kernel image in / directory in root filesystem hierarchy
and then build rootfs image in jffs2 type.