Hello World

In this blog I’ll try to document my journey in bringing mainline Linux support for OnePlus Nord N100 and N10 phones (hopefully more down the line).


OK, so what does all that mean? As you might know, Android is actually based on Linux, so every Android device contains a Linux kernel and a bunch of other software, which as a whole, is named Android. You might be wondering what other software there is — well, if you try to build it on your own (following LineageOS instructions), you’ll realize that there are 769 (as of time of writing) repositories downloaded (the linux kernel is one of those).

The Linux kernel itself is also not the one straight from kernel.org, instead it is heavily patched by various vendors, resulting in a kernel “frozen in time”. This means that you can not simply update the kernel version from time to time (for security updates), because the kernel changes so much from release to release that it is a non-trivial task to port all the patches on top. The phone vendors normally support the kernel for some time (4 years tops, if you’re really lucky, normally around 2), but then they give up, because — it takes time and respectively money.

The reason the kernel in phones is so heavily modified, is that it contains most of the hardware drivers that are not yet present in the official Linux tree (the Mainline tree). The reason being, that accepting patches in the official tree takes time and effort, other people might point out bugs, issues, styling differences etc, and the developer will often have to address those to get his patches approved. So to put it simply, the vendor kernel modifications include code of questionable quality (hasn’t been peer reviewed) and mind boggling quantity 🙂

Going Mainline

To Mainline is basically to locate vendor specific bits and pieces, to modify them slightly so they fit the kernel style guides, and to submit them through the official kernel developer channels (the LKML).

After the code is accepted, it becomes part of the official kernel tree (it becomes Mainline), so from now on, the kernel supports this bit of hardware “forever”. Why do I put forever in quotes — because technically it is true, but in practice there needs to be somebody trying out new kernels from time to time and fixing regressions. You might be thinking CI/automated testing — it turns out this is not trivial when hardware is involved. In any case if somebody figures out a way to test on multiple devices automatically that will be a game changer.

Note about binary blobs

When talking about freedom, open source, evil corporations inevitably someone throws in the issue of binary blobs. Unfortunately most phones on the market today relay on such proprietary binary blobs for pieces such as modem (Calls, SMS, Cellular Data), WiFi, Bluetooth, sometimes camera. If you mainline a piece of hardware in your phone that needs a binary firmware to operate, if you don’t provide the firmware in a known location the hardware simply won’t work. So you, the user, has a final say into whether to use a given functionality and depend on a binary blob, or not use the functionality and not depend on it. I think this is a fair compromise. In cases where the firmware is not cryptographically signed, it is (in theory) possible to reverse engineer it, and make an open source version of said binary firmware. This topic is outside the scope of this guide.


I’m by no means the first or the most skillful developer working on mainlining phones in their spare time. However, I think the lack of accessible documentation about the process limiting the reach of the community. In short — the people who are very good at this, are too busy doing it so the newcomers have to go the “hard way” and learn it mostly by themselves. There are thousands of youtube videos about getting into web development, but there are no videos about getting into mainlining phones.

That isn’t to say that there isn’t an active community. PostmarketOS is a great place to start, it has an active mainlining community (unlike most other linux phone distros, which mostly focus on users). Their matrix/irc mainlining channel is a great place for beginner mainlining developers to ask questions, and get going, they also have an excellent wiki. I still think that if you can follow somebody else in the process (via this blog) it will provide a lower barrier for entry.