Skip to content

Commit

Permalink
Merge pull request #57 from ros-realtime/master-next
Browse files Browse the repository at this point in the history
update to 24.04
  • Loading branch information
razr authored Sep 23, 2024
2 parents 6b755d1 + b68d814 commit 0a17ee3
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 82 deletions.
2 changes: 2 additions & 0 deletions .config-fragment
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ CONFIG_PERF_EVENTS=y
CONFIG_DEBUG_INFO=n
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_SYSTEM_TRUSTED_KEYS=""
CONFIG_SYSTEM_REVOCATION_KEYS=""
12 changes: 6 additions & 6 deletions .github/workflows/build-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
workflow_dispatch:
inputs:
kernel_version:
description: 'Raspi kernel version, 5.4.0|5.15.0'
default: '5.15.0'
description: 'Raspi kernel version, 6.8.0'
default: '6.8.0'
required: false
type: string
ubuntu_version:
description: 'Ubuntu version, focal|jammy'
default: 'jammy'
description: 'Ubuntu version, jammy|noble'
default: 'noble'
required: false
type: string
uname_r:
description: 'raspi release in a form of <5.15.0-1012-raspi>'
description: 'raspi release in the form of <6.8.0-1005-raspi>'
required: true
default: '5.15.0-1012-raspi'
default: '6.8.0-1005-raspi'
type: string
lttng_version:
description: 'LTTNG version 2.13'
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/rpi4-kernel-build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This is a callable workflow for the RPI4 RT kernel build. It is based on the Dockerfile located in the repo
# This is a callable workflow for the Raspberry Pi RT kernel build. It is based on the Dockerfile located in the repo
# Workflow can be started from another workflow
# The build takes 1.5 hours and artifacts are available under workflow artifacts
# The build takes 2 hours and artifacts are available under workflow artifacts
# - kernel .deb packages
# TODO:
# - create Docker image and push it to the packages
# - create a Docker image and push it to the packages

name: 'RPI4 RT Kernel build'

Expand Down Expand Up @@ -53,10 +53,21 @@ jobs:
# Checks-out repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Get available space
run: |
cd /
df -H
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: false
swap-storage: true

- name: Print input params
run: |
Expand Down Expand Up @@ -85,7 +96,7 @@ jobs:
image: rtwg-image:22.04
options: -v ${{ github.workspace }}:/work
run: |
cd /home/user/linux_build/linux-raspi
cd /linux_build/linux-raspi
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LOCALVERSION=-raspi -j `nproc` bindeb-pkg
sudo cp ../*.deb /work
Expand Down
108 changes: 62 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# A Dockerfile to build an RT kernel for the RPI4 based on Ubuntu 20.04 or 22.04 RPI4 kernel
# A Dockerfile to build an RT kernel for the Raspberry Pi based on Ubuntu 24.04
#
# If run without parameters the Docker image is created to built RT_PREEMPT patched version of the latest 5.15 raspi kernel
# If run without parameters the Docker image is created to built RT_PREEMPT patched version of the latest 6.8 raspi kernel
# The Docker build command accepts the following build arguments:
# $ docker build [--build-arg UBUNTU_VERSION=<ubuntu name>] [--build-arg KERNEL_VERSION=<kernel version>]
# [--build-arg UNAME_R=<raspi release>] [--build-arg RT_PATCH=<RT patch>]
# [--build-arg LTTNG_VERSION=<LTTNG version>] -t rtwg-image .
#
# where
# <ubuntu name> is jammy or focal, default is jammy
# <kernel version> is 5.4.0 or 5.15.0, default is 5.15.0
# <raspi release> is in a form of 5.15.0-1023-raspi, if not defined the lastest version is taken
# <ubuntu name> is noble, default is noble
# <kernel version> is in a form of 6.8.0, default is 6.8.0
# <raspi release> is in a form of 6.8.0-1005-raspi, if not defined the lastest version is taken
# see http://ports.ubuntu.com/pool/main/l/linux-raspi/
# <RT patch> is in a form of 5.15.76-rt53, if not defined the closest to the defined <raspi release> is taken
# see http://cdn.kernel.org/pub/linux/kernel/projects/rt/5.15/older
# <RT patch> is in a form of 6.8.2-rt11, if not defined the closest to the defined <raspi release> is taken
# see https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.8/
# <LTTNG version> is 2.13, default is 2.13
#
# To build a Docker image for the latest 5.15 raspi kernel run
# To build a Docker image for the latest raspi kernel, run
# $ docker build -t rtwg-image .
#
# To build a Docker image for the latest 5.4 raspi kernel run
# $ docker build --build-arg UBUNTU_VERSION=focal --build-arg KERNEL_VERSION=5.4.0 -t rtwg-image .
# To build a Docker image for the stable raspi kernel, run
# $ docker build --build-arg UBUNTU_VERSION=noble --build-arg KERNEL_VERSION=6.8.0 --build-arg UNAME_R=6.8.0-1005-raspi -t rtwg-image .
#
# After that the Docker image is prepared and ready to run
# $ docker run -it rtwg-image bash
#
# and then inside the docker
# $ cd $HOME/linux_build/linux-raspi
# $ cd /linux_build/linux-raspi
# $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LOCALVERSION=-raspi -j `nproc` bindeb-pkg
#
# user ~/linux_build/linux-raspi $ ls -la ../*.deb
# -rw-r--r-- 1 user user 8123580 Jan 16 16:34 ../linux-headers-5.15.74-rt53-raspi_5.15.74-rt53-raspi-1_arm64.deb
# -rw-r--r-- 1 user user 58802024 Jan 16 16:34 ../linux-image-5.15.74-rt53-raspi_5.15.74-rt53-raspi-1_arm64.deb
# -rw-r--r-- 1 user user 1185420 Jan 16 16:34 ../linux-libc-dev_5.15.74-rt53-raspi-1_arm64.deb
# user /linux_build/linux-raspi $ ls -la ../*.deb
# -rw-r--r-- 1 user user 9355162 Jul 1 16:44 ../linux-headers-6.8.4-rt11-raspi_6.8.4-g75867ff0890f-4_arm64.deb
# -rw-r--r-- 1 user user 70457678 Jul 1 16:44 ../linux-image-6.8.4-rt11-raspi_6.8.4-g75867ff0890f-4_arm64.deb
# -rw-r--r-- 1 user user 1377154 Jul 1 16:44 ../linux-libc-dev_6.8.4-g75867ff0890f-4_arm64.deb
#
# copy deb packages to the host, or directly to the RPI4 target
# copy deb packages to the host, or directly to the Raspberry Pi target
# $ scp ../*.deb <user>@172.17.0.1:/home/<user>/.

FROM ubuntu:focal
FROM ubuntu:noble

USER root
ARG DEBIAN_FRONTEND=noninteractive
Expand All @@ -51,8 +51,8 @@ ARG ARCH=arm64
ARG UNAME_R
ARG RT_PATCH
ARG triple=aarch64-linux-gnu
ARG KERNEL_VERSION=5.15.0
ARG UBUNTU_VERSION=jammy
ARG KERNEL_VERSION=6.8.0
ARG UBUNTU_VERSION=noble
ARG LTTNG_VERSION=2.13
ARG KERNEL_DIR=linux-raspi

Expand All @@ -61,13 +61,18 @@ RUN apt-get update && apt-get install -q -y \
gcc-${triple} \
&& dpkg --add-architecture ${ARCH} \
&& sed -i 's/deb h/deb [arch=amd64] h/g' /etc/apt/sources.list \
&& add-apt-repository -n -s "deb [arch=$ARCH] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -s -c) main universe restricted" \
&& add-apt-repository -n -s "deb [arch=$ARCH] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -s -c)-updates main universe restricted" \
&& sed -i 's/deb h/deb [arch=amd64] h/g' /etc/apt/sources.list.d/* \
&& sed -i '/Components/a\Architectures: amd64' /etc/apt/sources.list.d/*.sources \
&& echo "deb [arch=$ARCH] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -s -c) main universe restricted" >> /etc/apt/sources.list.d/ubuntu-ports.list \
&& echo "deb-src [arch=$ARCH] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -s -c) main universe restricted" >> /etc/apt/sources.list.d/ubuntu-ports.list \
&& echo "deb [arch=$ARCH] http://ports.ubuntu.com/ubuntu-ports $(lsb_release -s -c)-updates main universe restricted" >> /etc/apt/sources.list.d/ubuntu-ports.list \
&& rm -rf /var/lib/apt/lists/*

# setup environment
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV UID=1000
ENV GID=1000

# install build deps
RUN apt-get update && apt-get build-dep -q -y linux \
Expand All @@ -76,56 +81,67 @@ RUN apt-get update && apt-get build-dep -q -y linux \
fakeroot \
&& rm -rf /var/lib/apt/lists/*

# remove ubuntu user to set our own
RUN userdel -r ubuntu

# setup user
RUN apt-get update && apt-get install -q -y sudo \
&& useradd -m -d /home/user -s /bin/bash user \
&& groupadd -g $GID user \
&& useradd -m -d /home/user -s /bin/bash -u $UID -g $GID user \
&& gpasswd -a user sudo \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& echo 'user\nuser\n' | passwd user \
&& rm -rf /var/lib/apt/lists/*

# install extra packages needed for the patch handling
RUN apt-get update && apt-get install -q -y wget curl gzip git time \
RUN apt-get update && apt-get install -q -y wget curl gzip git bash-completion time \
&& rm -rf /var/lib/apt/lists/*

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

# Create a directory and set permissions
RUN mkdir -p /linux_build && chown user:user /linux_build

# Define the volume
VOLUME /linux_build

USER user

# find the latest UNAME_R and store it locally for the later usage
# if $UNAME_R is set via --build-arg, take it
RUN if test -z $UNAME_R; then UNAME_R=`curl -s http://ports.ubuntu.com/pool/main/l/linux-raspi/ | grep linux-buildinfo | grep -o -P '(?<=<a href=").*(?=">l)' | grep ${ARCH} | grep ${KERNEL_VERSION} | sort | tail -n 1 | cut -d '-' -f 3-4`-raspi; fi \
&& echo $UNAME_R > /home/user/uname_r

# Set the working directory
WORKDIR /linux_build

# install linux sources from git
RUN mkdir /home/user/linux_build \
&& cd /home/user/linux_build \
&& git config --global https.postBuffer 1048576000 \
&& time git clone -b master --depth 1 --single-branch https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-raspi/+git/${UBUNTU_VERSION} ${KERNEL_DIR} \
RUN git config --global https.postBuffer 1048576000 \
&& git clone -b master --depth 1 --single-branch --jobs=$(($(nproc) * 2)) --progress https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux-raspi/+git/${UBUNTU_VERSION} ${KERNEL_DIR} \
&& cd ${KERNEL_DIR} \
&& git fetch --tag

# checkout necessary tag
RUN cd /home/user/linux_build/${KERNEL_DIR} \
&& git tag -l *`cat /home/user/uname_r | cut -d '-' -f 2`* | sort -V | tail -1 > /home/user/linux_build/tag \
&& git checkout `cat /home/user/linux_build/tag`
RUN cd /linux_build/${KERNEL_DIR} \
&& git tag -l *`cat /home/user/uname_r | cut -d '-' -f 2`* | sort -V | tail -1 > /linux_build/tag \
&& git checkout `cat /linux_build/tag`

# install buildinfo to retieve `raspi` kernel config
RUN cd /home/user \
&& wget http://ports.ubuntu.com/pool/main/l/linux-raspi/linux-buildinfo-${KERNEL_VERSION}-`cat /home/user/uname_r | cut -d '-' -f 2`-raspi_${KERNEL_VERSION}-`cat /home/user/linux_build/tag | cut -d '-' -f 4`_${ARCH}.deb \
&& wget http://ports.ubuntu.com/pool/main/l/linux-raspi/linux-buildinfo-${KERNEL_VERSION}-`cat /home/user/uname_r | cut -d '-' -f 2`-raspi_${KERNEL_VERSION}-`cat /linux_build/tag | cut -d '-' -f 4`_${ARCH}.deb \
&& dpkg -X *.deb /home/user/

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

COPY ./getpatch.sh /home/user/

# get the nearest RT patch to the kernel SUBLEVEL
# if $RT_PATCH is set via --build-arg, take it
RUN cd /home/user/linux_build/${KERNEL_DIR} \
RUN cd /linux_build/${KERNEL_DIR} \
&& if test -z $RT_PATCH; then /home/user/getpatch.sh `make kernelversion` > /home/user/rt_patch; else echo $RT_PATCH > /home/user/rt_patch; fi

# download and unzip RT patch
RUN cd /home/user/linux_build \
RUN cd /linux_build \
&& wget http://cdn.kernel.org/pub/linux/kernel/projects/rt/`echo ${KERNEL_VERSION} | cut -d '.' -f 1-2`/older/patch-`cat /home/user/rt_patch`.patch.gz \
&& gunzip patch-`cat /home/user/rt_patch`.patch.gz

Expand All @@ -138,25 +154,25 @@ RUN cd /home/user/ \
# run lttng built-in script to configure RT kernel
RUN set -x \
&& cd `ls -d /home/user/lttng-modules-*` \
&& ./scripts/built-in.sh ${HOME}/linux_build/${KERNEL_DIR}
&& ./scripts/built-in.sh /linux_build/${KERNEL_DIR}

# patch kernel, do not fail if some patches are skipped
RUN cd /home/user/linux_build/${KERNEL_DIR} \
RUN cd /linux_build/${KERNEL_DIR} \
&& OUT="$(patch -p1 --forward < ../patch-`cat $HOME/rt_patch`.patch)" || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false);

# setup build environment
RUN cd /home/user/linux_build/${KERNEL_DIR} \
RUN cd /linux_build/${KERNEL_DIR} \
&& export $(dpkg-architecture -a${ARCH}) \
&& export CROSS_COMPILE=${triple}- \
&& fakeroot debian/rules clean \
&& LANG=C fakeroot debian/rules printenv

COPY ./.config-fragment /home/user/linux_build/.
COPY ./.config-fragment /linux_build/.

# config RT kernel and merge config fragment
RUN cd /home/user/linux_build/${KERNEL_DIR} \
RUN cd /linux_build/${KERNEL_DIR} \
&& cp /home/user/usr/lib/linux/`cat /home/user/uname_r`/config .config \
&& ARCH=${ARCH} CROSS_COMPILE=${triple}- ./scripts/kconfig/merge_config.sh .config $HOME/linux_build/.config-fragment
&& ARCH=${ARCH} CROSS_COMPILE=${triple}- ./scripts/kconfig/merge_config.sh .config /linux_build/.config-fragment

RUN cd /home/user/linux_build/${KERNEL_DIR} \
RUN cd /linux_build/${KERNEL_DIR} \
&& fakeroot debian/rules clean
Loading

0 comments on commit 0a17ee3

Please sign in to comment.