rickstaa/ros-gazebo-gym-ws

Error during the compilation of the realtime kernel

rickstaa opened this issue · 0 comments

When trying to compile the realtime (RT) kernel for the Franka robot I run into a number of errors. In the end, the official guide from Emika Franka did not seem to work for me. The following, however, does seem to work:

Compile realtime kernel

  1. Install dependencies:
sudo apt-get install build-essential bc curl ca-certificates fakeroot gnupg2 libssl-dev lsb-release libelf-dev bison flex libncurses-dev
  1. Download the regular kernel and the patch from the Linux Kernel archive.
curl -SLO https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.4.26.tar.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.4.26.tar.sign
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.26-rt17.patch.xz
curl -SLO https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-5.4.26-rt17.patch.sign
  1. Unzip the files:
xz -d linux-5.4.26.tar.xz
xz -d patch-5.4.26-rt17.patch.xz
  1. Verifying the file integrity.
gpg2 --verify linux-5.4.26.tar.sign
gpg2 --verify patch-5.4.26-rt17.patch.sign

You have to first download the public key of the person who signed the above file. As you can see from the above output, it has the ID 6092693E. You can obtain it from the key server:

gpg2  --keyserver hkp://keys.gnupg.net --recv-keys 647F28654894E3BD457199BE38DBBDC86092693E
  1. Unzip the linux kernel tar xvf linux-5.4.26.tar.
  2. Go into the kernel folder cd linux-5.4.26.
  3. Apply the patch patch -p1 < ../patch-5.4.26-rt17.patch.
  4. Run make menuconfig and change the Preemption Model to 'Fully Preemptible Kernel (RT) (PREEMPT_RT_FULL) (NEW)'.
  5. Disable lz4 compression scripts/config --disable KERNEL_LZ4.
  6. Enable gzip compression scripts/config --enable KERNEL_GZIP.
  7. Disable debug info scripts/config --disable DEBUG_INFO.
  8. Run make clean.
  9. Make the bzImage make -j $(nproc) bzImage.
  10. Make the modules make -j $(nproc) modules.
  11. Install the modules make -j $(nproc) modules_install.
  12. Install the kernel make -j $(nproc) install.

Allow a user to set real-time permissions for its processes

After the PREEMPT_RT kernel is installed and running, add a group named realtime and add the user controlling your robot to this group:

sudo addgroup realtime
sudo usermod -a -G realtime $(whoami)

Afterwards, add the following limits to the realtime group in /etc/security/limits.conf:

@realtime soft rtprio 99
@realtime soft priority 99
@realtime soft memlock 102400
@realtime hard rtprio 99
@realtime hard priority 99
@realtime hard memlock 102400

The limits will be applied after you log out and in again.

Resources