Vendor and ODM DLKM partitions

Android 11 introduces the concept of the Generic Kernel Image and the vendor boot partition. The vendor boot partition stores kernel modules compatible with GKI, and is loaded by first stage init. Kernel Modules prior to Android 11's release are also stored in vendor and ODM partitions, and are loaded by vendor processes.

For Android 11 or higher, the kernel and all kernel modules can be updated independently from the rest of the partitions. To enable updates for kernel modules stored in the vendor partition (without a vendor partition update), move all vendor partition modules to a new partition called Vendor DLKM (dynamically loadable kernel module). You can then update this partition independently. Similarly, you can move all kernel modules stored in the ODM partition to a new partition called ODM DLKM. This partition can be updated independently as well.

Partition location

vendor_dlkm and odm_dlkm partitions are located in the super partition as another dynamic partition.

vendor_dlkm contents in /vendor/lib/modules

  • Vendor kernel modules
  • modprobe config files
  • A modules.load file

odm_dlkm contents in /odm/lib/modules

  • ODM kernel modules
  • modprobe config files
  • A modules.load file

See Kernel Module Support for further details on kernel module config files.

Build support

Building vendor_dlkm and odm_dlkm is a similar process to building other dynamic partitions.

vendor_dlkm build example

Build vendor_dlkm as shown in the following examples.

BoardConfig.mk

BOARD_USES_VENDOR_DLKMIMAGE := true
BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_COPY_OUT_VENDOR_DLKM := vendor_dlkm
BOARD_<GROUP_NAME>_PARTITION_LIST += vendor_dlkm

Replace <GROUP_NAME> with the appropriate name of the update group. The update group should be the group that the vendor partition is in.

For A/B and Virtual A/B devices, device.mk

AB_OTA_PARTITIONS += vendor_dlkm

fstab

Add the following entry for vendor_dlkm to fstab. Change flags according to the device. Use the CL Add vendor_dlkm to CF as an example.

vendor_dlkm /vendor_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb

odm_dlkm build example

Build odm_dlkm as shown in the following examples.

BoardConfig.mk

BOARD_USES_ODM_DLKIMAGE := true
BOARD_ODM_DLKIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_COPY_OUT_ODM_DLKM := odm_dlkm
BOARD_<group_name>_PARTITION_LIST += odm_dlkm

For A/B and Virtual A/B devices, device.mk

AB_OTA_PARTITIONS += odm_dlkm

fstab

Add the following entry for odm_dlkm to fstab. Change flags according to the device. Use the CL Add odm_dlkm to CF as an example.

odm_dlkm /odm_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb

Copy kernel modules into a partition

To select the kernel modules you want to copy into the vendor_dlkm partition, list them in BOARD_VENDOR_KERNEL_MODULES.

If you want to override the contents of modules.load, you can specify it in BOARD_VENDOR_KERNEL_MODULES_LOAD.

At build time, modules listed in BOARD_VENDOR_KERNEL_MODULES are installed in $ANDROID_PRODUCT_OUT/vendor_dlkm/lib/modules. A symbolic link is created at /vendor/lib/modules that leads to /vendor_dlkm/lib/modules.

Similarly, to select the kernel modules you want to copy into the odm_dlkm partition, list them in BOARD_ODM_KERNEL_MODULES. The platform build runs depmod on the modules and copies the depmod output files into the image. The build creates a modules.load file and stores it in the image. This file contains all of the modules listed in BOARD_ODM_KERNEL_MODULES.

If you want to override the contents of modules.load, you can specify it in BOARD_ODM_KERNEL_MODULES_LOAD.

At build time, modules listed in BOARD_ODM_KERNEL_MODULES is installed in $ANDROID_PRODUCT_OUT/odm_dlkm/lib/modules. A symbolic link is created at /odm/lib/modules that leads to /odm_dlkm/lib/modules.

Always use /vendor/lib/modules and /odm/lib/modules for vendor and ODM kernel modules.

Never use /vendor_dlkm/lib/modules. Devices without a vendor_dlkm partition install BOARD_VENDOR_KERNEL_MODULES to /vendor/lib/modules directly. This is problematic as /vendor_dlkm/lib/modules doesn't exist.

Never use /odm_dlkm/lib/modules. Devices without an odm_dlkm partition install BOARD_ODM_KERNEL_MODULES to /odm/lib/modules directly. This is problematic as /odm_dlkm/lib/modules doesn't exist.

Partition mounting and module loading

During first_stage_init, the vendor_dlkm and odm_dlkm partitions are mounted in the /vendor_dlkm and /odm_dlkm directories, respectively. When this happens, symlinks at /vendor/lib/modules and /odm/lib/modules become available.

A vendor process (like an .rc script) can then load the kernel modules based on the order specified in modules.load. The vendor process can also load the modules at a later time, if necessary.

For documentation regarding the creation of a vendor-boot partition (which contains the vendor RAMDisk), refer to Kernel Module Support.