Realtime Linux: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Check the [http://www.techunited.nl/wiki/index.php?title=How_to_turn_Hardware_into_Football How to turn Hardware into Football] from the techunited page.'''
* '''Check [http://www.techunited.nl/wiki/index.php?title=How_to_turn_Hardware_into_Football How to turn Hardware into Football] from the techunited page.'''


'''Also check the [[E-box/Install_manual|E-box]] page for more recent information.'''
* '''Check the [[E-box/Install_manual|E-box]] page for more information.'''


<!--
* '''Check [http://www.mate.tue.nl/mate/pdfs/10018.pdf Installing a Real-Time Linux Kernel for Dummies] by Jeroen de Best & Roel Merry'''
=How to install a devpc=
** '''IMPORTANT:''' When using Ubuntu 10.04 and the linux-rt kernel, in addition to what is mentioned in the above about CPU-scaling, remove the file "/etc/init.d/ondemand" to stop the scaling mode from changing to ondemand 1 minute after startup.
'''Author(s):''' Jeroen de Best, Koen Meessen<br>
'''Source:''' [http://www.techunited.nl/wiki/index.php?title=How_to_turn_Hardware_into_Football Techunited: How to turn Hardware into Football]




This chapter describes in detail all the consecutive steps needed in order to get a fully operational development PC called devpc.
==Install Ubuntu 8.10==
Get a Ubuntu 8.10 live CD put it in your CD tray, boot your system from CD and select Install Ubuntu 8.10 to your hard disk. At the first step choose your language (English) and select 'Forward'. At the second step choose your time-zone. The time-zones are sorted by continent. Choose Europe, Amsterdam and select 'Forward'. At the third step choose your keyboard settings. You can try the settings in the lower area of the setup screen. The default is U.S. English, U.S. English. Select 'Forward'. At the fourth step you are asked to prepare the disks. Choose for the manual option here and select 'Forward'. Now watch out, because in the following steps you are going to ''erase your entire hard-disk''! Consecutively, select each partition and delete those partitions by clicking 'Delete partition'. After deleting all partitions select 'free space' and click 'New partition'. First make a primary partition of 4096 megabytes which is located at the beginning. Use this partition as a swap partition. This can be chosen in the 'Use as' drop down menu. Select 'Ok'. Secondly, make a primary partition of the remaining size which is located also at the beginning. Use this partition as an ext3 partition. This can be chosen in the 'Use as' drop down menu. The mount point should be '/'. Now, all disk space is partitioned. Turn on the 'Format?' option for the ext3 partition and select 'Forward'. At step number five, do not Migrate Documents and Settings and select 'Forward'. At the sixth step you should fill in the form about who you are. In our case the login name and username are robocup. The password for robocup is Robocup. Make sure that the name of your computer is devpcX, where X stand for the number of the devpc. Tick the Login Automatically option. The installation will take approximately 15 minutes. After installation, reboot the system.
==Wireless Internet at the TU/e==
If you have a wireless ethernet adapter, you will be asked to give a default keyring password after rebooting. Just apply it ''without'' giving any password and accept the warning about the weak password. You can get wireless connection to the Internet by clicking the network applet in the top right corner of the screen. Choose tue-wpa2. A screen with settings appears. Set the following settings:
<pre>
Wireless Security: WPA & WPA 2 Enterprise
Authentication: Protected EAP (PEAP)
Anonymous Identity:
Ca- Certificate: /usr/share/ca-certificates/mozilla/GTE_CyberTrust_Global.crt
PEAP Version: Version 0
Inner Authentication: MSCHAPv2
Username: <your TU/e user name>
Password: <your TU/e password>
</pre>
Accept the settings and you will be connected to the wireless TU/e network.
===Switch to basic appearance===
At this moment we shutdown the fancy graphics environment. Therefore, go to System, Preferences, Appearance, Visual Effects and set these to none. This turns of all the fancy desktop features, which are unnecessary.
===Change root password===
Now we should change the superuser/root password by typing. This can be done using a so-called terminal, which can be started from Applications, Accessories, Terminal. A white screen will appear with a command line prompt. To change the root password type the following.
<pre>
robocup@devpcX:~$ sudo passwd root
</pre>
Type your own password when asked as follows
<pre>
[sudo] password for robocup:
</pre>
and enter the new root password ****** twice when asked as follows
<pre>
Enter new UNIX password:
Retype new UNIX password:
</pre>
Now your root password is updated.
<pre>
passwd: password updated successfully
</pre>
===Install additional packages===
At this point, be sure to have a working Internet connection. If so, open Synaptic Package Manager from System, Administration, Synaptic Package Manager. Type the password Robocup to enter the package manager. Click the top right 'Reload' button to update the package list. Now double-click or right-click and select 'Mark for Installation' for the following packages. You can find these packages fast by selecting one of the packages (single-click) in the top right package list and type the first letters of the package you are searching for.
<pre>
csh (needed for matlab engine)
g++
g++-4.1
gcc-4.1 (needed for compatibility with mex)
glade-3 (needed for GUIs)
kernel-package (needed for kernel compilation)
libgd2-noxpm-dev (needed for gd functionalities)
libstdc++5
mc (file browser midnight commander)
nfs-common (needed to mount wtbfiler)
ntp (needed for synchronizing clocks)
ntpdate (needed for synchronizing clocks)
openssh-server (to access from a remote computer)
sun-java6-bin (needed for java)
subversion (needed for svn version)
bison (needed for comm)
ccache
</pre>
Apply to install the packages. Agree the license agreement of Java, select 'Forward'. These packages will be needed during the following steps or will be needed in combination with the Tech United software.
===Change gcc and g++ version===
On your system there are now two versions of gcc, namely 4.1 and 4.3. Since the mex command of matlab cannot cope with the 4.3 version we have to use the 4.1 version. The current version will probably be 4.3. To check this type the following
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# gcc --version
root@devpcX:/home/robocup# g++ --version
</pre>
Now we alter the link gcc and g++ to point to the 4.1 versions. This is done as follows
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# cd /usr/bin
root@devpcX:/usr/bin# ln -sf gcc-4.1 gcc
root@devpcX:/usr/bin# ln -sf g++-4.1 g++
</pre>
Check the versions again to make sure that the correct version 4.1 is now used.
==Install matlab 2007b==
Now we will install matlab 2007b. Therefore we will access to the wtbfiler of the TU/e. Note that this is only possible if you are at the TU/e or having a VPN connection with the TU/e. Make sure you have a working Internet connection, preferably wired to speed up the installation process. Open a Terminal and proceed as follows
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# mkdir /mnt/temp
root@devpcX:/home/robocup# mount wtbfiler.wtb.tue.nl:/software /mnt/temp
root@devpcX:/home/robocup# mkdir /usr/local/matlab75
root@devpcX:/home/robocup# cd /mnt/temp/Unix-Software/matlab2007b/license
root@devpcX:/mnt/temp/Unix-Software/matlab2007b/license# cp license.dat /usr/local/matlab75
root@devpcX:/mnt/temp/Unix-Software/matlab2007b/license# cd ../DVD1
root@devpcX:/mnt/temp/Unix-Software/matlab2007b/DVD1# ./install
</pre>
Choose the matlab root directory as /usr/local/matlab75. During installation cut the license at the begin and at the end where it is indicated (cut including the begin and end comments). Select the option Create symbolic links to MATLAB scripts in: /usr/local/bin. The installation will approximately take 30 minutes. Now we change the matlab command to work with the installed java package. Therefore edit the file /usr/local/bin/matlab. Open a Terminal and open the file as follows
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# cd /usr/local/bin
root@devpcX:/usr/local/bin# gedit matlab
</pre>
Add the following at line 183 just after all the comments
<pre>
export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.14/jre
</pre>
Save and close the file. Now you can start matlab. Always start matlab as a superuser/root so
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# matlab
</pre>
==Change mex options==
In this section we change the options for the matlab function mex in order to be able to build the Tech United software later on. If matlab is started type the following
<pre>
>> mex -setup
</pre>
Choose for option 2, Template Options file for building gcc MEX-files. Matlab reports that a file mexopts.sh is created in the folder /root/.matlab/R2007b. Check if it is placed in the prementioned folder. If this is not the case, you probably did not start matlab as a superuser and therefore the file mexopts.sh is placed in /home/robocup/.matlab/R2007b, which is incorrect. If this is the case restart matlab as a superuser and do the same again. Open the file /root/.matlab/R2007b/mexopts.sh with the editor of matlab and remove the -ansi option from the CFLAGS options on line 57 and 65. Add the option -W on line 57 and 65 to show warnings during compilation. Save and close the file.
==Install Linux kernel 2.6.28.3==
Since the Tech United software is based on the Linux kernel 2.6.28.3 we need to install this kernel. Therefore, make sure to have a working Internet connection. Open the web browser Mozilla and go to the FTP site ftp://ftp.kernel.org/pub/linux/kernel/v2.6 and download the file linux-2.6.28.3.tar.bz2 to your desktop. Extract the file by right-clicking and chose extract here. To move the folder linux-2.6.28.3 from your desktop to /usr/src open a Terminal and type
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# cd Desktop
root@devpcX:/home/robocup/Desktop# mv linux-2.6.28.3 /usr/src
</pre>
Now obtain the .config file needed for the compilation of the kernel from another devpc and put it into the folder /usr/src/linux-2.6.28.3. Now your are ready to compile the 2.6.28.3 Linux kernel. Here we will make Debian packages of the kernel, *.deb files, such that they can be easily installed and uninstalled from your current installation. Open a Terminal and proceed as follows
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# cd /usr/src/linux-2.6.28.3
root@devpcX:/usr/src/linux-2.6.28.3# make-kpkg --initrd binary-arch
</pre>
The compilation will approximately take one hour. After that, two Debian packages are created in /usr/src, namely linux-image-2.6.28.3_2.6.28.3-10.00.Custom_i386.deb and linux-headers-2.6.28.3_2.6.28.3-10.00.Custom_i386.deb. Open the file browser Nautilus from Places, Computer and go to /usr/src/ and double-click the first one. Enter the password and install the package. Do the same for the second one. Finally, restart your PC. During rebooting you will see that there are now two more GRUB options from which the default is now the new Linux kernel 2.6.28.3. Once booted, you can check the kernel version in a Terminal
<pre>
robocup@devpcX:~$ uname -r
</pre>
It should be 2.6.28.3.
==Linux==
In the startup script set the maximum transfer unit of the GigE Ethernet card to 9200 kilobytes. This can be done as
<pre>
robocup@devpcX:~$ su
root@devpcX:/home/robocup# ifconfig eth0 mtu 9200
</pre>
where eth0 is the GigE Ethernet port.
-->
=Ubuntu RealTime Kernels=
=Ubuntu RealTime Kernels=
'''Source:''' [https://help.ubuntu.com/community/UbuntuStudio/RealTimeKernel Ubuntu Documentation]
'''Source:''' [https://help.ubuntu.com/community/UbuntuStudio/RealTimeKernel Ubuntu Documentation]
Line 254: Line 70:




'''FAQ:''' from [https://wiki.ubuntu.com/RealTime Ubuntu Wiki]
===FAQ: from [https://wiki.ubuntu.com/RealTime Ubuntu Wiki]===


''Q'': What is the difference between an -rt kernel and a -realtime kernel?
''Q'': What is the difference between an -rt kernel and a -realtime kernel?

Latest revision as of 14:02, 16 February 2012

  • Check the E-box page for more information.
  • Check Installing a Real-Time Linux Kernel for Dummies by Jeroen de Best & Roel Merry
    • IMPORTANT: When using Ubuntu 10.04 and the linux-rt kernel, in addition to what is mentioned in the above about CPU-scaling, remove the file "/etc/init.d/ondemand" to stop the scaling mode from changing to ondemand 1 minute after startup.


Ubuntu RealTime Kernels

Source: Ubuntu Documentation

Check the source for an up to date version of this subject, the text provided here is for quick reference and was copied from the source when it was last edited on 23-08-2011.

Prerequisite definitions:

kernel - central component of a computer's operating system, bridging between applications and the actual data processing done at the hardware level. See also Wikipedia's Kernel entry.

real-time - an attempt to have deterministic operational deadlines from an event to system response, i.e. the time it takes the computer to respond to an event is known and predictable. A byproduct of this is usually lower latency for audio. See also Wikipedia's Real-time entry.

vanilla kernel source - Linux kernel source code than you can download at www.kernel.org.

Ubuntu kernel source - Linux kernel source code used in Ubuntu and modified for offer all Ubuntu features. You can download it at http://kernel.ubuntu.com/git or simply install binary releases via Synaptic.

Kernel Types

-generic kernel - this is the stock kernel that is provided by default in Ubuntu.

-preempt kernel - this kernel is based on the -generic kernel source tree but is built with different configurations (settings) to reduce latency. Also known as a soft real-time kernel.

-rt kernel - is based on the Ubuntu kernel source tree with Ingo Molnar maintained PREEMPT_RT patch applied to it. Also know as a hard real-time kernel.

-lowlatency kernel - very similar to the -preempt kernel and based on the -generic kernel source tree, but uses a more aggressive configuration to further reduce latency. Also know as a soft real-time kernel.

-realtime kernel - is based on the vanilla kernel source tree with Ingo Molnar maintained PREEMPT_RT patch applied to it. Also know as a hard real-time kernel.

At the moment only the first three kernels are available through official Ubuntu archives.

Choosing a Kernel for Your Use Case

These are some simple guidelines provided to help you understand which kernel, and in which order, you should test to fit your use case.

  • If you do not require low latency for your system then please use the -generic kernel.
  • If you need a low latency system (e.g. for recording audio) then please use the -preempt kernel as a first choice. This reduces latency but doesn't sacrifice power saving features. It is available only for 64 bit systems (also called amd64).
  • If the -preempt kernel does not provide enough low latency for your needs (or you have an 32 bit system) then you should try the -lowlatency kernel.
  • If the -lowlatency kernel isn't enough then you should try the -rt kernel.
  • If the -rt kernel isn't enough stable for you then you should try the -realtime kernel.

Kernel Repositories

Currently, not all kernels are available in the official Ubuntu repositories. The balance may be found in select PPA's.

First attempt to locate the desired kernel in the official Ubuntu repositories by using your choice of package management (i.e. Synaptic or apt-get). Warning - the -rt kernel release can lag behind mainstream, check to the kernel version number! As of this writing, Lucid release, the kernel is 2.6.32 but the -rt kernel available in the Ubuntu repositories is 2.6.31.

Next it is recommended you search in the following selective and discriminating PPAs:

It is not recommended to use kernels from unknown or untested PPA's! You do not know what configuration were used or how it was built and an unstable (or unbootable) system could be the result. Use only trusted PPA's

Please note that Alessio Igor Bogani has been the Ubuntu Studio kernel maintainer for several releases and has the support of the Ubuntu Studio team.

Kernel Confusion

Some confusion persists about the purposes of -lowlatency and -realtime kernels.

The goal of -realtime and -rt (hard real-time) kernels is to achieve the lowest possible latency at every cost. In technical slang hard realtime systems should always meet their deadlines. Thus developers should use the most advanced programming techniques (sleeping spinlocks, PI Mutex, Full preemption, IRQ Threads and others) and sacrifice things like reliability, power-saving and throughput. Almost all parts of kernel should be analysed to guarantee that right behaviour always occurs.

The goal of -preempt and -lowlatency (soft real-time) kernels is to achieve good realtime characteristics, meanwhile offering welcomed features like rock-solid reliability, good power-saving features and also good throughput. But in this way it can't guarantee lowest latency under all conditions.


FAQ: from Ubuntu Wiki

Q: What is the difference between an -rt kernel and a -realtime kernel?

A: From a technical point of view, -rt and -realtime are the same kernel. They are both based on the PREEMPT_RT patchset, although the version may be different. The main difference is that the -rt kernel should be based on the Ubuntu source tree (and therefore can use the same features, patches, enabled hardware, security fixes and so on) and should offer the same services that the Ubuntu default -generic kernel offers. For example, it should be compatible with closed video drivers (nvidia and fglrx), any external DKMS drivers, and have available backport packages. The goal of an -rt kernel is to obtain a real time variant of the Ubuntu kernel that is aligned with the -generic kernel.

On the other hand, the -realtime kernel is a PREEMPT_RT patched kernel based on the vanilla source tree (not the Ubuntu source). This kernel will be missing Ubuntu specific code, patches or security fixes and it isn't guaranteed to be compatible with any external software (low level utilities, DKMS drivers and so on). It does not use the same Linux kernel version as the -generic kernel, and so these two kernels are not aligned. It is a working, upstream real-time kernel that is being used on Ubuntu. No more no less.