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

Bookworm Support #25

Open
reraikes opened this issue Nov 12, 2023 · 20 comments
Open

Bookworm Support #25

reraikes opened this issue Nov 12, 2023 · 20 comments

Comments

@reraikes
Copy link

reraikes commented Nov 12, 2023

rpi-source always succeeds on Bullseye but fails on Bookworm if rpi-update has not previously been run (which creates /boot/firmware/.firmware_revision):

*** SoC: BCM2711
ERROR:
Can't find a source for this kernel

Linux raspberrypi 6.1.0-rpi4-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.54-1+rpt2 (2023-10-05) aarch64 GNU/Linux

@pelwell
Copy link
Member

pelwell commented Nov 15, 2023

@XECDesign How can we determine the head commit for the kernel (even if we omit the Debian patches)? Which package installs the kernel? dpkg -S /boot/firmware/kernel8.img complains it can't find a match.

@XECDesign
Copy link
Member

You could do something along the lines of zcat /usr/share/doc/linux-image-$(uname -r)/changelog.Debian.gz | head

For that dpkg command, the equivalent would be something like dpkg -S /boot/vmlinuz-*-v8 | tail -n1

@pelwell
Copy link
Member

pelwell commented Nov 15, 2023

Thanks - that gets me further:

linux (1:6.1.58-1+rpt2) bookworm; urgency=medium
  * Linux commit: ccf1586ad0663fa91238ac56abf6340d6d740d18
  * Remove most Debian patches
  * Bump ABI to rpi5
 -- Serge Schneider <[email protected]>  Fri, 27 Oct 2023 14:31:48 +0000

linux (1:6.1.58-1+rpt1) bookworm; urgency=medium
  * Linux commit: 3ed6d34d53e94ecbebc64c8fa3d1b6d3c41db8fb
 -- Serge Schneider <[email protected]>  Wed, 25 Oct 2023 13:04:06 +0000

The second of these hashes is a recognised kernel commit in rpi-6.1.y, one that matches the rpi-firmware stable release of Oct 24, but the first isn't.

@XECDesign
Copy link
Member

I think because it was built from a PR. raspberrypi/linux@ccf1586

@john-ardu
Copy link

Hi @XECDesign ,
I tried compiling the kernel module from the kernel source and loading it into the raspberry pi kernel (without replacing the kernel), and I ran into some trouble. I tried the hash from the changelog, and the git hash from the raspberrypi/firmware repository, both It doesn't work properly. I think it may be because the KERNEL REALESE (vermagic) name has been modified (6.1.0-rpi4-rpi-v8). Is there any way I can modify it during compilation, or how the Raspberry Pi is compiled and publish it?

@XECDesign
Copy link
Member

Can you let me know which module you're building and I can see if I can write some instructions?

@john-ardu
Copy link

Can you let me know which module you're building and I can see if I can write some instructions?

That's great! I'm using Pi5 and Pi4.

@XECDesign
Copy link
Member

I mean which linux driver are you building as a module, not which pi model you're using.

@XECDesign
Copy link
Member

XECDesign commented Nov 24, 2023

I'll just leave links containing the answers regardless of what you're doing.

To get the exact source the kernel was built from (you'd need to know a little about debian packages):
https://www.debian.org/doc/manuals/debian-kernel-handbook/ch-common-tasks.html#s4.2.3
You'd use fakeroot make -f debian/rules.gen setup_arm64_rpi.

To build external modules, everything you need is already provided int he headers package, so you can just do this:
https://docs.kernel.org/kbuild/modules.html#command-syntax

EDIT: An example to build the wireguard module...

sudo apt-get install linux-source
tar xf /usr/src/linux-source-6.1.tar.xz
make -C "/lib/modules/$(uname -r)/build" M="$(PWD)/linux-source-6.1/drivers/net/wireguard"
sudo make -C "/lib/modules/$(uname -r)/build" M="$(PWD)/linux-source-6.1/drivers/net/wireguard" modules_install

@john-ardu
Copy link

I mean which linux driver are you building as a module, not which pi model you're using.

Sorry I misunderstood, I was thinking it doesn't seem to make a difference which kernel module is used

@john-ardu
Copy link

I'll just leave links containing the answers regardless of what you're doing.

To get the exact source the kernel was built from (you'd need to know a little about debian packages): https://www.debian.org/doc/manuals/debian-kernel-handbook/ch-common-tasks.html#s4.2.3 You'd use fakeroot make -f debian/rules.gen setup_arm64_rpi.

To build external modules, everything you need is already provided int he headers package, so you can just do this: https://docs.kernel.org/kbuild/modules.html#command-syntax

EDIT: An example to build the wireguard module...

sudo apt-get install linux-source
tar xf /usr/src/linux-source-6.1.tar.xz
make -C "/lib/modules/$(uname -r)/build" M="$(PWD)/linux-source-6.1/drivers/net/wireguard"
sudo make -C "/lib/modules/$(uname -r)/build" M="$(PWD)/linux-source-6.1/drivers/net/wireguard" modules_install

Thank you very much, I will give it a try!

@john-ardu
Copy link

Hi @XECDesign

Is there a way to build it from kernel source using cross compilation?
The method mentioned above requires some binary information on the Raspberry Pi (/lib/modules/$(uname -r)). I have to compile it on raspberry pi.

The method I used before:
https://www.raspberrypi.com/documentation/computers/linux_kernel.html#cross-compiling-the-kernel

@XECDesign
Copy link
Member

Not without downloading the relevant .deb file and extracting the necessary files from it.

@john-ardu
Copy link

Not without downloading the relevant .deb file and extracting the necessary files from it.

Thank you for your reply.
I took a closer look and found that debian will add some patches to the kernel and use .kernelvariables files to overwrite some variables. I think this is why the relevant deb is necessary.

@john-ardu
Copy link

Hi @XECDesign
Another thing I'm not sure about is where did the linux-6.1.xxx source code downloaded from apt source come from? It doesn't seem to match any hash in raspberrypi/linux, even we do patch rpi.patch in debian.

@XECDesign
Copy link
Member

Thank you for your reply. I took a closer look and found that debian will add some patches to the kernel and use .kernelvariables files to overwrite some variables. I think this is why the relevant deb is necessary.

It might be a factor, but there are many other reasons. Taking build artifacts from two completely different build environments and different sources is a non-starter altogether.

Hi @XECDesign Another thing I'm not sure about is where did the linux-6.1.xxx source code downloaded from apt source come from? It doesn't seem to match any hash in raspberrypi/linux, even we do patch rpi.patch in debian.

The 'upstream' part of the source comes straight from kernel.org. You can take a look at the debian source package to see how everything is generated. The tarball you get from the linux-source-* package may or may not have some additional patches applied. I didn't look too closely, since I only used it as an example.

It's probably to take further questions like that to the forum.

@john-ardu
Copy link

Thank you for your reply. I took a closer look and found that debian will add some patches to the kernel and use .kernelvariables files to overwrite some variables. I think this is why the relevant deb is necessary.

It might be a factor, but there are many other reasons. Taking build artifacts from two completely different build environments and different sources is a non-starter altogether.

Hi @XECDesign Another thing I'm not sure about is where did the linux-6.1.xxx source code downloaded from apt source come from? It doesn't seem to match any hash in raspberrypi/linux, even we do patch rpi.patch in debian.

The 'upstream' part of the source comes straight from kernel.org. You can take a look at the debian source package to see how everything is generated. The tarball you get from the linux-source-* package may or may not have some additional patches applied. I didn't look too closely, since I only used it as an example.

It's probably to take further questions like that to the forum.

Got it!

@reraikes
Copy link
Author

The content of this issue has drifted from the original post.

Is it expected that rpi-source will be fixed?

@pelwell
Copy link
Member

pelwell commented Nov 30, 2023

It's underway.

@reraikes
Copy link
Author

It's underway.

Thank you. I will await hearing that it's ready for use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants