Version 4 (modified by Cdcs, on Jun 10, 2010 at 2:29:26 AM) (diff)

RTEMS on Virtualbox

You can run RTEMS in the VirtualBox x86 virtualizer.

The main advantage of VirtualBox over other virtualizers is that it provides several board/controller emulation options, including a SATA controller and several network adapters.= Introduction =

This page describes how to setup a “one click solution” for booting RTEMS in VirtualBox; if the RTEMS application gets updated is just a matter of rebooting the virtual machine to boot the new updated application.

A solution for debugging RTEMS remotely through VirtualBox serial port is also described. = What we will need? =

  • VirtualBox
  • Etherboot
  • Opentftp
  • Socat relay= Get Virtual Box =

The first step is to get and install VirtualBox.

You can get Virtual box from here; you can download the file suited for your Linux distribution or setup the VirtualBox repository.

The pre-requirements for this installation are:

  • Qt 4.4.0 or higher;
  • SDL 1.2.7 or higher (this graphics library is typically called libsdl or similar)
  • DKMS

They should be already installed, if not install them from your distro’s repository:

yum install qt
yum install SDL
yum install dkms

Assuming that you added the VirtualBox repository you only have to issue:

yum install VirtualBox

VirtualBox installations can become quite tricky because a kernel module needs to be installed, so please refer to the VirtualBox documentation if you have any problem.

Get opentftp

Opentftp is a tftp(Trivial File Transfer Protocol) server that will enable us to boot a file from the host computer(the RTEMS application) on the virtual machine.

You can get opentftp from here. The opentftp server comes already compiled, so you only need to run it. The README explains various options for the server, including how to run it as a linux service.

We need to change the directory that is mapped in the server to the directory where our rtems applications is( In my case /home/cdcs/testbed-build/). You can do this be opening the opentftp.ini file that stores the server options. In this file find the "[HOME]" marker and place there the path to your application. This is how my file looked:

#You should specify home directory(s) here
#The home directory can be specified
#in two different ways, with alias or 
#bare names without aliases. Using alias you
#can specify upto 8 directories like
#without aliases, only one directory can
#be specified, which will become root
#directory for tftp.
#mixup of bare names and aliases not allowed
#default will be home directory of user

This option will map the root of the server to "/home/cdcs/testbed-build/". This means that when you access "tftp://" you are accessing "/home/cdcs/testbed-build/test.exe". You can also specify up to 8 aliases, eg: "myhome=/home/cdcs" will map "tftp://" to "/home/cdcs/test.exe".

You also need to change the "username=" option in "[TFTP-OPTIONS]" to your username. eg:"username=cdcs"

Once you have made these changes you are ready to run the server:

./opentftp -v -i opentftp.ini

This command should produce a similar output to the following one:

[root@cdcs opentftp]# ./opentftpd -v -i opentftpd.ini 
TFTP Server MultiThreaded Version 1.62 Unix Built 1621

starting TFTP...
username: cdcs
alias / is mapped to /home/cdcs/testbed-build/
permitted clients: all
server port range: all
max blksize: 65464
default blksize: 512
default timeout: 3
file read allowed: Yes
file create allowed: No
file overwrite allowed: No
thread pool size: 1
listening on:

Now that we have the tftp server up and running let's go to the next step...

Get the bootloader

Now we must get the bootloader that will fetch our application remotely and boot it. For this purpose we will use the etherboot bootloader.

A floppy image with the bootloader can be configured and obtained online. To do so you need to go here and select the most recent production release of gPXE.

This will lead to a configuration page with several bootloader options. For the time being just get sure that the first option(Choose an output format:) is in "Floppy bootable image" and press "Get Image".

The virtual machine

Now we must configure a virtual machine for RTEMS use.

Start VirtualBox and choose "New".

image Give a name to the virtual machine and select "Other"/"Other(Unknown)" in the first page of the virtual machine configuration.

In the second page you have to select the available memory for RTEMS(eg:128Mb).

The third configuration page will allow you to create or select a virtual disk. If you want a virtual harddisk create one and select its size. Creating a Virtual disk is not mandatory, you can still boot RTEMS without having one.

Now that we have concluded creating the virtual machine, we will need to change some options. Select the virtual machine in VirtualBox and press "Settings".The virtual machine settings page will open. This page allows to add disks, change allocated memory, change number of processors among other options.

Select "Storage" on the right panel and then press "Empty" that is underneath the "Floppy Controller". Now press the Browse button that is in front of "Floppy Device" and a new window will open. Press "Add", then change the "Filter:" option in the browse windows from "Image Files" to "All files" and select the .dsk floppy image file that you downloaded earlier.

This is how it should look:

image1 image2

In the "Network" options the "Adapter-1" shall be attached to "NAT".

Now we are ready to the next step.= First boot =

You shall now have the virtual machine configured with the bootloader floppy image and the opentftp server configured and running with the path to your application.

In VirtualBox press Start to initiate the virtual machine. The bootloader should start to run, and you have to press "Ctrl+B" to start the gPXE command line.

Once in the command line issue:

dhcp net0

Then a set of network parameters will be printed. Write Down the "gateway" parameter(eg:

Now it is the time to test if everything is as expected... Issue the following commands:

kernel tftp://

Where is the gateway parameter you wrote down earlier and test.exe is the name of your application. If everything is running fine the RTEMS applications should boot.