remusmp / rpi-rt-kernel

56 stars 34 forks source link

Error when patch is applied #6

Closed matthiasthomasbecker closed 2 years ago

matthiasthomasbecker commented 2 years ago

Hi,

I get an error in the build process when the patch is applied. I am not quite sure what the problem is, the error message is appended below. This happens for me with different kernel versions (I tried 5.10 and 5.15).

Is there a known way to work around this?

Thanks a lot!

--------------------------
|diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
|index 717db5ecd0bd..093db2d13e92 100644
|--- a/net/xfrm/xfrm_state.c
|+++ b/net/xfrm/xfrm_state.c
--------------------------
patching file net/xfrm/xfrm_state.c
Using Plan A...
Hunk #1 succeeded at 2691 (offset -2 lines).
done
Removing file arch/alpha/include/asm/kmap_types.h
Removing file arch/arc/include/asm/kmap_types.h
Removing file arch/arm/include/asm/kmap_types.h
Removing file arch/arm/mm/highmem.c
Removing file arch/ia64/include/asm/kmap_types.h
Removing file arch/microblaze/mm/highmem.c
Removing file arch/mips/include/asm/kmap_types.h
Removing file arch/nds32/mm/highmem.c
Removing file arch/parisc/include/asm/kmap_types.h
Removing file arch/powerpc/include/asm/kmap_types.h
Removing file arch/powerpc/mm/highmem.c
Removing file arch/sh/include/asm/kmap_types.h
Removing file arch/sparc/include/asm/kmap_types.h
Removing file arch/sparc/mm/highmem.c
Removing file arch/um/include/asm/kmap_types.h
Removing file arch/x86/include/asm/kmap_types.h
Removing file include/asm-generic/kmap_types.h
Removing file include/linux/irq_cpustat.h
Removing file kernel/printk/internal.h
Removing file kernel/printk/printk_safe.c
The command '/bin/sh -c export PATCH=$(curl -s https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/${LINUX_KERNEL_VERSION}/ | sed -n 's:.*<a href="\(.*\).patch.gz">.*:\1:p' | sort -V | tail -1) &&     echo "Downloading patch ${PATCH}" &&     curl https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/${LINUX_KERNEL_VERSION}/${PATCH}.patch.gz --output ${PATCH}.patch.gz &&     gzip -cd /rpi-kernel/linux/${PATCH}.patch.gz | patch -p1 --verbose' returned a non-zero code: 1
make: *** [Makefile:5: all] Error 1
b08x commented 2 years ago

running dockerlint on the Dockerfile throws an error at line 17 RUN contains and undefined ARG or ENV variable

I'm not sure what exactly it's missing, but I can say that manually applying the patch works.

For now, I've made the following edits to my version of the Dockerfile:

diff --git a/Dockerfile b/Dockerfile
index b13517d..2358e7a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,10 +14,10 @@ RUN apt-get install -y wget zip unzip fdisk nano curl xz-utils
 WORKDIR /rpi-kernel
 RUN git clone https://github.com/raspberrypi/linux.git -b ${LINUX_KERNEL_BRANCH} --depth=1
 WORKDIR /rpi-kernel/linux
-RUN export PATCH=$(curl -s https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/${LINUX_KERNEL_VERSION}/ | sed -n 's:.*<a href="\(.*\).patch.gz">.*:\1:p' | sort -V | tail -1) && \
-    echo "Downloading patch ${PATCH}" && \
-    curl https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/${LINUX_KERNEL_VERSION}/${PATCH}.patch.gz --output ${PATCH}.patch.gz && \
-    gzip -cd /rpi-kernel/linux/${PATCH}.patch.gz | patch -p1 --verbose
+
+RUN export PATCH=$(curl -s https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.10/ | sed -n 's:.*<a href="\(.*\).patch.gz">.*:\1:p' | sort -V | tail -1) && echo "Downloading patch ${PATCH}" && wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.10/${PATCH}.patch.gz
+
+RUN export PATCH=$(curl -s https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.10/ | sed -n 's:.*<a href="\(.*\).patch.gz">.*:\1:p' | sort -V | tail -1) && sh -xc 'gzip -cd ${PATCH}.patch.gz | patch -p1 --verbose' || :

 ENV KERNEL=kernel8
 ENV ARCH=arm64

I listed four items, but I lament as I wonder if just using the logical or to an empty command would be good enough for the time being.

Right now the kernel is still compiling, which is good....so I'll see if this works out once it gets to building the img file. Will update when that happens.

matthiasthomasbecker commented 2 years ago

Thank you a lot! The proposed changes to the dockerfile worked for me and I could successfully build the image with the preempt-rt patch applied.

remusmp commented 2 years ago

Sorry to jump in: if the patch fails to be applied then I wouldn't fully trust the kernel. Maybe it works, maybe it doesn't. My bet right now is that 5.10 is not maintained anymore on https://github.com/raspberrypi/linux and newly RT patches for 5.10 fail to be applied.

However, I noticed that https://github.com/raspberrypi/linux moved to rpi-5.15.y branch by default so I changed to the same default branch in this repo. The patch successfully applies and things build fine with 5.15. I would recommend upgrading to 5.15 or if you insist on using 5.10 then I think you need to switch to an older RT patch that is compatible with the rpi-5.10.y branch (the newest RT patch doesn't work anymore).

matthiasthomasbecker commented 2 years ago

thank you a lot! I rebuild the kernel using 5.15 and all went smooth.

I am not sure what exactly went wrong when I tried it initially as I got the same error for 5.10 and 5.15 when the patch was applied.