QEMU Build Tutorial: Difference between revisions

From coreboot
Jump to navigation Jump to search
Line 21: Line 21:
plus a Linux kernel and root filesystem and a working development environment (make, gcc, etc.).  gcc 4.0.x and 4.1.x are known to work.
plus a Linux kernel and root filesystem and a working development environment (make, gcc, etc.).  gcc 4.0.x and 4.1.x are known to work.


=== Creating FILO ===
=== Building FILO ===


Download FILO (I used filo-0.4.2.tar.bz2), decompress it, enter inside directory created.  
If you plan to build your Linux kernel and root filesystem directly into LinuxBIOS, you can skip this section.
 
Download FILO (I used filo-0.4.2.tar.bz2), decompress it, enter inside the created directory.
    
    
First invocation of make creates the default Config file.  
First invocation of make creates the default Config file.
  $ make  
  $ make


Edit this file as you like. The default configuration worked to me.   
Edit this file as you like. The default configuration worked for me.   
  $ vi Config   
  $ vi Config   


Line 34: Line 36:
  $ make   
  $ make   


You will need this file (filo.elf) to start Linux. 
You will use this file (filo.elf) as the LinuxBIOS payload later on.
This is used as a payload in LinuxBIOS, when executed it can load Linux kernel.  
 


=== Creating LinuxBIOS ===
=== Creating LinuxBIOS ===

Revision as of 23:03, 13 September 2006

Introduction

If you don't have a mainboard supported by LinuxBIOS don't worry: Qemu can help you to emulate one.

This nice tutorial was written by Alan Carvalho de Assis <acassis@gmail.com>, with additions by Ed Swierk <eswierk@arastra.com>.

While there are many ways to use LinuxBIOS to load and run a Linux kernel, this tutorial covers two of the most common:

  • LinuxBIOS with FILO as payload, using FILO to load a Linux kernel and initramfs from a hard disk image.
  • LinuxBIOS with a Linux kernel and initramfs as payload.

Requirements

You need the following software packages:

plus a Linux kernel and root filesystem and a working development environment (make, gcc, etc.). gcc 4.0.x and 4.1.x are known to work.

Building FILO

If you plan to build your Linux kernel and root filesystem directly into LinuxBIOS, you can skip this section.

Download FILO (I used filo-0.4.2.tar.bz2), decompress it, enter inside the created directory.

First invocation of make creates the default Config file.

$ make

Edit this file as you like. The default configuration worked for me.

$ vi Config   

Run make again to create filo.elf, the ELF FILO image.

$ make   

You will use this file (filo.elf) as the LinuxBIOS payload later on.

Creating LinuxBIOS

Download LinuxBIOS source code (I used LinuxBIOSv2-2394). Decompress it.

Change to directory targets/emulation/qemu-i386 and modify Config.lb to point to your filo.elf.

Return to targets directory and execute:

$ ./buildtarget emulation/qemu-i386  

Go to targets/emulation/qemu-i386/qemu-i386 and execute:

$ make  

It will create the file "qemu-bios.rom"

Rename this file to "bios.bin" and copy to your HOME directory.


Creating your disk image

Create a empty file (~ 200MB):

# dd if=/dev/zero of=disk.img bs=1M count=200 

Format it as ext2:

# mkfs.ext2 -F disk.img 

Mount it on somewhere:

# mount disk.img /mnt/rootfs -t ext2 -o loop 

Now you need copy a root filesystem to it.

I create a directory /debian and used debootstrap command to create a basic root filesystem, but you can use any root filesystem from your distro (i.e. copy one from diskboot.img):

# cp -R /debian/* /mnt/rootfs 

Open the file /mnt/rootfs/etc/inittab and change runlevel to level 1:

id:1:initdefault: 

Change to /mnt/rootfs/boot and copy your default vmlinuz and initrd:

# cp /boot/vmlinuz-2.6.16-2-686 vmlinuz
# cp /boot/initrd.img-2.6.16-2-686 initrd

Change to /root and umount /mnt/rootfs:

# umount /mnt/rootfs

Exit of root account:

# exit


Starting LinuxBIOS in Qemu

Execute Qemu using the followings parameters:

$ qemu -L ~ -hda disk.img -nographic -no-kqemu -d in_asm,exec

When appear "boot:" text enter it:

boot: hda:/boot/vmlinuz root=/dev/hda initrd=/boot/initrd console=tty0 console=ttyS0,115200