tech_log: Checking qemu init

Saturday, November 22, 2008

Checking qemu init

Here is a little tip I found on Busybox FAQ:

-----------

Busybox init isn't working!

Init is the first program that runs, so it might be that no programs are
working on your new system because of a problem with your cross-compiler,
kernel, console settings, shared libraries, root filesystem... To rule all
that out, first build a statically linked version of the following "hello
world" program with your cross compiler toolchain:

#include <stdio.h>

int main(int argc, char *argv)
{
  printf("Hello world!\n");
  sleep(999999999);
}

Now try to boot your device with an "init=" argument pointing to your
hello world program. Did you see the hello world message? Until you
do, don't bother messing with busybox init.




Once you've got it working statically linked, try getting it to work
dynamically linked. Then read the FAQ entry How
do I build a BusyBox-based system?
, and the
documentation for BusyBox
init
.

----------

I compiled it and placed it on the /hello_world in my newly filesystem image, rootfs.img, prepared for qemu (this position on fs is not so important, as long as you pass correct path to qemu):


qemu -hda rootfs.img -kernel bzImage -append "root=/dev/hda init=hello_world"

or

qemu -hda rootfs.img -kernel bzImage -append "root=/dev/hda init=/hello_world"


in my case would be the same thing, and it did the job. That way we can observe that root fs was correctly mounted, that init was called and executed correctly, and boot will here stuck because of sleep() call in hello_world.c

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home