The Mainline Kernel
We want to get as many devices working with one shared kernel package (based on upstream). Making a device boot with the upstream kernel is commonly referred to as mainlining.
Carrying around forks of the kernel is not sustainable as it becomes impossible to provide security patches after a short time. The only way to truly fix this for a device is mainlining it.
That package is
linux-postmarketos-stable. For devices, which are in the kernel's
mainline release, but not yet in
stable (see kernel releases), we also have
linux-postmarketos-mainline. It is even allowed to carry temporary patches around on top of these kernels, as long as work is being done to get them upstreamed properly. The kernel packages based on the official one are in
aports/main/postmarketos-linux*, while the device-specific forks are in
To make the kernel work with multiple devices, it no longer appends the
dtb file to the kernel image. Instead, it puts all
dtb files for the current architecture in
postmarketos-mkinitfs package appends the
dtb file defined in the deviceinfo to the linux image in the boot partition.
Device tree source (ARM architecture)
To make your device boot, you will need a device tree source (
dts) file (which will get compiled to a
dtb mentioned above). Check the
arch/arm/boot/dts folder in the kernel source code for relevant files (browse online) with your device's codename.
When you don't have a result, try to find a
dts file with the same chipset as your device (e.g.
msm8974). Try to create a new one for your device based on that by creating a patch for
linux-postmarketos-stable. If there is not even a
dts file for the same chipset, you need to create one from scratch (no idea how to do that, good luck and please extend the wiki).
Enable the mainline kernel for a new device
Before proceeding, make sure that you know that your device is supported by the mainline kernel. Otherwise use the source code of a vendor's fork of the kernel, which is known to work as described in the porting guide.
pmbootstrap.py menuconfig linux-postmarketosand adjust the kernel config to add the drivers for the device if they are not enabled yet. Set as much drivers to build as external module as possible so the main vmlinuz filesize doesn't increase too much.
- Set the kernel dependency to
linux-postmarketosin the APKBUILD for the device package if you want to make it the default kernel (more information).
- Add the name of the generated dtb file (without path or extension) to the
deviceinfo_dtbfile in the deviceinfo file.
A good example of a device using a mainline kernel is the
Porting drivers from a Linux fork to the mainline kernel
This is a massive amount of work, and you will need C knowledge, as well as knowledge about how to contribute to the kernel. It is probably a very frustrating path, so make sure that you are either up to that or consider contributing in pmOS in another, from a developers point of view, more enjoyable way. Documentation from our side is also pretty thin on this, so if you actually work on this, please expand it. Thanks!
If you never worked on kernel before, you may want to help with some simple driver on already-working device. Nokia N900 should be easy, Nokia N9, N950 and Motorola Droid 4 are a bit harder. You might also try to revive support for something older, Nokia N770, N800 or N810 may not be too hard. Next in difficulty is unsupported phone based on supported SoC. TI OMAPs have pretty good support, so Samsung i9100g might be good target... Preparing mainline support for new SoC may be too much work for individual developer.
- Select a device where support is doable. Get a suitable one if necessary.
- Get a working serial cable
- Find out hardware details about your device, such as CPU, GPU, display, ...
- Find out which drivers are missing from mainline.
- Configure bootloader
Boot with serial output and shell
You probably need to copy over the device tree source, from which the
dtb file gets generated, to the mainline kernel. Please expand this.
- Qualcomm mainline porting
- Blog about mainline kernel support for the Motorola Droid 4
- Freedreno wiki: Display driver porting
- #91: "The Mainline Kernel"
- Debian on N900
- Build Mainline for Xperia devices
- How to get an Android kernel up to date with Linux upstream
- Submitting your first patch to the Linux kernel and responding to feedback