Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux kernel recompilation instructions are wrong/incomplete #3575

Open
RaduLucianR opened this issue Apr 2, 2024 · 2 comments
Open

Linux kernel recompilation instructions are wrong/incomplete #3575

RaduLucianR opened this issue Apr 2, 2024 · 2 comments
Assignees
Labels
documentation update Things change with time, this is a change

Comments

@RaduLucianR
Copy link

I recently tried to recompile the Raspberry Pi Linux kernel to enable the PREEMPT_RT patch, but by following the instructions on the documentation page for this very thing I was lead to wrong steps and some things are missing.

I tried both to compile the kernel on my Raspberry Pi (version 4 B+, 64-bit), and to cross-compile it on my x86 laptop with Ubuntu 22.04 and then installing it on the SD card.

After finishing the compilation/cross-compilation, the documentation states that "If you now reboot, your Raspberry Pi should be running your freshly-compiled kernel.", but this is not the case. In both cases (compile and cross-compile) the kernel would not be correctly installed/linked, and the Raspberry Pi would just start up with its normal kernel.

I checked with ls /boot/vmlinuz* to see all available kernels, but the just installed kernel was not there, for compilation nor cross-compilation.

I found out that one could use the flash-kernel command to force the RPi to use the correct kernel. However, the flash-kernel command cannot find the freshly installed kernel because it doesn't have a vmlinuz.

The steps that worked for me to correctly compile and flash the kernel are the following:

  1. Cross-compile the Raspberry Pi Linux kernel like described in the docs, BUT use the flag LOCALVERSION=”-raspi”. We need this for the flash-kernel command. This command can force flash our newly installed kernel, but only if it's the "correct flavor". To make a kernel the "correct flavor" for RPis, it needs to have the "-raspi" suffix.
  2. Make a .deb package out of the freshly compiled kernel.
  3. Copy the .deb package on the RPi and install it.
  4. Reboot.
  5. Execute the flash-kernel -force <kernel_name> command with the kernel's name.
  6. Reboot.
  7. Now the RPi should start with the newly installed kernel.

My suggestions for the RPi docs:

  1. Mention the option to make a .deb package out of the cross-compiled Linux kernel and how to install it on the Raspberry Pi.
  2. Mention that one might need to use the flash-kernel utility to force the Linux kernel installation. In that case the kernel needs to be compiled with the LOCALVERSION=”-raspi”flag, so flash-kernel recognizes the kernel as having the correct flavor.

Some nice additions specific to the PREEMPT_RT patch would be to mention that one needs to disable KVM so that the Full RT option for the Linux kernel becomes available. I know this is not Raspberry Pi-specific but I think that using the PREEMPT_RT patch on a RPi will become more common in the future.

@aallan aallan added documentation update Things change with time, this is a change labels Apr 2, 2024
@by
Copy link

by commented Apr 27, 2024

Thanks, and please add a provision how to properly create initramfs requirements for custom kernels, thank you!

@lurch
Copy link
Contributor

lurch commented Apr 27, 2024

See also #3249

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation update Things change with time, this is a change
Projects
None yet
Development

No branches or pull requests

5 participants