Yocto Recipe for automatically loading Out of Tree Linux Device Drivers on Start
We can instruct Yocto to automatically start our own Linux Kernel Module on Start.
Steps:
1. Create a folder 'recipes-kernel' in your own custom meta layer if it doesn't exist
$ mkdir recipes-kernel
2. Inside 'recipes-kernel', create a folder 'my-module' for storing recipe and device driver files
$ cd recipes-kernel; mkdir my-module
3. Inside 'my-module', create 'files' folder and copy your device driver files
$ cd my-module; mkdir files
4. Copy this Makefile in the 'files' directory
5. Come back to the parent folder (i.e., my-module) and create a recipe for building the module
$ cd .. ; touch my-module_0.1.bb
You should have the following tree after this step.
6. Add this module into your configuration file (local.conf file or machine.conf)
MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-mymod"
KERNEL_MODULE_AUTOLOAD += "mymod"
Steps:
1. Create a folder 'recipes-kernel' in your own custom meta layer if it doesn't exist
$ mkdir recipes-kernel
2. Inside 'recipes-kernel', create a folder 'my-module' for storing recipe and device driver files
$ cd recipes-kernel; mkdir my-module
3. Inside 'my-module', create 'files' folder and copy your device driver files
$ cd my-module; mkdir files
4. Copy this Makefile in the 'files' directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj-m := mymod.o | |
SRC := $(shell pwd) | |
all: | |
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) | |
modules_install: | |
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install | |
clean: | |
rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c | |
rm -f Module.markers Module.symvers modules.order | |
rm -rf .tmp_versions Modules.symvers |
$ cd .. ; touch my-module_0.1.bb
You should have the following tree after this step.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SUMMARY = "My Module" | |
LICENSE = "GPLv2" | |
inherit module | |
SRC_URI = "file://Makefile \ | |
file://mymod.c \ | |
" | |
S = "${WORKDIR}" | |
# The inherit of module.bbclass will automatically name module packages with | |
# "kernel-module-" prefix as required by the oe-core build environment. | |
RPROVIDES_${PN} += "kernel-module-mymod" |
MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-mymod"
KERNEL_MODULE_AUTOLOAD += "mymod"
MACHINE_ESSENTIAL_EXTRA_RDEPENDS tells yocto to build this module and include it in the build image
KERNEL_MODULE_AUTOLOAD is to load the module automatically on start
Comments
Post a Comment