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.
See Mainlining Guide.
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
arm with your architecture) folder in the kernel source code for relevant files (browse online) with your device's codename. The general file naming is
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 kconfig edit postmarketos-qcomand 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. Replace
qcomwith the kernel config you want to modify (see
- 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
- Mainlining FAQ various information collected from #postmarketOS
- Qualcomm mainline porting
- Allwinner mainline effort
- Blog about mainline kernel support for the Motorola Droid 4
- Freedreno wiki: Display driver porting
- List of DTSI -> panel driver function translations
- #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
- Linux Kernel Release Model (reasons why we should all be using mainlined kernels)
- Documenting devices with mainline Linux support
- Device Tree reference on elinux.org
- Documentation of devicetree bindings
- opendata26 walking alibabzo through mainlining aries
- ARM64 SoC Linux Support Check-List (what needs to be done to get an arm64 soc to work on mainline)
- probably a list of which qualcomm socs are similar