Build droidian instructions
Build it according to droidian instructions
old guide: https://github.com/droidian/porting-guide/blob/88135e5a0eb8444d9cae5a4ea7713d7b998298fb/image-creation.md https://github.com/droidian/porting-guide/blob/master/kernel-compilation.md
--- docker mine custom
mkdir droidian-instructions && cd droidian-instructions/
mkdir -p /work/droidian-instructions/kernel/vendor/device
mkdir -p /work/droidian-instructions/packages
cd /work/droidian-instructions/kernel/vendor/device
git clone --depth=1 -b lineage-22.2 https://github.com/LineageOS/android_kernel_oneplus_sdm845
ls -la android_kernel_oneplus_sdm845/arch/arm64/configs/enchilada_defconfig
--- host
KERNEL_DIR="$HOME/enchilada/droidian-instructions/kernel/vendor/device"
PACKAGES_DIR="$HOME/enchilada/droidian-instructions/packages"
podman run --rm -v $PACKAGES_DIR:/buildd -v $KERNEL_DIR:/buildd/sources -it quay.io/droidian/build-essential:current-amd64 bash
--- droidian/build-essential container
apt update && apt install -y linux-packaging-snippets
cd /buildd/sources
mkdir -p debian/source
cp -v /usr/share/linux-packaging-snippets/kernel-info.mk.example debian/kernel-info.mk
echo 13 > debian/compat
echo "3.0 (native)" > debian/source/format
cat > debian/rules <<EOF
#!/usr/bin/make -f
include /usr/share/linux-packaging-snippets/kernel-snippet.mk
%:
dh \$@
EOF
chmod +x debian/rules
find a boot.img for enchilada... extract
unpack_bootimg --boot_img boot.emmc.winfrom a twrp backup of original android 9root@d535add90a22:/buildd/sources/extract-boot-img# unpack_bootimg --boot_img boot.emmc.win boot magic: ANDROID! kernel_size: 12931878 kernel load address: 0x00008000 ramdisk size: 15893077 ramdisk load address: 0x01000000 second bootloader size: 0 second bootloader load address: 0x00f00000 kernel tags load address: 0x00000100 page size: 4096 os version: 9.0.0 os patch level: 2019-08 boot image header version: 1 product name: command line args: androidboot.hardware=qcom androidboot.console=ttyMSM0 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 swiotlb=2048 androidboot.configfs=true androidboot.usbcontroller=a600000.dwc3 firmware_class.path=/vendor/firmware_mnt/image loop.max_part=7 buildvariant=user additional command line args: recovery dtbo size: 0 recovery dtbo offset: 0x0000000000000000 boot header size: 1648copy and mod the entries from kernel-info.mk as https://github.com/droidian/porting-guide/blob/master/kernel-compilation.md#kernel-infomk-entries
Edit the kernel-info.mk
cat /buildd/sources/debian/kernel-info.mk
---
########################################################################
# Kernel settings
########################################################################
# Kernel variant. This is currently used only on the Source package name.
# Use 'android' for Android kernels ("downstream") or 'mainline' for upstream
# kernels.
VARIANT = android
# Kernel base version
## awk '/^VERSION =/ {v=$3} /^PATCHLEVEL =/ {p=$3} /^SUBLEVEL =/ {s=$3} END {print v"."p"."s}' android_kernel_oneplus_sdm845/Makefile
KERNEL_BASE_VERSION = 4.9.337
# The kernel cmdline to use
KERNEL_BOOTIMAGE_CMDLINE = put-cmdline-here
# Slug for the device vendor. This is going to be used in the KERNELRELASE
# and package names.
DEVICE_VENDOR = oneplus
# Slug for the device model. Like above.
DEVICE_MODEL = enchilada
# Slug for the device platform. If unsure, keep this commented.
# DEVICE_PLATFORM = platform
# Marketing-friendly full-name. This will be used inside package descriptions
DEVICE_FULL_NAME = OnePlus 6
# Whether to use configuration fragments to augment the kernel configuration.
# If unsure, keep this to 0.
KERNEL_CONFIG_USE_FRAGMENTS = 0
# Enable kernel config device extra fragments
# KERNEL_CONFIG_EXTRA_FRAGMENTS = container.config debug.config other.config
# Whether to use diffconfig to generate the device-specific configuration.
# If you enable this, you should set KERNEL_CONFIG_USE_FRAGMENTS to 1.
# If unsure, keep this to 0.
KERNEL_CONFIG_USE_DIFFCONFIG = 0
# The diffconfig to apply. Only used when KERNEL_CONFIG_USE_DIFFCONFIG is
# enabled.
# KERNEL_PRODUCT_DIFFCONFIG = my_diffconfig
# Defconfig to use
KERNEL_DEFCONFIG = enchilada_defconfig
# Whether to include DTBs with the image. Use 0 (no) or 1.
# GKI devices should set this to 0
KERNEL_IMAGE_WITH_DTB = 0
# Path to the DTB
# If you leave this undefined, an attempt to find it automatically
# will be made.
# KERNEL_IMAGE_DTB = arch/arm64/boot/dts/qcom/my_dtb.dtb
KERNEL_IMAGE_DTB =
# Whether to include a DTB Overlay. Use 0 (no) or 1.
# GKI devices should set this to 0
KERNEL_IMAGE_WITH_DTB_OVERLAY = 1
# Path to the DTB overlay.
# If you leave this undefined, an attempt to find it automatically
# will be made.
KERNEL_IMAGE_DTB_OVERLAY = arch/arm64/boot/dts/qcom/enchilada-mp-v2.1-overlay.dtbo
# Whether to include the DTB Overlay into the kernel image
# Use 0 (no, default) or 1.
# dtbo.img will always be shipped in the linux-bootimage- package.
# GKI devices should set this to 0
KERNEL_IMAGE_WITH_DTB_OVERLAY_IN_KERNEL = 0
# Path to a specifc configuration file for mkdtboimg.
# The default is to leave it undefined.
# KERNEL_IMAGE_DTB_OVERLAY_CONFIGURATION = debian/custom_dtbo_config.cfg
# Path to the DTB directory. Only define if KERNEL_IMAGE_DTB_OVERLAY_CONFIGURATION
# is defined too.
# KERNEL_IMAGE_DTB_OVERLAY_DTB_DIRECTORY = arch/arm64/boot/dts/qcom
# Path to the prebuilt DT image. should only be defined on header version 1 and below.
# mostly used on samsung devices. default is to leave it undefined
# KERNEL_PREBUILT_DT = debian/dt.img
# Various other settings that will be passed straight to mkbootimg
# GKI devices can leave BASE_OFFSET, KERNEL_OFFSET, INITRAMFS_OFFSET, SECOND_OFFSET and TAGS_OFFSET empty
KERNEL_BOOTIMAGE_PAGE_SIZE = 4096
KERNEL_BOOTIMAGE_BASE_OFFSET = 0x00000000
KERNEL_BOOTIMAGE_KERNEL_OFFSET = 0x00008000
KERNEL_BOOTIMAGE_INITRAMFS_OFFSET = 0x01000000
KERNEL_BOOTIMAGE_SECONDIMAGE_OFFSET = 0x00f00000
KERNEL_BOOTIMAGE_TAGS_OFFSET = 0x00000100
# Specify boot image security patch level if needed
# KERNEL_BOOTIMAGE_PATCH_LEVEL = 2022-04-05
# Specify boot image OS version if needed
# KERNEL_BOOTIMAGE_OS_VERSION = 12.0.0
# Required for header version 2, ignore otherwise
# GKI devices should leave this offset empty
# KERNEL_BOOTIMAGE_DTB_OFFSET = 0x1f00000
KERNEL_BOOTIMAGE_DTB_OFFSET =
# Kernel bootimage version. Defaults to 0 (legacy header).
# As a rule of thumb:
# Devices launched with Android 8 and lower: version 0
# Devices launched with Android 9: version 1
# Devices launched with Android 10: version 2
# Devices launched with Android 11: version 2 or 3 (GKI)
# Devices launched with Android 12: version 3 (GKI) or 4 (GKI)
# Devices launched with Android 13: version 3 (GKI) or 4 (GKI)
KERNEL_BOOTIMAGE_VERSION = 1
# Kernel initramfs compression. Defaults to gzip.
# All non-gki devices need a gzip (gz) initramfs
# For devices launched with a GKI kernel it can be either gzip (gz) or lz4 (lz4)
KERNEL_INITRAMFS_COMPRESSION = gz
# Whether to generate a vendor_boot image. Supported since
# bootimage version 3.
# vendor_boot images will contain the required kernel modules that
# are to be loaded during the initramfs stage.
# If building for a device with bootimage version >= 3, you
# should probably want to enable it.
#
# Module list should be added in KERNEL_DIR/droidian/modules.load.
KERNEL_BOOTIMAGE_GENERATE_VENDOR_BOOT = 0
# The cmdline for the vendor_boot image
KERNEL_BOOTIMAGE_VENDOR_CMDLINE = "androidboot.hardware=qcom androidboot.console=ttyMSM0 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 swiotlb=2048 androidboot.configfs=true androidboot.usbcontroller=a600000.dwc3 firmware_class.path=/vendor/firmware_mnt/image loop.max_part=7 buildvariant=user"
########################################################################
# Android verified boot
########################################################################
# Whether to build a flashable vbmeta.img. Please note that currently
# only empty vbmeta images (disabling verified boot) can be generated.
# Use 0 (no) or 1 (default).
DEVICE_VBMETA_REQUIRED = 1
# Samsung devices require a special flag. Enable the following if your
# device is a Samsung device that requires flag 0 to be present
# Use 0 (no, default) or 1.
DEVICE_VBMETA_IS_SAMSUNG = 0
# boot partition size. If specified, an AVB footer will be added at the
# end of the bootimage.
KERNEL_BOOTIMAGE_PARTITION_SIZE =
########################################################################
# Automatic flashing on package upgrades
########################################################################
# Whether to enable kernel upgrades on package upgrades. Use 0 (no) or 1.
FLASH_ENABLED = 1
# If your device is treble-ized, but aonly, you should set the following to
# 1 (yes).
FLASH_IS_AONLY = 0
# `flash-bootimage` defaults are enough for most recent devices, but legacy
# devices won't work out of the box.
# If you set the following to 1, this package will set `flash-bootimage`'s
# DEVICE_IS_AB and BOOTIMAGE_SLOT_A accordingly, thus enabling flashing
# on older devices.
#
# Do not enable if you don't know what you're doing
FLASH_IS_LEGACY_DEVICE = 0
# On some exynos devices partition names are capitalized (boot is BOOT and so on)
# This flag makes the kernel to get flashed to the correct partition on updates.
FLASH_IS_EXYNOS = 0
# On some devices flashing userdata.img via fastboot fails and telnet should
# be used instead. Set to 1 for telnet and 0 for fastboot
FLASH_USE_TELNET = 0
# Device manufacturer. This must match the `ro.product.vendor.manufacturer`
# Android property. If you don't want to specify this, leave it undefined,
# FLASH_INFO_CPU will be checked instead.
FLASH_INFO_MANUFACTURER = OnePlus
# Device model. This must match the `ro.product.vendor.model`
# Android property. If you don't want to specify this, leave it undefined,
# FLASH_INFO_CPU will be checked instead.
FLASH_INFO_MODEL = enchilada
# Device CPU. This will be grepped against /proc/cpuinfo to check if
# we're running on the specific device. Note this is a last-resort
# method, specifying FLASH_INFO_MANUFACTURER and FLASH_INFO_MODEL is
# recommended.
# FLASH_INFO_CPU = My Fictional System-on-a-Chip
# Space-separated list of supported device ids as reported by fastboot
# FLASH_INFO_DEVICE_IDS = model1 model2
########################################################################
# Kernel build settings
########################################################################
# Whether to cross-build. Use 0 (no) or 1.
BUILD_CROSS = 1
# (Cross-build only) The build triplet to use. You'll probably want to
# use aarch64-linux-android- if building Android kernels.
# might need to use aarch64-linux-gnu- with newer kernels such as GKI
BUILD_TRIPLET = aarch64-linux-android-
# (Cross-build only) The build triplet to use with clang. You'll probably
# want to use aarch64-linux-gnu- here.
BUILD_CLANG_TRIPLET = aarch64-linux-gnu-
# The compiler to use. Recent Android kernels are built with clang.
BUILD_CC = clang
# Use llvm instead of gcc. Recent Android kernels (past android 12) need llvm.
BUILD_LLVM = 0
# Set to 1 to skip modules packaging if CONFIG_MODULES is disabled in defconfig
BUILD_SKIP_MODULES = 0
# Set clang version
CLANG_VERSION = 6.0-4691093
# Set to 1 to use a manually installed toolchain
# Remember to update the path in BUILD_PATH
CLANG_CUSTOM = 0
# Extra paths to prepend to the PATH variable. You'll probably want
# to specify the clang path here (the default).
BUILD_PATH = /usr/lib/llvm-android-$(CLANG_VERSION)/bin
# Extra packages to add to the Build-Depends section. Mainline builds
# can have this section empty, unless cross-building.
# The default is enough to install the Android toolchain, including clang.
DEB_TOOLCHAIN = linux-initramfs-halium-generic:arm64, binutils-aarch64-linux-gnu, gcc-4.9-aarch64-linux-android, g++-4.9-aarch64-linux-android, libgcc-4.9-dev-aarch64-linux-android-cross
# Where we're building on
DEB_BUILD_ON = amd64
# Where we're going to run this kernel on
DEB_BUILD_FOR = arm64
# Target kernel architecture
KERNEL_ARCH = arm64
# Kernel target to build
KERNEL_BUILD_TARGET = Image
export KERNEL_DIR="/buildd/sources/android_kernel_oneplus_sdm845"
export PACKAGES_DIR="/buildd"
rm -f debian/control
debian/rules debian/control
cd /buildd/sources
# add origin pointing to upstream (change URL if you prefer Lineage)
git remote add origin https://github.com/OnePlusOSS/android_kernel_oneplus_sdm845.git
# fetch remote refs (fast)
git fetch --all --prune
# ensure you are on the packaging branch (create if needed)
git checkout -b debian-packaging || git checkout debian-packaging
# run the releng builder again
RELENG_HOST_ARCH="arm64" releng-build-package
cat > .gitmodules <<'EOF'
[submodule "android_kernel_oneplus_sdm845"]
path = android_kernel_oneplus_sdm845
url = https://github.com/OnePlusOSS/android_kernel_oneplus_sdm845.git
EOF
git submodule sync --recursive
git submodule update --init --recursive
git add .gitmodules
git commit -m "Fix .gitmodules: add url for android_kernel_oneplus_sdm845"
RELENG_HOST_ARCH="arm64" releng-build-package
I had the things in the wrong path.
root@d535add90a22:/buildd/sources# export KERNEL_DIR="/buildd/sources/android_kernel_oneplus_sdm845"
root@d535add90a22:/buildd/sources# cd android_kernel_oneplus_sdm845/
root@d535add90a22:/buildd/sources/android_kernel_oneplus_sdm845# mv ../debian .
root@d535add90a22:/buildd/sources/android_kernel_oneplus_sdm845# mv ../.gitmodules .
RELENG_HOST_ARCH="arm64" releng-build-package
...
seems to work. i think.
kernel compiled
-rw-r--r-- 1 root root 240K Sep 23 18:22 linux-android-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.build
-rw-r--r-- 1 root root 8.9K Sep 23 18:22 linux-android-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.buildinfo
-rw-r--r-- 1 root root 4.4K Sep 23 18:22 linux-android-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.changes
-rw-r--r-- 1 root root 50M Sep 23 18:22 linux-bootimage-4.9.337-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.deb
-rw-r--r-- 1 root root 1.4K Sep 23 18:21 linux-bootimage-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.deb
-rw-r--r-- 1 root root 7.9M Sep 23 18:21 linux-headers-4.9.337-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.deb
-rw-r--r-- 1 root root 1.4K Sep 23 18:21 linux-headers-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.deb
-rw-r--r-- 1 root root 10M Sep 23 18:21 linux-image-4.9.337-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.deb
-rw-r--r-- 1 root root 1.4K Sep 23 18:21 linux-image-oneplus-enchilada_0.0.0+git20250711132731.eabce74.lineage.22.2_arm64.deb
root@d535add90a22:/buildd/sources# ls -lah android_kernel_oneplus_sdm845/out/KERNEL_OBJ/*.img
-rw-r--r-- 1 root root 54M Sep 23 18:20 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/boot-default.img
-rw-r--r-- 1 root root 54M Sep 23 18:21 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/boot-recovery-default.img
-rw-r--r-- 1 root root 54M Sep 23 18:20 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/boot.img
-rw-r--r-- 1 root root 211K Sep 23 18:21 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/dtbo.img
-rw-r--r-- 1 root root 54M Sep 23 18:21 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/recovery.img
-rw-r--r-- 1 root root 4.0K Sep 23 18:21 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/vbmeta.img
-rw-r--r-- 1 root root 0 Sep 23 18:21 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/vendor_boot-default.img
-rw-r--r-- 1 root root 0 Sep 23 18:21 android_kernel_oneplus_sdm845/out/KERNEL_OBJ/vendor_boot.img
can I boot this image? currently it has android. fastboot boot ~/enchilada/droidian-instructions/kernel/vendor/device/android_kernel_oneplus_sdm845/out/KERNEL_OBJ/boot.img nope fastboot boot ~/enchilada/droidian-instructions/kernel/vendor/device/android_kernel_oneplus_sdm845/out/KERNEL_OBJ/recovery.img no. oh well... fastboot boot ~/enchilada/halium-9/out/target/product/enchilada/halium-boot.img same cd ~/enchilada/droidian-instructions/kernel/vendor/device/extract-boot-img/out fastboot boot kernel ramdisk nope cd ~/enchilada/droidian-instructions/kernel/vendor/device/extract-boot-img fastboot boot boot.emmc.win it boots android. so maybe this may only work with the right img file and the one I built only works with linux.
rootfs
https://github.com/droidian/porting-guide/blob/master/rootfs-creation.md
Host
cd ~/enchilada/droidian-instructions podman run --rm -v $PACKAGES_DIR:/buildd -v $KERNEL_DIR:/buildd/sources -it quay.io/droidian/build-essential:current-amd64 bash cd /buildd/sources git clone https://github.com/droidian-releng/droidian-build-tools/ && cd droidian-build-tools/bin ./droidian-new-device -v oneplus -n enchilada -c arm64 -a 28 -r phone -d droidianTest container
Host
Container