Kernel configuration

From postmarketOS
Jump to: navigation, search

Changing the kernel configuration

You can change the kernel configuration with pmbootstrap, for the linux-sony-yuga package for example we run:

./pmbootstrap.py menuconfig sony-yuga

This gives you a menu where you can select and deselect all kernel configuration options. Press the / key to get a search dialog.

KernelConfig.png

Options aren't always visible!

If you're looking for an option and you just can't find it, then it might not show up because it depends on other options that have been disabled. In that case, press / and search for the option in question. You will see the dependencies. Then use the search again to find these dependencies, and enable them until you can finally enable the option you wanted to change in the first place.

Useful kernel configuration options

Required

Enable or disable the following options to get postmarketOS working. Use ./pmbootstrap.py kconfig_check to check which options need to be modified.

CONFIG_DEVTMPFS

About

This adds support for the devtmpfs filesystem which should be mounted to /dev at startup. The kernel driver core creates device nodes for all registered devices in that filesystem. All device nodes are owned by root and have the default mode of 0600. Userspace can add and delete the nodes as needed.

Read more...

Location in menu

Device Drivers -->
  Generic Driver Options -->
    Maintain a devtmpfs filesystem to mount at /dev

pmOS specific

This should always be set, otherwise you get this when you try SSH:

PTY allocation request failed on channel 0
-ash: a: unknown operand

CONFIG_DEVTMPFS_MOUNT

About

This will instruct the kernel to automatically mount the devtmpfs filesystem at /dev, directly after the kernel has mounted the root filesystem. The behavior can be overridden with the commandline parameter: devtmpfs.mount=0|1.

Read more...

Location in menu

Device Drivers -->
  Generic Driver Options -->
    Automount devtmpfs at /dev, after the kernel mounted the rootfs

pmOS specific

This option should not be set.

CONFIG_VT

About

If you say Y here, you will get support for terminal devices with display and keyboard devices. These are called "virtual" because you can run several virtual terminals (also called virtual consoles) on one physical terminal. This is rather useful, for example one virtual terminal can collect system messages and warnings, another one can be used for a text-mode user session, and a third could run an X session, all in parallel. Switching between virtual terminals is done with certain key combinations, usually Alt-<function key>.

Read more...

Location in menu

Device Drivers -->
  Character Devices -->
    Virtual Terminal

pmOS specific

This should always be set, otherwise you cannot get virtual terminal over USB.

CONFIG_DM_CRYPT

About

This device-mapper target allows you to create a device that transparently encrypts the data on it.

Read more...

Location in menu

Device Drivers -->
  Multiple devices driver support (RAID and LVM) -->
    Device mapper support -->
      Crypt target support

pmOS specific

This should always be set, required for full disk encyption.

CONFIG_KERNEL_GZIP, CONFIG_KERNEL_XZ, CONFIG_KERNEL_LZO and CONFIG_KERNEL_LZMA

About

GZIP
The old and tried gzip compression. It provides a good balance between compression ratio and decompression speed.
Read more...
XZ
XZ uses the LZMA2 algorithm and instruction set specific BCJ filters which can improve compression ratio of executable code. The size of the kernel is about 30% smaller with XZ in comparison to gzip. The speed is about the same as with LZMA: The decompression speed of XZ is better than that of bzip2 but worse than gzip and LZO. Compression is slow.
Read more...
LZO
Its compression ratio is the poorest among the choices. The kernel size is about 10% bigger than gzip; however its speed (both compression and decompression) is the fastest.
Read more...
LZMA
This compression algorithm's ratio is best. Decompression speed is between gzip and bzip2. Compression is slowest. The kernel size is about 33% smaller with LZMA in comparison to gzip.
Read more...

Location in menu

General Setup -->
  Kernel compression mode -->
    Gzip
    LZMA
    XZ
    LZO

pmOS specific

You should set one of these to Y.

CONFIG_ANDROID_PARANOID_NETWORK

About

Android adds a "paranoid network" option to the Linux kernel, which restricts access to some networking features depending on the group of the calling process. The list of groups that are allowed access to networking features is in the kernel source file: /include/linux/android_aids.h Setting this config will enable the paranoid network security feature

Read more...

Location in menu

Networking Support -->
  Networking Options -->
    Only allow certain groups to create sockets

Android specific

This option should not be set in pmOS or any other OS not using Android security model.


CONFIG_PFT

About

This caused builds to fail with a modern GCC at least once, and while it originally was meant as security feature by Qualcomm, "it is unsupported by Qualcomm, and opens up to a wide range of potential attack surfaces that has not been audited by anyone." [1].

Location in menu

Device Drivers -->
  Qualcomm MSM specific device drivers -->
    Per-File-Tagger driver

pmOS specific

Please disable it, so we have one less source for failing builds and enabling it has no benefit anyway.


CONFIG_SYSVIPC

Location in menu

General Setup -->
  System V IPC

pmOS specific

Please enable it for postmarketOS, so busybox' syslogd can log to a ringbuffer in the kernel (fixes #808).

Optional

These kernel options are optional and for some devices required to fix some issues.

CONFIG_USB_G_ANDROID

About

The Android Composite Gadget supports multiple USB functions: adb, acm, mass storage, mtp, accessory and rndis.

Each function can be configured and enabled/disabled dynamically from userspace through a sysfs interface.

Location in menu

Device Drivers -->
  USB Support -->
    USB Gadget Support -->
      USB Gadget Drivers -->
        Android Composite Gadget

pmOS specific

Enabling this option is needed for usb networking on some of the android kernels.

CONFIG_USB_ETH

About

This driver implements Ethernet style communication, in one of several ways:

  • The "Communication Device Class" (CDC) Ethernet Control Model. That protocol is often avoided with pure Ethernet adapters, in favor of simpler vendor-specific hardware, but is widely supported by firmware for smart network devices.
  • On hardware can't implement that protocol, a simple CDC subset is used, placing fewer demands on USB.
  • CDC Ethernet Emulation Model (EEM) is a newer standard that has a simpler interface that can be used by more USB hardware.

RNDIS support is an additional option, more demanding than than subset.

Read more...

Location in menu

Device Drivers -->
  USB Support -->
    USB Gadget Support -->
      USB Gadget Drivers -->
        Ethernet Gadget

pmOS specific

Most devices do not need this to be set. If telnet/SSH does not work you can try and set this option to Y.

CONFIG_USB_ETH_RNDIS

About

Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, and Microsoft provides redistributable binary RNDIS drivers for older versions of Windows.

If you say "y" here, the Ethernet gadget driver will try to provide a second device configuration, supporting RNDIS to talk to such Microsoft USB hosts.

Read more...

Location in menu

Device Drivers -->
  USB Support -->
    USB Gadget Support -->
      USB Gadget Drivers -->
        RNDIS Support

pmOS specific

Required if you set CONFIG_USB_ETH to 'Y'.

CONFIG_MSM_KGSL

About

3D graphics driver. Required to use hardware accelerated OpenGL ES 2.0 and 1.1.

Read more...

Location in menu

Device Drivers -->
  Graphics Support -->
    MSM 3D graphics Driver

pmOS specific

If framebuffer does not work set this to 'N'

CONFIG_CMDLINE

About

Enter arguments here that should be compiled into the kernel image and used at boot time. If the boot loader provides a command line at boot time, it is appended to this string to form the full kernel command line, when the system boots.

Read more...

Location in menu

General Setup -->
  Boot options -->
    Default kernel command string

pmOS specific

No

CONFIG_BUILD_ARM_APPENDED_DTB_IMAGE

About

Build a concatenated zImage/dtb by default

Enabling this option will cause a concatenated zImage and list of DTBs to be built by default (instead of a standalone zImage.)

The image will built in arch/arm/boot/zImage-dtb

Location in menu

General Setup -->
  Boot options -->
    appended device tree blob to zImage

pmOS specific

Set this if your device needs an appended device tree. If you are unsure, use extract-dtb on an existing kernel image. Not to be confused with CONFIG_ARM_APPENDED_DTB!

Automatically merging kernel configuration

This hasn't been tested a lot and will probably break something.

This is a small python script that will find kernel config thats enabled in one kernel config but not in the other. You can use it by running it against the kernel config file in pmbootstrap and a defconfig from an android tree:

$ diffconfig.py config-postmarketos-mainline.armhf hammerhead_defconfig
CONFIG_ZSWAP=y
CONFIG_ZPOOL=y
CONFIG_Z3FOLD=y
....

It should be save to append the output from the diff command to the existing config*.armhf file to merge the extra kernel config needed for a device into the more generic postmarketOS kernel. Make sure that the outputted diff lines don't contain lines that change the more general kernel options like CONFIG_KERNEL_LZMA and make sure you run the menuconfig command after appending the config so the new kernel config is sanitized.

#!/usr/bin/env python3
def parse_config(raw):
    result = {}
    for line in raw.splitlines():
        if line.startswith("#"):
            continue
        if line.strip() == "":
            continue

        key, value = line.split("=", maxsplit=1)
        result[key] = value

    return result


def diff_configs(a, b):
    result = []
    config_a = parse_config(a)
    config_b = parse_config(b)
    for key, value in config_b.items():
        if key not in config_a:
            result.append("{}={}".format(key, value))
    return result


if __name__ == '__main__':
    import argparse

    parser = argparse.ArgumentParser(description="defconfig diff utility")
    parser.add_argument('config_a', type=open)
    parser.add_argument('config_b', type=open)
    args = parser.parse_args()

    with args.config_a:
        a = args.config_a.read()

    with args.config_b:
        b = args.config_b.read()

    diff = diff_configs(a, b)
    for line in diff:
        print(line)


References

  1. Linux Kernel Driver Database