Skip to content

systemnb/compile_android_driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

106 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kade – Android Kernel Driver Automation (lyenv-based)

Read this in other languages: English, 中文.

kade is an Android kernel driver automation framework built on top of lyenv. It provides a configuration-driven, reproducible workflow for building GKI and non-GKI kernels locally and in CI (GitHub Actions).

This repository is designed to work with:


Features

  • ✅ GKI and non-GKI kernel support
  • ✅ Single configuration file (kadeflow.yaml)
  • ✅ GitHub Actions ready
  • ✅ External or in-tree driver integration
  • ✅ ABI upstream patching and ABI symbol export
  • ✅ Artifact export (modules, images, dist outputs)
  • ✅ Optional post-build commands (compile_commands, image unpack, etc.)

Recommended Repository Layout

.
├── code/                     # Driver source directory (external driver)
│   ├── Makefile
│   ├── mydriver.c
│   └── Kconfig               # optional
│
├── abi.symbols               # ABI symbols (optional, recommended)
├── kadeflow.yaml             # Main automation configuration
│
├── .github/
│   └── workflows/
│       └── kade.yml          # GitHub Actions workflow
│
├── README.md
└── README_zh.md

Driver Source Directory

When using an external driver, kade treats one directory in the repository as the driver source directory.

Recommended convention

code/

Configured via:

gki:
  driver:
    in_tree: false
    external_src_dir: "${GITHUB_WORKSPACE}/code"

Only this directory will be copied into the kernel source tree. Other repository files are ignored.

The directory name is not hardcoded. Any path may be used.


Providing ABI Symbols (Recommended)

ABI symbols should be version-controlled and reviewed like source code.

Recommended method: repository file

Create a file such as:

abi.symbols

Example:

# ABI symbols required by this driver
register_kprobe
unregister_kprobe
kallsyms_lookup_name

Reference it in kadeflow.yaml:

abi:
  upstream_patch: true
  symbols_file: "${GITHUB_WORKSPACE}/abi.symbols"

kade will automatically execute:

kade abi_upstream
kade abi --file abi.symbols

before building.


kadeflow.yaml (Main Configuration)

kadeflow.yaml is the single source of truth for CI and automation. All kade configuration is derived from this file.


GKI Configuration

kade:
  config_overrides:
    kernel:
      flavor: "gki"

    gki:
      android_version: 13
      kernel_version: "5.15"
      target_arch: "aarch64"

      driver:
        project_name: "mydriver"
        in_tree: false
        external_src_dir: "${GITHUB_WORKSPACE}/code"
        module_name: "mydriver.ko"
        overwrite: true

non-GKI Configuration

Enable non-GKI mode:

kernel:
  flavor: "non_gki"

Source configuration (non_gki.source)

Git repository

non_gki:
  source:
    type: "repo"
    repo_url: "https://github.com/vendor/kernel.git"
    branch: "main"

Local directory

non_gki:
  source:
    type: "local"
    local_path: "/absolute/path/to/kernel"

ZIP archive

non_gki:
  source:
    type: "zip"
    zip_path: "${GITHUB_WORKSPACE}/kernel.zip"
    zip_strip_root: true

Build configuration (non_gki.build)

Script mode (recommended)

non_gki:
  build:
    mode: "script"
    script: "build.sh"
    args: []
    artifacts_dir: "out"

Make mode (optional)

non_gki:
  build:
    mode: "make"
    make:
      defconfig: "vendor_defconfig"
      kernel_series: "4.9_plus"
      toolchain_path_prefix: "/root/toolchain/clang/bin:/root/toolchain/gcc32/bin:/root/toolchain/gcc64/bin"

non-GKI compile_commands

non-GKI kernels do not use Bazel.

kade runs:

python3 gen_compile_commands.py -d <out_dir>

Override the directory if needed:

compile_commands:
  non_gki_out_dir: "out/android13-5.15/common"

Default CI Flow

By default, the GitHub Action will:

  1. Install lyenv
  2. Create and activate a lyenv project
  3. Install the kade plugin
  4. Apply configuration from kadeflow.yaml
  5. Execute:
    • kade prepare
    • kade deps
    • kade sync
    • kade abi_upstream
    • kade abi (if symbols provided)
    • kade build
    • kade export
  6. Upload exported artifacts

After running:

eval "$(lyenv activate)"

all installed plugins (including kade) are available globally.


Environment Variable Expansion

All paths in kadeflow.yaml support environment variables such as:

  • ${GITHUB_WORKSPACE}
  • ${LYENV_HOME}

They are expanded automatically before kade runs.


License

Defined by the repository owner.


Related Projects


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published