While it is always preferable to build a module driver from source and install it into the Yocto image, in somecases you may need a kernel module driver to be installed from pre-built .ko module. This is needed when you want build your proprietary images without releasing your source code. Below is the template recipe for installing a pre-built module into the Yocto kernel Image.

Sample recipe file

DESCRIPTION = "Install any module driver from pre-built .ko files"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

inherit linux-kernel-base

# We need the kernel to be staged (unpacked, patched and configured) before
# we can grab the source and make the kernel-devsrc package
do_install[depends] += "virtual/kernel:do_populate_sysroot"


KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}"

SRC_URI = " \
    file://sample_module_driver.ko \

S = "${WORKDIR}"

	echo compiling

do_install() {

    install -d $MODULE_DIR
    install -m 755 ${S}/sample_module_driver.ko $MODULE_DIR

FILES_${PN} += "\
/lib \
/lib/modules/${KERNEL_VERSION}kernel/drivers/input/sample_module_driver.ko \

KERNEL_MODULE_AUTOLOAD = "sample_module_driver"

In the above recipe file, in order to get the KERNEL_VERSION which contains the path of module driver path(For example, 4.1.15-1.0.0+g0e2316f), “linux-kernel-base” class has to be inherited. To get started, copy this recipe to your layer and give it an appropriate name based on your implementation. In the same directory, create a directory named files where you need to copy your pre-built module. In this example it is sample_module_driver.ko.