Skip to content

Commit

Permalink
Merge branch 'master' into add-gh-actions-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
razr authored Oct 15, 2021
2 parents 4c7db51 + 972560e commit 1b9376f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
21 changes: 20 additions & 1 deletion .config-fragment
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
CONFIG_PREEMPT_RT=y
CONFIG_LOCKUP_DETECTOR=n
CONFIG_DETECT_HUNG_TASK=n
CONFIG_NO_HZ_FULL=y
CONFIG_HZ_1000=y
# CONFIG_AUFS_FS is not set
CONFIG_CPU_FREQ=n
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
CONFIG_CPU_IDLE=n
CONFIG_LTTNG=y
# CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM is not set
CONFIG_LTTNG_CLOCK_PLUGIN_TEST=y
CONFIG_MODULES=y
CONFIG_KALLSYMS=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_TRACEPOINTS=y
# CONFIG_KPROBES is not set
CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
CONFIG_EVENT_TRACING=y
CONFIG_PERF_EVENTS=y
# CONFIG_KRETPROBES is not set
# CONFIG_KALLSYMS_ALL is not set

14 changes: 9 additions & 5 deletions .github/workflows/rpi4-kernel-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ name: 'RPI4 RT Kernel build'

# Controls when the workflow will run
on:
# Triggers the workflow on push only if kernel configuration changed
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
paths:
- '.config-fragment'
branches:
- master
pull_request:
branches:
- master

# Allows you to run this workflow manually from the Actions tab
# manual start works on teh default branch only
# manual start works on the default branch only
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
Expand Down Expand Up @@ -160,4 +164,4 @@ jobs:
with:
name: 'RPI4 RT Kernel deb packages'
path: ~/linux_build/*.deb


29 changes: 24 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# if the build arguments defined it will build a corresponding version instead
# $ docker build [--build-arg UNAME_R=<raspi release>] [--build-arg RT_PATCH=<RT patch>] -t rtwg-image .
#
# where <raspi release> is in a form of 5.4.0-1034-raspi,
# where <raspi release> is in a form of 5.4.0-1034-raspi,
# see https://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=linux-image-5.4&searchon=names
# and <RT patch> is in a form of 5.4.106-rt54,
# and <RT patch> is in a form of 5.4.106-rt54,
# see http://cdn.kernel.org/pub/linux/kernel/projects/rt/5.4/older
#
# $ docker run -it rtwg-image bash
# $ docker run -it rtwg-image bash
#
# and then inside the docker
# $ $HOME/linux_build && cd `ls -d */`
# $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j `nproc` deb-pkg
#
#
# user ~/linux_build/linux-raspi-5.4.0 $ ls -la ../*.deb
# -rw-r--r-- 1 user user 11430676 May 17 14:40 ../linux-headers-5.4.101-rt53_5.4.101-rt53-1_arm64.deb
# -rw-r--r-- 1 user user 487338132 May 17 14:40 ../linux-image-5.4.101-rt53-dbg_5.4.101-rt53-1_arm64.deb
Expand All @@ -32,13 +32,14 @@ ARG DEBIAN_FRONTEND=noninteractive
# setup timezone
RUN echo 'Etc/UTC' > /etc/timezone \
&& ln -s -f /usr/share/zoneinfo/Etc/UTC /etc/localtime \
&& apt-get update && apt-get install -q -y tzdata apt-utils lsb-release software-properties-common \
&& apt-get update && apt-get install -q -y tzdata apt-utils lsb-release software-properties-common openssh-client \
&& rm -rf /var/lib/apt/lists/*

ARG ARCH=arm64
ARG UNAME_R
ARG RT_PATCH
ARG triple=aarch64-linux-gnu
ARG LTTNG=2.12

# setup arch
RUN apt-get update && apt-get install -q -y \
Expand Down Expand Up @@ -95,6 +96,10 @@ RUN sudo apt-get update \
&& apt-get source linux-image-`cat /uname_r` \
&& sudo rm -rf /var/lib/apt/lists/*

# install lttng dependencies
RUN sudo apt-get update \
&& sudo apt-get install -y libuuid1 libpopt0 liburcu6 libxml2 numactl

COPY ./getpatch.sh /getpatch.sh

# get the nearest RT patch to the kernel SUBLEVEL
Expand All @@ -111,6 +116,20 @@ RUN cd `ls -d */` \
RUN wget http://cdn.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patch-`cat $HOME/rt_patch`.patch.gz \
&& gunzip patch-`cat $HOME/rt_patch`.patch.gz

# download lttng source for use later
# TODO(flynneva): make script to auto-determine which version to get?
RUN cd $HOME \
&& sudo apt-add-repository ppa:lttng/stable-${LTTNG} \
&& sudo apt-get update \
&& apt-get source lttng-modules-dkms

# run lttng built-in script to configure RT kernel
RUN set -x \
&& export KERNEL_DIR=`ls -d */` \
&& cd $HOME \
&& cd `ls -d lttng-*/` \
&& ./scripts/built-in.sh ${HOME}/linux_build/${KERNEL_DIR}

# patch `raspi` kernel, do not fail if some patches are skipped
RUN cd `ls -d */` \
&& OUT="$(patch -p1 --forward < ../patch-`cat $HOME/rt_patch`.patch)" || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false);
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
Alternatively, you can modify ```.config-fragment``` and then merge your changes in the ```.config``` by running

```bash
cd $HOME/linux_build/linux-raspi-*
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- ./scripts/kconfig/merge_config.sh .config $HOME/linux_build/.config-fragment
```

### Kernel build

```bash
cd $HOME/linux_build/linux-raspi-*
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j `nproc` deb-pkg
```

Expand Down Expand Up @@ -172,6 +174,12 @@ Linux ubuntu 5.4.101-rt53 #1 SMP PREEMPT_RT Mon May 17 12:10:16 UTC 2021 aarch64

To build ```x86_64``` Linux kernel, see [Building Realtime rt_preempt kernel for ROS 2](https://index.ros.org/doc/ros2/Tutorials/Building-Realtime-rt_preempt-kernel-for-ROS-2)

## Why is LTTng included in the kernel?

[LTTng](https://lttng.org/docs) stands for _Linux Trace Toolkit: next generation_ and is an open source toolkit that enables low-level kernel tracing which can be extremely useful when calculating callback times, memory usage and many other key characteristics.

As this repository is within the `ros-realtime` organization it can be assumed that most users will install ROS 2 on the end system - which then they can use `ros2_tracing` to trace various things. Since [`ros2_tracing`](https://gitlab.com/ros-tracing/ros2_tracing) uses LTTng as its tracer, and since [the `lttng-modules` package is not easily available](https://github.com/ros-realtime/rt-kernel-docker-builder/issues/16) for the raspberry-pi RT linux kernel we build it into the kernel here as a work around.

## References

* [ROS Real-Time Working group documentation](https://real-time-working-group.readthedocs.io/en/rolling/Guides/Real-Time-Operating-System-Setup/Real-Time-Linux/rt_linux_index.html)
Expand Down

0 comments on commit 1b9376f

Please sign in to comment.