wiki:TBR/UserManual/QemuTutorial
Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Version 10 (modified by Cocanlucian, on 08/14/09 at 19:18:42) (diff)

QemuTutorial

In order to be able to run RTEMS you need an execution environment. The easieast way is to use QEMU and mtools to emulate a PC. This is a tutorial showing how to get RTEMS running on QEMU and also how to make use of the RTEMS FAT filesystem (in order to get the trace file on your host filesystem). This tutorial assumes that you have successfully built RTEMS on your computer. TODO Add a tutorial on how to start with RTEMS too. It would be great to have all this information in one place.

  1. Clearly, QEMU needs to be installed on your computer.

sudo yum install qemu - for Fedora users sudo apt-get install qemu - for Ubuntu users

You can always install QEMU using the latest sources.

  1. Also, you will need mtools, which is a collection of utilities to access MS-DOS disks from Unix without mounting them.

sudo yum install mtools - for Fedora users sudo apt-get install mtools- for Ubuntu users

You can always install mtools using the latest sources.

  1. Now we need a floppy disk image that has GRUB on it.

cd ~/where_you_want wget http://www.thoughtwave.com/floppy.img.bz2 bunzip2 floppy.img.bz2

  1. Before you can access this image file you must create a mtools configuration file. Create and then open ~/.mtoolsrc with your favourite editor and add the following information:

drive a: file=path_to_the_floppy_image_file fat_bits=12 cylinders=80 heads=2 sectors=18 mformat_only

Now you should be able to see the following information if you type mdir a:

Volume in drive A has no label Directory for A:/ kernel gz 670491 2009-08-14 13:59 kernel.gz stage2 30816 1998-05-13 11:56 stage2 grubmenu 45 2006-05-31 8:19 grubmenu

3 files 701 352 bytes

755 200 bytes free

  1. This GRUB disk image is designed to boot any compressed kernel in the root directory called kernel.gz, meaning that to install hello.exe, you simply compress it and copy it into your virtual disk image.

cd ~/where_you_want cat hello.exe | gzip -9 > kernel.gz mcopy kernel.gz a:

  1. Create a disk image of 20 MBytes and create a MS-DOS FAT16 file system on it:

dd if=/dev/zero of=hdd.img bs=1024 count=20160 mkdosfs -F 16 hdd.img

  1. Open your ~/.mtoolsrc file and add the following information:

drive c: file="path_to_hdd.img"

You should now be able to access the hard disk image that you have created, using mtools. For example, typing mdir c: should list all the files on your hard disk image.

  1. Now start QEMU using the following command (use the disk image created):

qemu -serial stdio -boot a -m 128 -fda 'path to floppy.img' -hda 'path to the hdd.img' --no-reboot

The list of the QEMU options used in this command it's explained here?.