Kernel Building
Build Linux kernels for ARM64, ARM, and RISC-V on macOS.
Prerequisites
Section titled “Prerequisites”- Workspace initialized:
elmos init - Dependencies checked:
elmos doctor
Build Workflow
Section titled “Build Workflow”1. Set Architecture
Section titled “1. Set Architecture”elmos arch arm64 # or: arm, riscvelmos arch # Show current2. Configure Kernel
Section titled “2. Configure Kernel”# Default config for architectureelmos kernel config defconfig
# Interactive menuelmos kernel config menuconfig
# Minimal configelmos kernel config tinyconfigValid config types:
| Type | Description |
|---|---|
defconfig |
Architecture default |
tinyconfig |
Minimal kernel |
menuconfig |
Interactive menu |
kvm_guest.config |
KVM optimized |
oldconfig |
Update existing |
olddefconfig |
Update with defaults |
3. Build
Section titled “3. Build”# Default targets (Image, dtbs, modules)elmos kernel build
# Specific targetselmos kernel build Imageelmos kernel build vmlinux
# Custom parallelismelmos kernel build -j 8Valid build targets:
| Target | Description |
|---|---|
Image |
Kernel image (arm64, riscv) |
zImage |
Compressed image (arm) |
dtbs |
Device tree blobs |
modules |
Kernel modules |
vmlinux |
Uncompressed kernel (for GDB) |
4. Verify Build
Section titled “4. Verify Build”elmos statusOutput:
Workspace Status: Volume: /Volumes/elmos (mounted) Kernel: ✓ Configured, ✓ Built Architecture: arm64 Image: /Volumes/elmos/linux/arch/arm64/boot/ImageBuildOptions Reference
Section titled “BuildOptions Reference”type BuildOptions struct { Jobs int // Parallel jobs (-j) Targets []string // Build targets}Environment Variables
Section titled “Environment Variables”ELMOS automatically sets:
| Variable | Value |
|---|---|
ARCH |
Target architecture |
LLVM |
1 (use LLVM toolchain) |
CROSS_COMPILE |
Toolchain prefix |
HOSTCFLAGS |
macOS compatibility flags |
PATH |
Prepends LLVM, GNU tools |
Clean Build
Section titled “Clean Build”elmos kernel clean # make distcleanPatches
Section titled “Patches”Apply macOS compatibility patches:
# List availableelmos patch list
# Applyelmos patch apply v6.18/generic/fix-copy-rangeTroubleshooting
Section titled “Troubleshooting”| Issue | Solution |
|---|---|
| “No toolchain” | Run elmos doctor |
| Config errors | Run elmos kernel clean then reconfigure |
| Build hangs | Check disk space, reduce -j |
| Missing headers | Run elmos doctor --fix |