Jump to content

How to apply my own kernel patch


Recommended Posts

Hello,

 

I try build kernel for NanopiNeo board with user kernel patch, but I don't understand with path needed put my patch. In previous version armbian's builds I just put files to userpatches/kernel/sunxi-current how it described in docs. But now with current version Armbian build system it's not working.

I put my custom linux-sunxi-current.config to userpatches folder, my patch to userpatches/kernel/sunxi-current and try build kernel with command:

./compile.sh BOARD=nanopineo BRANCH=current kernel

I see that linux-sunxi-current.config found and applied but not patch isn't.

Link to comment
Share on other sites

Is this option used to create a patch and apply it at the same time? I've only used it for making patches, not for building the kernel.
That is, to build the kernel with my patch, I have to use this command:

./compile.sh BOARD=nanopineo BRANCH=current kernel-patch,kernel

?

Link to comment
Share on other sites

11 hours ago, nikkov said:

Is this option used to create a patch and apply it at the same time?

 

No it creates your patch, then you have to manually apply.

[🌱] You will find your patch here: [ /home/alistair/build/output/patch/kernel-sunxi64-edge.patch ]
[✨] Now you can manually move the produced patch to your userpatches or core patches to have it included in the next build [ /home/alistair/build/output/patch/kernel-sunxi64-edge.patch ]
[💖] Stopping after creating kernel patch
[🌱] Runtime [ 2:27 min ]

 

I do it this way for sunxi kernels as an example:

 

git -C cache/sources/linux-kernel-worktree/6.2__sunxi64__arm64 format-patch -1 -o ~/build/patch/kernel/archive/sunxi-6.2/patches.armbian/
/home/alistair/build/patch/kernel/archive/sunxi-6.2/patches.armbian/0001-Patching-kernel-sunxi64-files-arch-arm64-boot-dts-al.patch

 

 cd into the directory:

 

mv 0001-Patching-kernel-sunxi64-files-arch-arm64-boot-dts-al.patch <name of your new patch>.patch

 

 

In order to apply the patch during the build you have to change the series files to include your patch.

 

You include(commit) or discard your changes to git as you chose.

 

I don't have a use for userpatches (can't comment whether or not it works 'as expected' in main) as I'm normally doing a specific task that will lead to a commit.

 

I found inconsistencies (1st weeks of main) where patches (output/patch) were included in build even though not implicitly stated with cmd.

 

Hope this somewhat helps!

Link to comment
Share on other sites

Thank you for your time!

 

6 hours ago, ALIGMSTEN said:

In order to apply the patch during the build you have to change the series files to include your patch.

If I understand correctly, I have to include my patch in one of this files: /build/patch/kernel/archive/sunxi-6.1/series.* or just put it to folder /build/patch/kernel/archive/sunxi-6.1/.

Not a very clear approach, the previous one was more understandable, especially since the userpatches folder is still used.

Edited by nikkov
Link to comment
Share on other sites

Yes that's right you must include the file in the directory /sunxi-6.1/patches.armbian and then manually edit the file at patch/kernel/archive/sunxi-6.1/series.conf   series.armbian  to include your new patch.

 

I've not tried userpatches and don't know if it functions or not - perhaps raise an issue if you are sure it not currently working.

 

ADD: I think its correct that placing the file in the top directory series.conf picks it up (was smth like that master)

 

 

Link to comment
Share on other sites

For anyone else looking to patch their kernel through userpatches - it seems that (at least with the updated build system that uses the quite complex lib/tools/patching.py to apply patches) you can just drop a patch in `userpatches/kernel/archive/<platform>-<version>/` and it will be picked up (in my case, it was `userpatches/kernel/archive/sunxi-6.7`). No series file needed. I used a patch generated with `git format-patch`, but it seems that the script supports different formats, even mbox with multiple patches inside.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines