Search code examples
linuxlinux-device-driveryoctokernel-modulebitbake

Yocto - adding out of tree kernel module


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/5.8.1.2-git-r0/git/8821cu.ko': 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"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"

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

S = "${WORKDIR}/git"

PV = "5.8.1.2-git"

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' " 
EXTRA_OEMAKE += "ARCH=${ARCH}"
EXTRA_OEMAKE += "KSRC=${STAGING_KERNEL_BUILDDIR}"

MODULES_INSTALL_TARGET="install"

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 () {
    oe_runmake
}

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.


Solution

  • You have to replace SRCREV. Because as far as I can see, the SRCREV of the above recipe is using the old version. You can check "git log" and choose the latest commit. I used master branch and bitbake successfully.