Skip to content

ubuntu_rt_preempt_installation

Huaijiang Zhu edited this page Aug 17, 2022 · 39 revisions

Install the official Ubuntu image

Git clone the Ubuntu installation scripts repo and then run the following commands

cd official
sudo ./setup_ubuntu
# possible arguments are displayed, for example, installing all dependencies and tools via
sudo ./setup_ubuntu install all

The setup_ubuntu script has several installation options; namely [core|ros|laas|utils|all-code|all]. We recommend the all option. If you decide to install the dependencies separately, always proceed in the order: core, ros, laas, utils. If you install with the laas option first, ros packages will not be installed correctly with the rosoption later.

At the time of writing, part of the LAAS package installation script is broken. However, Pinocchio will be installed correctly.

Install the preempt-rt patch

To conduct hardware experiments with dynamic_graph_head, you will need use preempt-rt patched Linux kernel. To do this, follow the following instructions.

Warning: The preempt-rt kernel does not support NVIDIA drivers at the moment!

First, go to the preempt-rt page to find the patch version you'd like to install. For Ubuntu 20.04.4 LTS, we recommend the version 5.14.2-rt21. Now, you will need to update the installation script with this information.

cd rt-preempt/ubuntu20.04/

Use your favorite editor to update the bash file install_rt_preempt_kernel.sh.

VERSION_MAJOR=5
VERSION_SECOND=14
VERSION_MINOR=2
VERSION=$VERSION_MAJOR.$VERSION_SECOND.$VERSION_MINOR
VERSION_PATCH=$VERSION-rt21

Then, run the following commands

sudo ./enable_kernel_sources.sh
sudo ./install_rt_preempt_kernel.sh

After running the bash file, at some point you will be asked if you want to keep the local configuration, press Enter to continue. After this, you will be asked to edit the config file, follow the instruction written here. Save your changes to the ".config" file (default name) and exit the prompt.

The script will then start compiling the kernel and install it. If everything works out, you can reboot your computer after installation and select the patched kernel in the grub menu.

Finally, do not forget to add your account to the realtime user group.

sudo usermod -a -G realtime $USER

Trouble Shooting

Where are the downloaded files?

The script downloads and compiles the kernel in /root/Downloads/rt_preempt_kernel_install.

I can't execute the bash script even with sudo.

You may not have the correct permission. Try sudo chmod 777 filename to grant read/write/execute access for all users.

I can't compile the kernel.

There are two ways to compile the patched kernel: make-kpkg or make deb-pkg, maintained by different developers. See here for more information. If one method fails, try the other one. For example, a known issue with make-kpkg is that sometimes it gets stuck without any warnings/errors, in this case, using make -j$(nproc) deb-pkg solves the problem.

On the other hand, if the compilation fails with some error messages (in contrast to showing nothing), run the following commands

sudo -s
cd /root/Downloads/rt_preempt_kernel_install/linux-$VERSION_PATCH
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS

And double check that in the .config file, the following variables are set to blank strings

CONFIG_SYSTEM_TRUSTED_KEYS=""
CONFIG_SYSTEM_REVOCATION_KEYS=""

If not, edit them manually and save. More information can be found here.

I can't install the kernel.

If the patched kernel is compiled, yet the installation script shows a file not found error, it may have the wrong file name. In this case, install the following compiled files manually

sudo -s
cd /root/Downloads/rt_preempt_kernel_install/linux-$VERSION_PATCH 
# the following files may have different names, change them accordingly
sudo dpkg -i ../linux-headers-$VERSION_PATCH... .deb 
sudo dpkg -i ../linux-image-$VERSION_PATCH... .deb
sudo dpkg -i ../linux-libc-dev_$VERSION_PATCH... .deb # you may not need to install this---further investigation is required.

After installation, do not forget to manually run the rest of the commands in the installation script for proper configuration. Alternatively, you can also run the installation script again with the compilation/installation commands being commented out.

I don't see boot options for the installed kernel.

The grub menu allows you to select which kernel to use. If it does not show up after installation and rebooting. You can manually edit the file /etc/default/grub to set the following variables

GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10

Then, run sudo update-grub and reboot.

The installed kernel does not boot.

If everything was correctly installed but the kernel does not boot after the grub menu, deactivate secure boot in the BIOS.

Clone this wiki locally