0

I am trying to build a hello world kernel module using a Yocto recipe, following the setup provided in https://git.yoctoproject.org/poky/tree/meta-skeleton/recipes-kernel/hello-mod. The recipe works fine when the files are in the default directory structure, as follows:

recipes
└── hello-mod
    ├── files
    │   ├── COPYING
    │   ├── hello.c
    │   └── Makefile
    └── hello-mod_0.1.bb

Contents of hello-mod_0.1.bb:

SUMMARY = "Example of how to build an external Linux kernel module"
DESCRIPTION = "${SUMMARY}"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"

inherit module

SRC_URI = "file://Makefile \
           file://hello.c \
           file://COPYING \
          "

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-hello"

I moved the kernel module into a different directory to separate the recipes and the source code.Here is the updated structure.

demo_project
├── recipes
│   └── hello-mod
│       └── hello-mod_0.1.bb
└── source
    ├── COPYING
    ├── hello.c
    └── Makefile

I updated the recipe's .bb-file as

SUMMARY = "Example of how to build an external Linux kernel module"
DESCRIPTION = "${SUMMARY}"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${THISDIR}/../../source/COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"

inherit module

SRC_URI = "file://${THISDIR}/../../source/Makefile \
           file://${THISDIR}/../../source/hello.c \
           file://${THISDIR}/../../source/COPYING \
          "

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-hello"

Now I am getting the error as:

| DEBUG: Executing shell function do_compile
| NOTE: make -j 16 KERNEL_SRC=/home/dfg1/Demo/build/tmp/work-shared/qemux86/kernel-source 
                   KERNEL_PATH=/home/dfg1/Demo/build/tmp/work-shared/qemux86/kernel-source 
                   KERNEL_VERSION=5.4.219-yocto-standard 
                   CC=i686-poky-linux-gcc  
                   -fuse-ld=bfd 
                   -fmacro-prefix-map=/home/dfg1/Demo/build/tmp/work/qemux86-poky-linux/hello-mod/0.1-r0=/usr/src/debug/hello-mod/0.1-r0                      -fdebug-prefix-map=/home/dfg1/Demo/build/tmp/work/qemux86-poky-linux/hello-mod/0.1-r0=/usr/src/debug/hello-mod/0.1-r0                      -fdebug-prefix-map=/home/dfg1/Demo/build/tmp/work/qemux86-poky-linux/hello-mod/0.1-r0/recipe-sysroot=                      -fdebug-prefix-map=/home/dfg1/Demo/build/tmp/work/qemux86-poky-linux/hello-mod/0.1-r0/recipe-sysroot-native=  -fdebug-prefix-map=/home/dfg1/Demo/build/tmp/work-shared/qemux86/kernel-source=/usr/src/kernel -fdebug-prefix-map=/home/dfg1/Demo/build/tmp/work-shared/qemux86/kernel-build-artifacts=/usr/src/kernel LD=i686-poky-linux-ld.bfd  AR=i686-poky-linux-ar  O=/home/dfg1/Demo/build/tmp/work-shared/qemux86/kernel-build-artifacts KBUILD_EXTRA_SYMBOLS=
| make: *** No targets specified and no makefile found.  Stop.
| ERROR: oe_runmake failed

I am not sure why it is not working. If I move it outside, it works if I keep it in the same directory as hello-mod_0.1.bb.Any suggestions would be greatly appreciated. Thank you!

Mo_
  • 13
  • 4
goodman
  • 424
  • 8
  • 24

1 Answers1

0

The S variable is the "location in the Build Directory where unpacked recipe source code resides". You have to modify S to point to the directory of the Makefile.

You did not state your reasons, to remove the files from hello-mod/files. Notice, however, the Yocto docs say about SRC_URI files:

The directories are assumed to be subdirectories of the directory in which the recipe or append file resides.

It will save you a lot of pain, if you go a more standard way:

  • Pull code from a (git) repository, howto.
  • Still, the repo pulled from can be repo on your machine.
  • This SO post shows how exactly to include it in your recipe. In short:
SRC_URI = "git:///home/user/git/myTest/;protocol=file"
Mo_
  • 13
  • 4