Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing an Android kernel patch

I've been reading that it's possible to apply patches to your Android kernel to give them more features.

Here's an example: https://patchwork.kernel.org/patch/2254211/

But my question is, how exactly do I DEVELOP a patch from scratch? I'm confused on what language the patches are coded in and where the required documentation for developing a patch to a kernel is. I've already asked this on XDA developers but no one seems to know and that's why I asked it here.

like image 298
Prasanth Louis Avatar asked Sep 04 '26 14:09

Prasanth Louis


1 Answers

First of all you will need the source of the kernel you want to patch as it is explained here:

https://source.android.com/source/building-kernels.html

As you can see in your link these files are written in C. When you got the source you can change some lines in these files to create your own patch How you build your changed kernel is explained as well in the above link. You can also add new files for complete new functionality or features.

To create your .patch file you will have to do something like

diff -Naur old_file.c changed_old_file.c > patch.txt

or you could as well use eclipse or git to do so, as shown here:

https://docs.moodle.org/dev/How_to_create_a_patch

Another usefull tool to create patches and apply them is quilt. How to use it you can read here:

https://wiki.debian.org/UsingQuilt

The documentation is done in the code with comments. Depending on the developer there will be more or less comments to explain what happens in the code. Additional documentation can be found under:

https://www.kernel.org/doc/Documentation/

I think the Linux kernel coding style is used in Android kernel development as well. So you should stick to the coding style of the rest of the kernel to get your patch acknowledged by the maintainer.

https://www.kernel.org/doc/Documentation/CodingStyle

[EDIT]: If you want to participate in the community its a good idea to subscribe to the mailing list of the kernel part you are most interested in. You can also get a feeling for what is needed to be patched. The google groups are probably a good place to ask additional questions on how to go on.

https://source.android.com/source/community/index.html

You can also get the source for android here:

https://android.googlesource.com/?format=HTML

Did i leave something out?

like image 146
ikstream Avatar answered Sep 07 '26 06:09

ikstream