= RTEMS on Virtualbox = You can run RTEMS in the [http://www.virtualbox.org/ 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 [http://www.virtualbox.org/wiki/Linux_Downloads 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 [http://dlc.sun.com.edgesuite.net/virtualbox/3.2.4/UserManual.pdf 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 [http://sourceforge.net/projects/tftp-server/files/tftp%20server%20multithreaded/opentftpmtV1.62.tar.gz/download 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:''' {{{ [HOME] #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 #routers=c:/RouterImages/Images #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 /home/cdcs/testbed-build/ }}} This option will map the root of the server to "/home/cdcs/testbed-build/". This means that when you access "tftp://127.0.0.1/test.exe" you are accessing "/home/cdcs/testbed-build/test.exe". You can also specify up to 8 aliases, eg: "myhome=/home/cdcs" will map "tftp://127.0.0.1/myhome/test.exe" 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: 0.0.0.0:69 }}} 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 [http://rom-o-matic.net/ 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 }}} {{{ config }}} Then a set of network parameters will be printed. '''Write Down the "gateway" parameter(eg:10.0.2.2)''' Now it is the time to test if everything is as expected... Issue the following commands: {{{ kernel tftp://10.0.2.2/test.exe }}} {{{ boot }}} Where 10.0.2.2 is the gateway parameter you wrote down earlier and test.exe is the name of your application. If everything is running fine the RTEMS application should boot. If it fails with a "permision denied" please chown and chmod your executable. If it fails with "not found" or similar please check your tftp server configuration(check your server root). = Automate the boot loader = Now we will automate the booting process. '''First go back to the bootloader configuration [http://rom-o-matic.net/ page]''', but this time select the "Customize" option. If you know what you are doing you can deselect several drivers and protocols, if not let it be. '''Now go to the "Embedded Script:" area in the bottom of the page and add this:''' {{{ #!gpxe dhcp net0 kernel tftp://10.0.2.2/test.exe boot }}} Where 10.0.2.2 is the gateway parameter you wrote down earlier and test.exe is the name of your application. Now press "Get Image" and replace the old one in the virtual machine. Next Time you boot the virtual machine the booting process will be fully automated and will be no need for interaction.