Jump to content

The Mainline Kernel: Difference between revisions

From postmarketOS Wiki
Wfranken (talk | contribs)
m Added link on how to build mainline for Xperia devices
merge the page to Mainlining_Guide
Tag: New redirect
 
(36 intermediate revisions by 17 users not shown)
Line 1: Line 1:
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.
#REDIRECT [[Mainlining_Guide]]


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


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


== 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]].''


# run <code>pmbootstrap.py menuconfig linux-postmarketos</code> 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.
Examples:
# Set the kernel dependency to <code>linux-postmarketos</code> in the APKBUILD for the device package if you want to make it the default kernel ([https://github.com/postmarketOS/pmbootstrap/issues/91#issuecomment-318825285 more information]).
* <code>qcom-msm8974-lge-nexus5-hammerhead.dts</code>
# Add the name of the generated dtb file (without path or extension) to the <code>deviceinfo_dtb</code> file in the deviceinfo file.
* <code>qcom-msm8974-sony-xperia-honami.dts</code>
* <code>qcom-apq8064-sony-xperia-yuga.dts</code>
* <code>qcom-apq8064-asus-nexus7-flo.dts</code>


A good example of a device using a mainline kernel is the <code>device-nokia-rx51</code> package.
When you don't have a result, try to find a <code>dts</code> file with the same chipset as your device (e.g. <code>msm8974</code>). Try to create a new one for your device based on that by [[How_to_create_a_patch_when_packaging_software|creating a patch]] for <code>linux-postmarketos-stable</code>. If there is not even a <code>dts</code> 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'').


== Porting drivers from a Linux fork to the mainline kernel ==
== Enable the mainline kernel for a new device ==


''This is a massive amount of work, and you will need C knowledge, as well as knowledge about [https://kernelnewbies.org/KernelHacking 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!''


=== Preparation ===
#
 
# Set the kernel dependency to <code>linux-postmarketos</code> in the APKBUILD for the device package if you want to make it the default kernel ([https://github.com/postmarketOS/pmbootstrap/issues/91#issuecomment-318825285 more information]).
* Get a working [[Serial-debugging|serial cable]]
# Add the name of the generated dtb file (without path or extension) to the <code>deviceinfo_dtb</code> file in the deviceinfo file.
* Find out hardware details about your device, such as CPU, GPU, display, ...
 
=== Boot with serial output and shell ===
 
You probably need to copy over the device tree source, from which the <code>dtb</code> file gets generated, to the mainline kernel. ''Please expand this.''
 
=== Links ===


* Blog about [http://elektranox.org/droid4/ mainline kernel support for the Motorola Droid 4]
A good example of a device using a mainline kernel is the <code>device-nokia-n900</code> package.
* [https://github.com/freedreno/freedreno/wiki/DSI-Panel-Driver-Porting Freedreno wiki: Display driver porting]
* [https://github.com/postmarketOS/pmbootstrap/issues/91 #91: &quot;The Mainline Kernel&quot;]
* [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]

Latest revision as of 17:05, 19 June 2023

Redirect to:

Introduction

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

  1. 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).
  2. 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-n900 package.