5. RTOS Guests (RT-Linux, VxWorks, On Time RTOS-32, …)

Important

You need to be familiar with chapter Hypervisor Guests - General before reading this chapter!

5.1. RTOS guests, general

Some ready to use RTOS images (containers) are provided, they are located in the respective template directory beyond /hv/templates (e.g. /hv/templages/rt-linux for RT Linux containers).

The first time, when a RTOS container is started, the RTOS Virtual Machine Framework (VMF) is loaded. Loading the VMF will also load the hypervisor configuration stored in the hv.config configuration file. This hypervisor configuration describes all guests and their related RTOS guest ID which is used to attach the guest to the VMF. In case a configuration entry has changed, all RTOS containers need to be stopped and the RTOS Virtual Machine to be reloaded. Configuration files are stored in *.config files.

5.1.1. RTOS Fileserver

The Hypervisor Host includes a file server which by default exposes the /hv/guests folder to RTOS guests.

The following configuration entry defines the root folder of the file server:

[Host\FileServer]
    "HomeDir"="/hv/guests"

The root folder is defined in /hv/config/hvbase.config for a System Manager based guest configuration or in one of the *.config files of the example guests.

This file server will use proprietary methods (using the Hypervisor’s RTOS-Library) to expose files in this folder. The RT-Linux and RTOS-32 guests include a filesystem driver for these methods.

5.1.2. RTOS guest folder

Besides the standard files described in General guest folder content, all RTOS guest folders contain the following additional file(s).

  • device.config: guest specific device configuration, you must not change this file

Additional configuration files may exist depending on the guest type and operation mode.

5.2. Example Real-time Linux guest

The initial example guest files are located in /hv/templates/example_guests. They are copied to /hv/guests/examples when running the /hv/bin/inithv.sh initialization script for the very first time.

Important

you need at least 256 Mbyte RAM for the shipped RT-Linux image. Assure the /hv/bin/inithv.sh script was executed with the appropriate RAM size.

The example Real-time Linux guest is located in /hv/guests/examples/rt-linux

Real-time Linux guest specific files are stored in /hv/guests/examples/rt-linux/files:

  • autostart.sh: RT-Linux autostart script, you may enhance this script to automatically run your RT-Linux application.

  • timesync.sh: Time-synchronization script, this will assure the RT-Linux time and date is consistent with the Hypervisor Host.

  • remote_cmd_exec.sh: Example script which is used to show how to run a RT-Linux application from within a Windows or Ubuntu guest.

5.2.1. File system access for RT-Linux guests

The Hypervisor Host file system is mounted into the /mnt/rtfiles folder of RT-Linux. The Hypervisor Host folder /hv/guests acts as the root folder for all guests and is mounted into this folder.

5.3. Example VxWorks guest

The example VxWorks guest is located in /hv/guests/examples/vxworks.

Important

The shipped VxWorks image can only be executed if it is loaded into memory at a fixed address of 64 MByte. In the default configuration this is the case. When using the System Manager tool it must be configured as the very first Real-time guest.

5.3.1. File system access for VxWorks guests

To access the Hypervisor filesystem from within VxWorks, you may use FTP.

Follow these instructions to install an FTP server in the Hypervisor in case it is not yet installed.

  • sudo apt-get install vsftpd

  • activate the entry write_enable=YES in /etc/vsftpd.conf (you need to edit it with root rights)

  • create a new entry local_root=/hv/guests

  • Restart the FTP server: sudo systemctl restart vsftpd

  • Create an FTP user target with password vxworks:
    • adduser target

    • passwd vxworks

    • You may use visudo to add the user target to the sudoers group (duplicate the root entry)

  • After executing the above steps, from within VxWorks, you should be able to access the guest folder via the VxWorks path pc:

5.4. Example On Time RTOS-32 guest

Caution

All On Time RTOS-32 example guest images are located at a fixed address of 64 MByte. Please assure, you have used the parameter -baseaddr 64 when calling inithv.sh, hv_adjmemconf or hv_resethv.

The example RTOS-32 guest is located in /hv/guests/examples/rtos-32

The guest image is selected through the osImage variable in the configuration script. By default it is the RTOS-32 loader image /hv/templates/rtos-32/Loader.bin which is set in /hv/guests/examples/rtos-32/guest_config.sh. If you want to change the RTOS-32 image, you should set the osImage variable in the user specific guest configuration script usr_guest_config.sh.

If the Loader.bin is used, the loader will use the application DLL which is defined in the following configuration section in /hv/guests/examples/rtos-32/guest.config:

[Rtos\Loader]                           ; Used by Loader.bin
     "DllName"="rtos32app.dll"          ; File or link must exist in the guest directory

By default this is a link to the effective DLL: /hv/guests/examples/rtos-32/rtos32app.dlm which by default points to the RTOS-32Demo.dlm demo application.

You may select a different application, for example the RealtimeDemo as follows:

cd /hv/guests/examples/rtos-32
rm rtos32app.dlm
ln -s files/RealtimeDemo.dlm rtos32app.dlm

5.4.1. File system access for RTOS-32 applications

From within the RTOS-32 application you may access the Hypervisor filesystem via the C: drive. The root directory is set in guest.config in section [\\Host\\FileServer]. By default, it is set to the example guest folder at /hv/guests/examples/rtos-32.

5.5. RTOS Shared Mode operation

Caution

This feature is not supported in RTOSVisor V8.1!

Using the RTOSVisor, Intel(c) VT technology allows to activate so called “Shared Mode”. In Shared Mode it is possible to run a RTOS on the same CPU as the Hypervisor Host (thus, the CPU is shared between two OSes). Please note, that hard real time for RTOS is also achieved in this mode.

Intel(c) VT-x and VT-d are hardware virtualisation extensions for Intel Processors. Please take a look at official Intel page for full description of the technology: https://www.intel.com/content/www/us/en/virtualization/virtualization-technology/intel-virtualization-technology.html

5.5.1. Activating VT

VT should be activated manually. In this example we configure 2 CPU system, where first CPU is used to run Hypervisor Host and RTOS1 (so, in shared CPU mode) and second CPU will be used to run RTOS2 (as exclusive core).

Note

Before you start to change anything in your system, please make sure, you have executed /hv/bin/inithv.sh script at least once.

This script installs necessary .deb packages, configures memory settings, reads ACPI tables and etc.

5.5.2. Linux Kernel grub parameters

IOMMU must be disabled in order to activate VT-D.

Add the following parameters to the linux kernel in grub.cfg: intremap=off intel_iommu=off maxcpus=1

Make sure these parameters have been removed: iommu=pt vfio_iommu_type1.allow_unsafe_interrupts=1

Currently only one shared cpu is supported. This is the reason, why maxcpus=1 is used.

5.5.3. Adapt .config files

  1. [Upload]

    "VersionDrv"=dword:9070000

  2. [Vmf]

    "VtAllowed"=dword:1

  3. [Rtos]

    "MemoryType"=dword:3

  4. [Rtos1]

    "MemoryType"=dword:3

  5. [Rtos\Vmf]

    "MapSystemTables"=dword:1

5.6. Achieving Hard Real-Time Capabilities

5.6.1. Background information

It is important to understand, which factors have influence to the real-time capabilities of your hardware. Most important of them are BIOS Settings (no CPU power saving modes should be activated, no CPU throttling, no variable CPU Frequency, USB Legacy support should also be disabled). System Management Interrupts (SMIs) must be also avoided.

Video Card has usually a huge impact on the real-time capabilities of the real-time system, because it can not only generate SMI but also perform huge background DMA transfers from/to DRAM memory.

For example, if you have Intel i915 video card on your Hypervisor Host, its Linux driver can produce significant interrupt/context latencies.

First step, in order to achieve better latencies, is to disable LightDM graphics manager in your Xubuntu Installation of RTOSVisor. Simply run the following command sudo apt-get remove lightdm and the reboot your system.

This step converts your system into console only mode, no GUI. But it is not enough, because a video card can do DMA Transfers even without GUI.

The easiest and fastest solution here is to kill its driver as follows:

  • establish connection with Hypervisor Host via SSH (port 22)

  • kill video driver sudo rmmod -f i915. Now the computer monitor cannot be used anymore.

  • start realtime demo and make sure, that context switch/interrupt delays much better now (200%+):

5.6.2. Real-time measurement

5.6.2.1. RT-Linux realtime demo

The shipped RT-Linux guests include a real-time measurement application.

Follow these steps to run the measurement:

cd /hv/guests/examples/rt-linux
hv_vmf_stop
hv_guest_start -view

Then log in (user = root, password = root)

RealtimeDemo

5.6.2.2. RTOS-32 realtime demo

You can use the RTOS-32 realtime demo application to determine the real-time capabilities of your system.

If you did not change the shipped RTOS-32 configuration, follow these steps to run the measurement:

cd /hv/guests/examples/rtos-32
rm rtos32app.dlm
ln -s files/RealtimeDemo.dlm rtos32app.dlm
hv_vmf_stop
hv_guest_start -view