I like to keep the directories in my Yocto projects structured so that I can easily keep track of where things come from. One of my biggest things is keeping any layers I have created separate from any layers I have downloaded for a third-party.
This shows a typical layout for a project I create.
To start with, I will create a layers
directory under the top level of my project. This now keeps the layers separate from any local utilities and helper scripts.
Next, I like to separate out any layers I create from any layers that I download from a third party, so under the layers directory I create project
and third-party
directories.
Any layers that have not been created in-house (poky
, meta-openembedded
, etc, etc) can then live in the third-party
directory.
The project directory then contains any layers that have been created locally. As a minimum starting point, I will create three layers:
- meta-my-bsp
- meta-my-distro
- meta-sy-software
meta-my-bsp
My BSP layer contains all of the recipes and recipe appends to boot the board(s) I am working on with that project. This would include the boot loader, the kernel, any bespoke kernel modules and also if it is a bespoke board, the machine configuration.
meta-my-distro
The distro layer is for anything that is ‘standard linux’ stuff. This is where I modify the recipes in other layers, so mainly contains .bbappend
files.
This is also where I define my distro.conf and any images for the project.
meta-my-software
The software layer is for any software that has been developed in-house.
Layer Configuration
Given that multiple people can be working on a project, I like to keep my bblayers.conf
file portable – so removing any hard-coded paths. This means I can create a template that can be checked-in to the overall project repository, and then other members of the team are able to easily make use of it.
My bblayers.conf
file therefore looks something like:
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
# YOCTOROOT will be updated with the correct path once build-env is sourced
YOCTOROOT = "${TOPDIR}/../layers"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
${YOCTOROOT}/third-party/poky/meta \
${YOCTOROOT}/third-party/poky/meta-poky \
${YOCTOROOT}/third-party/poky/meta-yocto-bsp \
${YOCTOROOT}/third-party/meta-openembedded/meta-oe \
${YOCTOROOT}/project/meta-my-bsp \
${YOCTOROOT}/project/meta-my-distro \
${YOCTOROOT}/project/meta-my-software \
"