我要评分
获取效率
正确性
完整性
易理解

Creating and Configuring a .config File

Generate a .config file and configure kernel compilation options.

The first step to compile the kernel is to create a .config file in which the functions and features that need to be enabled are declared.

  1. Copy the config file in the /boot directory to the source code directory and rename the file to .config.

    In the command, the name of the config file in the /boot directory is only an example. You can use the uname -r command to view the actual file name. The config file version must match the OS kernel version.

    If the config-`uname -r` file does not exist in the /boot directory, copy any file prefixed with config- in the /boot directory to the kernel source code directory on the server and rename the file .config.

    1
    cp /boot/config-`uname -r` /usr/src/kernels/kernel-5.10.0-136.12.0/.config
    
  2. Update the .config file content.
    1
    2
    cd /usr/src/kernels/kernel-5.10.0-136.12.0/
    make menuconfig
    
  3. Select Load in the following page:

  4. Select OK in the following page:

  5. Configure the kernel compilation options.

    In the page shown in Figure 1, configure the kernel compilation options according to Table 1.

    Figure 1 Kernel configuration page
    Table 1 Kernel compilation options

    Configuration Item

    Required Value

    Configuration Prompt

    Configuration Result Written to the .config File

    STAGING

    Y

    [*] Staging drivers

    CONFIG_STAGING=y

    ANDROID

    Y

    [*] Android Drivers

    CONFIG_ANDROID=y

    ASHMEM

    Y

    [*] Enable the Anonymous Shared Memory Subsystem

    CONFIG_ASHMEM=y

    ANDROID_BINDER_IPC

    Y

    [*] Android Binder IPC Driver

    CONFIG_ANDROID_BINDER_IPC=y

    ANDROID_BINDERFS

    Y

    [*] Android Binderfs filesystem

    CONFIG_ANDROID_BINDERFS=y

    ANDROID_ALARM

    Y

    <*> Android Alarm Driver

    CONFIG_ANDROID_ALARM=y

    ANON_VMA_NAME

    Y

    [*] Anonymous VMA name support

    CONFIG_ANON_VMA_NAME=y

    EXAGEAR_BT

    Y

    [*] Exagear binary translator support

    CONFIG_EXAGEAR_BT=y

    VFAT_FS

    Y

    <*> VFAT (Windows-95) fs support

    CONFIG_VFAT_FS=y

    INPUT_UINPUT

    Y

    <*> User level driver support

    CONFIG_INPUT_UINPUT=y

    HISI_PMU

    M

    <M> HiSilicon SoC PMU drivers

    CONFIG_HISI_PMU=m

    SYSTEM_TRUSTED_KEYS

    Clear out this field.

    ( ) Additional X.509 keys for default system keyring

    CONFIG_SYSTEM_TRUSTED_KEYS=""

    DEBUG_INFO

    N

    [ ] Compile the kernel with debug info

    # CONFIG_DEBUG_INFO is not set

    PID_RESERVE

    N

    [ ] Support for reserve pid

    # CONFIG_PID_RESERVE is not set

    PSI_DEFAULT_DISABLED

    N

    [ ] Require boot parameter to enable pressure stall information tracking

    # CONFIG_PSI_DEFAULT_DISABLED is not set

    Configuration methods:

    • Press the up, down, left, and right arrow keys to navigate the menu.
    • Press Enter to select a submenu or edit the content of a selected item.
    • Press Esc twice to exit.
    • Press / for search.
    • Press Y to compile the selected item into the kernel. The corresponding item is displayed as [*].
    • Press N to exclude the selected item. The corresponding item is displayed as [].
    • Press M to compile the selected item into a module (in KO format). The corresponding item is displayed as <M>.

    A configuration example is provided as follows:

    1. On the configuration page, press / to search, type STAGING, and press Enter. The search result is displayed, as shown in the following figure.

    2. Confirm the number of the configuration item, for example, (1) in the following figure. Press 1 to select the configuration item.

    3. Press Y to compile the selected item into the kernel, use the left and right arrow keys to navigate to <Exit>, and press Enter.

    4. On the kernel configuration home page, configure the next item as required.
  6. After the configuration is complete, choose Save on the kernel configuration home page.

  7. Select OK in the following page:

  8. Select Exit in the following page:

  9. The home page is displayed. Select Exit. The .config file content is updated.