Kernel-Foundry is a collection of containerized, standalone, and 100% reproducible Android kernel build environments.
The primary goal of this project is to decouple Android kernel development from the massive AOSP/LineageOS source trees (300GB+). By using Podman and lightweight container environments, Kernel-Foundry allows you to compile device-specific kernels in an isolated environment with only the necessary toolchains and sources.
Before getting started, ensure your host system has the following dependencies installed:
adb– To communicate with the target device and pull kernel/boot files.podman– To build and run containerized kernel environments.fzf– Required for the interactive device selection menu inrun.sh.- Flashing tool – At least one of
fastbootorheimdallmust be installed on the host.
| Device | Model | Code-name | Status |
|---|---|---|---|
| Motorola Edge 2021 | XT2141-2 | berlna | Stable |
| OnePlus 13 | CPH2655 | dodge | Stable |
| Samsung Galaxy Tab A7 | SM-T500 | gta4lwifi | Stable |
While each device has its own specific README.md inside its folder, the general workflow remains consistent:
- Automated Extraction & Environment Launch: Connect your target device via USB (with ADB and root/su enabled) and run the orchestration script from the repository root:
./run.shThis script automatically:
- Checks host dependencies (
adb,podman,fastboot/heimdall). - Opens an interactive menu (
fzf) to select your target device. - Downloads and extracts
magiskboot. - Pulls
/proc/config.gzand the active slot'sboot.imgdirectly from the connected device. - Organizes acquired files into
devices/<selected-device>/. - Builds or reuses the master
kernel-foundry-envPodman image. - Spawns an interactive shell inside the container, landing directly in
/workspace/<selected-device>.
- Setup & Build (Inside the Container): Once dropped into the container environment:
- Run
./setup_env.sh(once) to download device-specific toolchains and kernel sources. - Run
source restore_env.sh(every session) to set required compiler variables. - Modify your kernel configuration as needed and compile with
make.
run.sh accepts optional flags to manage your Podman container and image lifecycle:
| Command | Description |
|---|---|
./run.sh |
Default run. Reuses existing container state and attaches to it. |
./run.sh --replace container |
Force-deletes the target device's Podman container and spawns a fresh one. |
./run.sh --replace image |
Force-deletes the existing container and the master kernel-foundry-env image, rebuilding it from the root Containerfile. |
This project is designed to grow. If you have successfully decoupled a kernel from a vendor build system and verified it on physical hardware:
- Create a new directory under
devices/. - Provide a
setup_env.shscript to clone necessary repositories and toolchains. - Provide a
restore_env.shscript to set up host exports and toolchain PATHs. - Include any necessary
standalone_fixes.patchfiles required for the build to succeed outside of AOSP.
All kernel sources and toolchains are subject to their respective upstream licenses (GPLv2, Apache 2.0, etc.). The scripts and configuration files in this repository are provided "as-is" for the purpose of hardware experimentation and development.