Last edited 4 years ago

How to add a customer application

Template:ArticleMainWriter Template:ArticleApprovedVersion


1. Article purpose[edit source]

The main purpose of this article is to give main steps on how to add a customer application inside the Yocto build process (with the Distribution Package)

2. Pre-requesite[edit source]

You are already familiar with the Yocto build process and the OpenSTLinux distribution.

You have already created a customer layer (How to create a new open embedded layer) to update, for your own needs, the OpenSTLinux distribution.

You have already created in your environment either an external out of tree kernel module, or an "hello world" user space example.

3. Adding a customer application (integrated in a customer layer)[edit source]

Once mymodule or myhelloworld recipes have been created with devtool commands, to add it in the Yocto build process, some additional commands below must be used.
They concern the external out-of-tree Linux kernel module (mymodule).
Similar commands shall be executed for the "hello world" user space example (myhelloworld).

  • Copy the new recipe inside the customer layer
Template:PC$ mkdir ../meta-my-custo-layer/recipes-custom/mymodule
Template:PC$ cp workspace/recipes/mymodule/mymodule.bb ../meta-my-custo-layer/recipes-custom/mymodule
  • Copy the source code files, the Makefile inside the customer layer
Template:PC$ mkdir ../meta-my-custo-layer/recipes-custom/mymodule/mymodule
Template:PC$ cp kernel_module_example/Makefile ../meta-my-custo-layer/recipes-custom/mymodule/mymodule
Template:PC$ cp kernel_module_example/kernel_module_example.c ../meta-my-custo-layer/recipes-custom/mymodule/mymodule
Template:PC$ devtool reset mymodule
  • Some fields of new recipes must be also completed, at least LICENSE, LIC_FILES_CHKSUM, and SRC_URI

Template:Warning

# NOTE: LICENSE is set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (in most cases, it
# is not) you must specify the correct value, before using this
# recipe for anything other than the initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""

# No information for SRC_URI yet (only an external source tree is specified)
SRC_URI = ""

For instance for Linux kernel module:

LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"

SRC_URI = "file://Makefile \
           file://kernel_module_example.c \
          "

or for user space application:

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

SRC_URI = "file://hello_world_example.c \
          "

To check that your updates of new recipe have not broken the compilation, compile it with the bitbake command:

Template:PC$ bitbake mymodule
  • For a quick check you can add this new recipe (mymodule.bb) inside st-image-weston, recompile this image, flash/boot the board and check the module is well functionnal
Template:PC$ cd .../meta-st-openstlinux/recipes-st/images/

Open st-image-weston.bb and add this line : CORE_IMAGE_EXTRA_INSTALL += " mymodule "

Template:PC$ bitbake st-image-weston

After flashing and booting the board, Insert the kernel module example into the Linux kernel

Template:Board$ modprobe kernel_module_example
[18167.821725] Template:Highlight: hello world from STMicroelectronics

Remove the kernel module example from the Linux kernel

Template:Board$ rmmod kernel_module_example
[18180.086722] Template:Highlight: goodbye from STMicroelectronics

Once this quick check is done, please remove the addon in st-image-weston

  • Create your custom image by following the recommendation made in How to create your own image (chapter 4.2.3).
  • This new recipe (mymodule.bb) must be added inside the custom image you compile
Template:PC$ cd .../meta-my-custo-layer/recipes-samples/images/

Open my-custom-image.bb and add this line : IMAGE_INSTALL += "mymodule"

Template:PC$ bitbake <my custome image>

Template:ReviewsComments