Kernel Version Porting.

149 views
Skip to first unread message

krypticallusion

unread,
Feb 27, 2018, 10:26:39 AM2/27/18
to android-porting
Hey guys! 

I wanted to ask if it's possible to build New kernel versions for a phone which was shipped on a previous kernel version?

For example : I have a 3.10 kernel but I want to change to a 3.18 kernel. 

Is it possible? 
Sony does port their kernels too, so I guess it's possible.
But any documentation on how to do it?

Ilya Trukhanov

unread,
Mar 14, 2018, 9:37:23 AM3/14/18
to android-porting
Is it possible? Yes.
Is it practical? No.

First you need to understand that you can't put mainline kernel on a board (not a device, that's important) and expect it to just work. Although there are some exceptions, like Qualcomm's Dragonboards, that pretty much work out of the box because they are supported in mainline, most of the time you will need to patch the Linux kernel so that it boots and operates on your board of choice.

This is the first wave of patching, which diverges the kernel from mainline.

Second wave is getting peripherals to work — everything from an LCD display to speakers.

Once it is done, the board manufacturer releases their product along with kernel code and documentation to the public, at which point device manufacturers pick these boards up and introduce the third wave of patches — these are specific for a particular device. Generally this set of patches is limited to drivers of touchscreen, accelerometer etc. Most of the time you can actually take the generic board kernel and it will boot just fine, but most things won't work, since they need said drivers.

Now, if you want to port a newer kernel to your device, you will need to repeat these steps as if you were the board/device manufacturer, except you will be using a different kernel version.

Here's the problem: it takes a lot of time. Manufacturers have huge teams of developers working day and night on getting things done, and you are alone. Of course, it's a bit easier for you, since you don't have to work in the dark — all changes required for the board to boot are already there, you just need to adapt them to a newer kernel version. But it's easier said than done, since kernel API can vary greatly even in between two adjacent minor releases. The amount of work is also huge. For example, I have a 3.10.49 kernel from Qualcomm and it has a staggering 2 million lines of code difference from the mainline 3.10.49. The good thing is, 1.6 million is driver code, so I can spend about a week porting the other 400 thousand and it'll probably be functional.

So, to sum up: this is a bad idea. It is doable, but will take a lot of time and will probably take a toll on your mental health. If you really, really want to do it, your best bet is to team up with other developers who maintain devices of the same board. In the end it all comes down to the amount of time you can invest, but is spending weeks of you free time really worth it?
Reply all
Reply to author
Forward
0 new messages