Task #10 - How to create a custom layer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Task #10 - How to create a custom layer

No ratings

Task #10 - How to create a custom layer

One of the most important features of Yocto is its ability to handle sublayers. To understand the sublayers please Yocto Project Development Manual

Start creating meta-custom folder, then create the other folders. For example:

meta-daiane/

├── conf

│   └── layer.conf

├── README

├── recipes-core

│   └── helloworld

│       ├── helloworld

│       │   └── hello_world.c

│       └── helloworld_0.0.bb

└── recipes-daiane

    └── images

        └── dai-image-hello.bb

It´s possible to create recipes-kernel and place there your defconfig, or create a bbappend to apply your patches to kernel, or even create a recipes-multimedia and place there custom application for gstreamer, for example.

Here, the custom application example is a helloworld application.

One important tip:

Yocto see recipes name as PACKAGENAME_VERSION.bb, It means, yocto uses "_" (underline) to separate the package name from package version on a recipe file name. So, if you call your helloworld application as hello_world_1.0.bb Yocto will think your application is called "hello" and the version is something around "world_1.0"

Please, be careful.

LAYER.CONF

This is the file that gives new layer live. Find the content of mine layer.conf below:

# We have a conf and classes directory, add to BBPATH

BBPATH .= ":${LAYERDIR}"

# We have a packages directory, add to BBFILES

BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \

            ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "daiane"

BBFILE_PATTERN_daiane := "^${LAYERDIR}/"

BBFILE_PRIORITY_daiane = "4"

As soon as the new custom layer is created, it MUST include it to  conf/bblayers.conf file. Please see the example:

LCONF_VERSION = "6"

BBPATH = "${TOPDIR}"

BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"

BBFILES ?= ""

BBLAYERS = " \

  ${BSPDIR}/sources/poky/meta \

  ${BSPDIR}/sources/poky/meta-yocto \

  \

  ${BSPDIR}/sources/meta-openembedded/meta-oe \

  \

  ${BSPDIR}/sources/meta-fsl-arm \

  ${BSPDIR}/sources/meta-fsl-arm-extra \

  ${BSPDIR}/sources/meta-fsl-demos \

  \

  ${BSPDIR}/sources/meta-daiane \

"

Please, find the tarball with sample meta layer attached to this document.

It includes one image that will install the Hello World application:

$ bitbake dai-image-hello

When the content of image tar ball is extracted, hello_world was installed and it was for ARM:

$ find -name hello*

./usr/bin/hello_world

$ file ./usr/bin/hello_world

./usr/bin/hello_world: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped

Go to Yocto Training - HOME

Go to Task #9 - How to add bad/ugly

Labels (1)
Attachments
Comments

Question: If I have create a recipe for an application A and this has a DEPENDS on B and C, then how do I install the application on my board such that A,B,C are all installed in one step instead of installing rpms for A,B,C separately in three different steps.

In fact, DEPENDS does not mean it *must* be installed!

If you create A that needs to have access to B source code and C header files (dumb example). You don´t need to have B and C copied into your rootfs.

In other hand. If create an application that *depends in run time from another application*, for example, you created your very own MP3 player. You must have installed id3tag into source code, but your application does build WITHOUT its source code.

In this case application A does not DEPENDS += "B". It RDEPENDS += "B". in other words, it depends only in runtime (RuntimeDEPENDS)

In some cases (and I´m not completely sure in *which* cases) Yocto will determinate automatically the run time dependencies. One example is when a lib opens another lib by dlopen. Yocto detects this "link" and install both libraries files.

So, the most important thing is not fake your system to get something you want installed, but really know your application and create the *right* recipe to represent it on Yocto world. If you create the right recipe you will have everything you need *always*

But, if you only want to test all the stuff, and the *right* is not having B and C installed, and you only want those package *this time* you can add to local.conf CORE_IMAGE_ EXTRA_INSTALL += "B C"

Daiane,

Thank you for a good and easy to follow tutorial, I have done all these steps on my Fedora box and today I have successfully built my own yocto image (core-image-lsb) for my gk802 hdmi stick.

I have posted my sources for my custom layer here ajayramaswamy/meta-gk802 · GitHub

Thanks & best regards

Ajay

Hi Ajay, why does MACHINE_FEATURES in your gk802.conf (and other machine specific recipes that I have seen before) include "pci"? As far as I know gk802 does not expose a pci interface

Thanks a lot for sharing :heart:

Hello Daiane!

First of all thank you for your contribution. We made this example and works fine. However, we asked ourselves how to put the hello_world application  in another directory instead of bindir( if you open the bitbake.conf you can see datadir is equal to usr/share).  I want to explain how to install the app in usr/share/myapp  for example.

  1. Open the helloworld_0.0.bb
  2. Add :  FILES_${PN} +=  “  ${datadir}/myapp”
  3. Install the directory  : install –d ${D}/${datadir}/myapp
  4. Install the app : install –m  0644 ${WORKDIR}/hello_world  ${D}/${datadir}/myapp

As you can see in FILES_${PN}   you can add your own directory.

Diego

thanks a lot :heart:

Hello Daiane,

thank you very much for this helpful series. I wonder, is the tarball for this step still available (I can't see the link for download anywhere)?

Tim.

I´m almost sure I have uploaded it that time. Anyway, I uploaded the tarball.

Thanks for letting me know :smileywink:

hello Daiane,

Thanks for great tutorial.

As I was following the steps you mentioned, I get this error when trying to bitbake my image

bitbake lib-new-image

Error: libnew not found in the base feeds (nitrogen6x cortexa9hf-vfp-neon-mx6 cortexa9hf-vfp-neon cortexa9hf-vfp armv7ahf-vfp-neon armv7ahf-vfp armv6hf-vfp armv5ehf-vfp armv5hf-vfp noarch any all).

here's the structure:

./meta-newlib/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
├── recipes-core
│   └── libnew
│       ├── libnew
│       │   └── libnew.a
│       └── libnew_0.0.bb
└── recipes-newlib
    └── images
        └── lib-new-image.bb

lib-new.image.bb:

include recipes-core/images/core-image-minimal.bb

IMAGE_INSTALL += " \

        libnew \

"

export IMAGE_BASENAME = "lib-new-image"

libnew_00.bb:

DESCRIPTION = "simple C library"

PR = "r0"

LICENSE = "CLOSED"

S = "${WORKDIR}"

SRC_URI = "file://libnew.a"

do_install() {

             install -d ${D}${libdir}/

             install -m 0755 ${S}/libnew.a ${D}${libdir}/

}

FILES_${PN} = "${libdir}/libnew.a"

layer.conf:

# We have a conf and classes directory, add to BBPATH

BBPATH .= ":${LAYERDIR}"

# We have recipes-* directories, add to BBFILES

BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \

        ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "newlib"

BBFILE_PATTERN_newlib = "^${LAYERDIR}/"

BBFILE_PRIORITY_newlib = "6"

I also added the layer to bblayer config file.

any idea what's the problem here?

Mahyar

No, I almost cannot understand your message...

Would you mind, mahyar@boundarydevices.com/Mahyar create a new topic pasting all those information again? Please, share the new topic with me.

I would prefer if we solve individual problems/issues in individual threads instead of in a Doc comment.

Thanks

Hi Daiane,

How do we migrate to a newer version of library ?

In my case, I want to migrate to glib-2.0_2.38 from glib-2.0_2.36. What would be easiest way to do it ?

Please help.

Suman

?You need to create a .36 recipe, then on local.conf indicated the preferred version

PREFERRED_VERSION_glib-2.0 = "2.36"

Leo

Version history
Last update:
‎08-05-2013 09:57 AM
Updated by: