Yocto – adding out of tree kernel module

Solution for Yocto – adding out of tree kernel module
is Given Below:

I would like to add a wifi out-of-tree kernel module to my Yocto project. I found a layer on Open Embedded Layer Index with the driver that I need (https://layers.openembedded.org/layerindex/branch/master/layer/meta-rtlwifi/). I cannot build an image because I get the following error from bitbake:

install: cannot stat
‘build/tmp/work/<machine_dir>/rtl8821cu/’: No
such file or directory WARNING: exit code 1 from a shell command.

This file should be created by Makefile, but I have no errors generating by make.
The recipe for the driver is as follows:

SUMMARY = "RTL8821CU kernel driver (wifi)"
DESCRIPTION = "RTL8821CU kernel driver"
LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"

SRCREV = "2dace83e5f4cada52bbe3930b864c3eb82390b1f"
SRC_URI = "git://github.com/spriteguard/rtl8821CU;protocol=https "

S = "${WORKDIR}/git"

PV = ""

DEPENDS = "virtual/kernel"

inherit module

#This is the only line added by me to this recipe because sh wasn't able to find `bc`
EXTRA_OEMAKE += "-I${S}/usr/bin' " 


do_install () {
    install -d ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless
    install -m 0644 ${B}/8821cu.ko ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/rtl8821cu.ko

FILES_${PN} += "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/rtl8821cu.ko"
RPROVIDES_${PN} += "kernel-module-${PN}-${KERNEL_VERSION}"

I have tried to add the following task:

do_compile () {

But it changed nothing. I needed to add one line to this recipe: EXTRA_OEMAKE += "-I${S}/usr/bin' " because sh wasn’t able to find bc. Maybe bitbake doesn’t see one more file/library?

When I cloned the repo on my PC and just run make, the file *.ko was created. What can cause problems in Yocto with creating this module? I use the official layer and recipe so I suppose it should works.