Skip to content

Instantly share code, notes, and snippets.

@awesomebytes
Last active October 30, 2022 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awesomebytes/8f9158c32a24930c16db6c529f7c2a50 to your computer and use it in GitHub Desktop.
Save awesomebytes/8f9158c32a24930c16db6c529f7c2a50 to your computer and use it in GitHub Desktop.

Compile Kernel with PREEMPT_RT

When following https://docs.ros.org/en/foxy/Tutorials/Miscellaneous/Building-Realtime-rt_preempt-kernel-for-ROS-2.html

I built this in a VM using the Ubuntu ubuntu-20.04.5-desktop-amd64.iso. I needed to provide the VM with 7GB of RAM to avoid OOM (out of memory) errors. I needed to provide it with 60GB of storage space (Ubuntu installation needs short of 7GB and the kernel compilation seems to need over 40GB, plus testing the .deb installation it fills the disk).

39G	linux-5.15.73
8.2M	linux-headers-5.15.73-rt52_5.15.73-rt52-8_amd64.deb
84M	linux-image-5.15.73-rt52_5.15.73-rt52-8_amd64.deb
1.2G	linux-image-5.15.73-rt52-dbg_5.15.73-rt52-8_amd64.deb
1.2M	linux-libc-dev_5.15.73-rt52-8_amd64.deb
268K	linux-upstream_5.15.73-rt52-1.diff.gz
4.0K	linux-upstream_5.15.73-rt52-1.dsc
8.0K	linux-upstream_5.15.73-rt52-8_amd64.buildinfo
4.0K	linux-upstream_5.15.73-rt52-8_amd64.changes
344K	patch-5.15.73-rt52.patch

Given I ran into these errors and needed to restart/resume the compilation multiple times I'm not sure how long it actually takes.

I would recommend to proactively apply all the fixes listed here before running your compilation.

Workarounds needed

Failing to build stuff related to certs: https://stackoverflow.com/a/72528175

To avoid the error:

make[1]: *** No rule to make target 'debian/certs/debian-uefi-certs.pem', needed by 'certs/x509_certificate_list'.  Stop.

Step 1:

# Get the necessary certs and put them where they belong
sudo mkdir -p /usr/local/src/debian
sudo apt install linux-source
sudo cp -v /usr/src/linux-source-*/debian/canonical-*.pem /usr/local/src/debian/
sudo apt purge linux-source*

Step 2:

Edit .config:

#
# Certificates for signature checking
#
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"
CONFIG_MODULE_SIG_KEY_TYPE_RSA=y
CONFIG_MODULE_SIG_KEY_TYPE_ECDSA=y
CONFIG_SYSTEM_TRUSTED_KEYRING=y
CONFIG_SYSTEM_TRUSTED_KEYS="/usr/local/src/debian/canonical-certs.pem"
CONFIG_SYSTEM_EXTRA_CERTIFICATE=y
CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE=4096
CONFIG_SECONDARY_TRUSTED_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_HASH_LIST=""
CONFIG_SYSTEM_REVOCATION_LIST=y
CONFIG_SYSTEM_REVOCATION_KEYS="/usr/local/src/debian/canonical-revoked-certs.pem"
# end of Certificates for signature checking

To continue the build after error

make -j 10 bindeb-pkg

bindeb-pkg does not do a clean at the start.

Fix error missing dependency zstd

sudo apt install zstd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment