The Mainline Kernel

From postmarketOS
Jump to: navigation, search

One of the major goals of the postmarketOS project is getting as many devices as possible working on the mainline upstream Linux kernel. The majority of the current devices run some form of Android kernel tree like AOSP, LineageOS or CyanogenMOD.

The current progress of the mainlining effort is in the linux-postmarketos package, which can be used by multiple devices. The only pmOS-supported device that is usable with Linux 4.12 is the N900. The qemu-vexpress-(Qemu-with-vexpress-soc) packages also use the linux-postmarketos package.

To make the kernel work with multiple devices, it no longer appends the dtb file to the kernel image. It generate a vmlinuz-postmarketos file in the boot partition and puts all dtb files for the current architecture in /usr/share/dtb. The postmarketos-mkinitfs package appends the dtb file defined in the deviceinfo to the linux image in the boot partition.

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.

  1. run menuconfig linux-postmarketos and 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.
  2. Set the kernel dependency to linux-postmarketos in the APKBUILD for the device package if you want to make it the default kernel (more information).
  3. Add the name of the generated dtb file (without path or extension) to the deviceinfo_dtb file in the deviceinfo file.

A good example of a device using a mainline kernel is the device-nokia-rx51 package.

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.