Thread (8 messages) 8 messages, 3 authors, 2012-06-09

Setting up development environment using QEMU.

From: Aft nix <hidden>
Date: 2012-06-09 10:19:15

On Fri, Jun 8, 2012 at 8:20 PM, Adam Lee [off-list ref] wrote:
quoted
On Fri, Jun 8, 2012 at 6:46 PM, Adam Lee [off-list ref] wrote:
quoted
On Fri, Jun 08, 2012 at 06:08:44PM +0600, Aft nix wrote:
quoted
Sure about this? Check the output of `file vmlinux`
You were right then.

$file vmlinux
$vmlinux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
statically linked, not stripped
quoted
What's the arch of your host system, and your toolchain?
$uname -ar
$Linux kernel.vbox 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT
2011 x86_64 x86_64 x86_64 GNU/Linux
$gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
So, just add ARCH var when you making, like this:

make ARCH=i386 menuconfig
make ARCH=i386 bzImage

Tested OK.
Thank you for the tips. qemu is booting the kernel now. But it stops
with a kernel panic.
From qemu console,
[    2.209887] EXT3-fs (sda): mounted filesystem with writeback data mode
[    2.210566] VFS: Mounted root (ext3 filesystem) readonly on device 8:0.
[    2.211393] Freeing unused kernel memory: 456k freed
[    2.242325] Write protecting the kernel text: 6240k
[    2.242614] Write protecting the kernel read-only data: 1820k
[    2.248007] Kernel panic - not syncing: No init found.  Try passing
init= option to kernel. See Linux Documentation/init.txt for guidance.
[    2.248492] Pid: 1, comm: swapper/0 Not tainted 3.4.0+ #3
[    2.248596] Call Trace:
[    2.249743]  [<c160db4f>] panic+0x81/0x17e
[    2.249843]  [<c10012d5>] init_post+0x75/0xb0
[    2.249942]  [<c183a61a>] kernel_init+0x1e0/0x1ea
[    2.250028]  [<c183a3df>] ? parse_early_options+0x35/0x35
[    2.250237]  [<c183a43a>] ? repair_env_string+0x5b/0x5b
[    2.250326]  [<c1616cd6>] kernel_thread_helper+0x6/0xd

I've started reading Documentation/init.txt, But i'm not understanding
well. It seems the "init" binary is missing which should be on the
root file system.

the sell script i'm using to launch qemu is given below :

#!/bin/bash
# by, uberj

KERNEL=/mnt/build/linux-2.6/arch/i386/boot/bzImage

usage(){
    echo "./startup.sh <group_port> <hdd image>"
    echo "Kernel image is $KERNEL."
}

if [ $# != 2 ]
then
    usage
    exit
fi
QEMU_BIN=/usr/bin/qemu
HDD=$2
SSH_PORT=$((5100+$1))
GDB_PORT=$((5200+$1))
DEV_CONSOLE=stdio
VNC_PORT=$1

echo "===SSH Port=== $SSH_PORT"
echo "===GDB Port=== $GDB_PORT"
echo "===VNC Port=== $VNC_PORT"

    $QEMU_BIN \
    -cpu qemu64 \
    -net nic,model=e1000 \
    -net user \
    -vnc :$VNC_PORT \
    -gdb tcp::$GDB_PORT \
    -kernel $KERNEL \
    -hda $HDD \
    -append "root=/dev/sda console=ttyS0" \
    -redir tcp:$SSH_PORT::22 \
    -serial $DEV_CONSOLE \

I have made my root FS by following method :

$losetup /dev/loop0 rootfs.img
$mkfs -t ext3 /dev/loop0

My understanding is i have to put the init binary in my root fs. But
i'm clueless about how to do that?

Cheers.




--
Regards,
Adam Lee
--------------------------------
E-mail: adam8157 at gmail.com
Website: http://adam8157.info
--------------------------------


-- 
-aft
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help