Apply a patch to kernel-default and build it via OBS?

Hi all,

I’m using TW on a Framework laptop, and would like to learn how I can build the current kernel with a small patch applied.

The patch is mentioned here:

I have zero experience with building the kernel, but since it is my understanding that OBS can run builds, I was wondering if I’m not better off just letting OBS do the heavy lifting for me.

What I’m looking for is a way to fork the kernel used by TW, apply that patch there, and then let OBS compile and package it.

AFAIK I should then be able to install this patched kernel on my system with a bunch of zypper commands.

Can I find a step by step guide somewhere, or would someone be so kind to explain the process to me?

Thanks :slight_smile:

@andrea.ippo You don’t need to build the whole kernel, just that module, assuming it’s in use…

Can you show the output from lsmod | grep pinctl

See

search for “How to add custom patches”.

It’s not loaded indeed, output is empty

Is this the right command to try and load it?

❯ sudo modprobe pinctl
[sudo] password for root: 
modprobe: FATAL: Module pinctl not found in directory /usr/lib/modules/6.8.9-1-default

I was wondering if pinctl was a typo, but pinctrl yielded the same results.

In this case, should I build the module by myself and load it?

Thanks

Output of pinctrl modules:

Yes, it was.

It is built into kernel

CONFIG_PINCTRL=y
1 Like

Thanks, I added CONFIG_PINCTRL=y to the kernel parameters via YaST:

and rebooted, but still nothing.

image

In the output of modprobe -c I linked in my previous post there is no pinctrl-amd (or _amd) to be seen. I think that’s the one I’m looking for?

Sorry? You do understand, that driver can be built into kernel or built as loadable module, do not you?

Kernel Build System — The Linux Kernel documentation

Ok so that is a build flag, not a kernel command line parameter, my bad. That wasn’t clear to me

I wanted to avoid building the entire kernel if there’s a simpler route

You cannot change built-in driver into module without rebuilding the whole kernel to not include this driver.

But OBS does it for you. All that you need to do - provide the patch in the correct format as described in the README.SUSE. Branch kernel package, replace the patches.addon.tar.bz2 with the archive containing your patch, wait for OBS to finish build.

Thanks

I’ve tried something but I’m not sure it’s correct.

I have created a project here:

Branched package kernel-source

Checked it out on my PC with:
osc -A https://api.opensuse.org checkout home:andrea.ippo/pinctrl-amd-Set-up-affinity-for-GPIO-lines-when-enabling-interrupt

Browsed to the local files and modified config.addon.tar.bz2 and patches.addon.tar.bz2 as follows.

In config.addon.tar.bz2, I have added this structure:
image

In patches.addon.tar.bz2 I have added this:

Then I run osc commit

But the build now fails:

https://build.opensuse.org/build/home:andrea.ippo/openSUSE_Tumbleweed/x86_64/pinctrl-amd-Set-up-affinity-for-GPIO-lines-when-enabling-interrupt:kernel-default/_log

What have I missed?

If you had pasted text as text, instead of pictures, it were possible to comment on it. Anyway - trying to disable driver and and to apply patch for this driver at the same time sounds … amusing.

The kernel RPM package scripts check that your configuration is consistent and reproducible. make oldconfig produced different configuration, so build failed.

Kernel build system can automatically enable kernel options if other kernel options are selected. Which is what happened here. PINCTRL got re-enabled and this resulted in failure because it means your configuration change was inconsistent.

You do not need any configuration changes. You only need the patch for your driver. And if you insist on your configuration change you need to also disable any option that implicitly enables PINCTRL and do it recursively. But how are you going to test changes to pinctrl driver if you are going to disable pinctrl driver?

Thanks, the new build was successful :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.