Skip to content

09. Compiling Armbian Kernel | 编译 Armbian 内核

ophub edited this page Dec 7, 2023 · 1 revision

Kernel compilation is supported in Ubuntu20.04/22.04, Debian11 or Armbian systems. Both local compilation and GitHub Actions cloud compilation are supported. For specific methods, please refer to the Kernel Compilation Instructions.

9.1 How to Add Custom Kernel Patches

When there is a common kernel patch directory (common-kernel-patches) in the kernel patch directory tools/patch, or when there is a directory named the same as the kernel source repository (for example, linux-5.15.y), you can use -p true to automatically apply the kernel patch. The naming convention for the patch directory is as follows:

~/amlogic-s9xxx-armbian
    └── compile-kernel
        └── tools
            └── patch
                ├── common-kernel-patches  # Fixed directory name: stores common kernel patches for all versions
                ├── linux-5.15.y           # Named after the kernel source library: stores dedicated patches
                ├── linux-6.1.y
                ├── linux-5.10.y-rk35xx
                └── more kernel directory...
  • When compiling the kernel locally, you can manually create the corresponding directory and add the corresponding custom kernel patches.
  • When cloud compiling with GitHub Actions, you can use the kernel_patch parameter to specify the directory of the kernel patch in your repository, such as the usage of compile-beta-kernel.yml in the kernel repository:
- name: Compile the kernel
  uses: ophub/amlogic-s9xxx-armbian@main
  with:
    build_target: kernel
    kernel_version: 5.15.1_6.1.1
    kernel_auto: true
    kernel_patch: kernel-patch/beta
    auto_patch: true

When using the kernel_patch parameter to specify a custom kernel patch, please name the patch directory according to the above convention.

9.2 How to Make Kernel Patches

Before adding a custom kernel patch, it needs to be compared with the upstream kernel source repository unifreq/linux-k.x.y to confirm whether this patch has been added to avoid conflicts. Kernel patches that pass the test are recommended to be submitted to the series of kernel repositories maintained by unifreq. Each small step for a person is a big step for the world. Your contribution will make our use of Armbian and OpenWrt systems in the box more stable and interesting.

支持在 Ubuntu20.04/22.04,debian11 或 Armbian 系统中编译内核。支持本地编译,也支持使用 GitHub Actions 云编译,具体方法详见 内核编译说明

9.1 如何添加自定义内核补丁

当内核补丁目录 tools/patch 中有通用内核补丁目录(common-kernel-patches),或者有 与内核源码库同名 的目录时(例如 linux-5.15.y),可以使用 -p true 自动应用内核补丁。补丁目录的命名规范如下:

~/amlogic-s9xxx-armbian
    └── compile-kernel
        └── tools
            └── patch
                ├── common-kernel-patches  # 固定目录名:存放各版本都通用的内核补丁
                ├── linux-5.15.y           # 与内核源码库同名:存放专用补丁
                ├── linux-6.1.y
                ├── linux-5.10.y-rk35xx
                └── more kernel directory...
  • 在本地编译内核时,可以手动创建相应目录,添加对应的自定义内核补丁。
  • 在 GitHub Actions 云编译时,可以使用 kernel_patch 参数指定内核补丁在你仓库中的目录,例如 kernel 仓库中 compile-beta-kernel.yml 的使用方法:
- name: Compile the kernel
  uses: ophub/amlogic-s9xxx-armbian@main
  with:
    build_target: kernel
    kernel_version: 5.15.1_6.1.1
    kernel_auto: true
    kernel_patch: kernel-patch/beta
    auto_patch: true

当使用 kernel_patch 参数指定自定义内核补丁时,补丁目录请参照上述规范进行命名。

9.2 如何制作内核补丁

在添加自定义内核补丁前,需要先和上游的内核源码仓库 unifreq/linux-k.x.y 进行比较,确认此补丁是否已经添加,避免造成冲突。通过测试的内核补丁,建议向 unifreq 大佬维护的系列内核仓库进行提交。每人一小步,世界一大步,大家的贡献会让我们在盒子里使用 Armbian 和 OpenWrt 系统时更加稳定和有趣。