Jump to content

The Mainline Kernel: Difference between revisions

From postmarketOS Wiki
Pinoaffe (talk | contribs)
Mirh (talk | contribs)
Links: linux-sunxi effort, fixed xperia link
Line 36: Line 36:
* [[Mainlining FAQ]] various information collected from #postmarketOS
* [[Mainlining FAQ]] various information collected from #postmarketOS
* [[Qualcomm mainline porting]]
* [[Qualcomm mainline porting]]
* [http://linux-sunxi.org/Linux_mainlining_effort Allwinner mainline effort]
* Blog about [http://elektranox.org/droid4/ mainline kernel support for the Motorola Droid 4]
* Blog about [http://elektranox.org/droid4/ mainline kernel support for the Motorola Droid 4]
* [https://github.com/freedreno/freedreno/wiki/DSI-Panel-Driver-Porting Freedreno wiki: Display driver porting]
* [https://github.com/freedreno/freedreno/wiki/DSI-Panel-Driver-Porting Freedreno wiki: Display driver porting]
Line 41: Line 42:
* [https://github.com/postmarketOS/pmbootstrap/issues/91 #91: "The Mainline Kernel"]
* [https://github.com/postmarketOS/pmbootstrap/issues/91 #91: "The Mainline Kernel"]
* [http://n900.elektranox.org/index.html Debian on N900]
* [http://n900.elektranox.org/index.html Debian on N900]
* [https://developer.sonymobile.com/open-devices/how-to-build-and-flash-a-linux-kernel/how-to-build-mainline-linux-for-xperia-devices/ Build Mainline for Xperia devices]
* [https://developer.sony.com/develop/open-devices/guides/kernel-compilation-guides/how-to-build-mainline-linux-kernel-for-xperia-devices Build Mainline for Xperia devices]
* [https://forum.xda-developers.com/android/software-hacking/reference-how-to-upstream-android-kernel-t3626913 How to get an Android kernel up to date with Linux upstream]
* [https://forum.xda-developers.com/android/software-hacking/reference-how-to-upstream-android-kernel-t3626913 How to get an Android kernel up to date with Linux upstream]
* [https://nickdesaulniers.github.io/blog/2017/05/16/submitting-your-first-patch-to-the-linux-kernel-and-responding-to-feedback/ Submitting your first patch to the Linux kernel and responding to feedback]
* [https://nickdesaulniers.github.io/blog/2017/05/16/submitting-your-first-patch-to-the-linux-kernel-and-responding-to-feedback/ Submitting your first patch to the Linux kernel and responding to feedback]

Revision as of 17:22, 14 May 2018

Introduction

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.

Why bother?

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.

Mainlining guide

See Mainlining Guide.

Kernel packaging

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 aports/device/linux-*.

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 /usr/share/dtb. The 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 (replace 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 $chipset_vendor-$chipset-$vendor-$codename.dts.

Examples:

  • qcom-msm8974-lge-nexus5-hammerhead.dts
  • qcom-msm8974-sony-xperia-honami.dts
  • qcom-apq8064-sony-xperia-yuga.dts
  • qcom-apq8064-asus-nexus7-flo.dts

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.

  1. run pmbootstrap.py 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.

Links