Sample: Headless application¶
This sample shows how to customize Welma to run a non-graphical application at start-up. It can be used to experiment with Welma and as a starting point for your own application and distribution.
It is provided as a dedicated meta-layer (meta-demo-headless
), which is the
recommended way to use Welma and Yocto.
Running the demo¶
Clone meta-demo-headless
¶
If you followed the Quick start guide, the meta-demo-headless
layer folder should already be present in your Yocto directory. If not, refer
back to the quick start, or add it to your manifest-*.txt
file and run
welma-manifest/setup-download
.
meta-demo-headless git@gitlab.com:${WELMA_GIT_NAMESPACE}/meta-demo-headless ...
Add the meta-layer¶
We now need to make this layer accessible to Yocto. For this, you can either
directly use the template provided (recommended) or edit your layer
configuration (bblayers.conf
) manually.
Option 1: Run the setup tool¶
Load the configuration from the templates available in the meta-layers.
Warning
This will override your local configuration and changes you made to your local configuration files.
source meta-welma/setup/setup-build-env \
meta-welma-*/conf/templates/$MACHINE \
meta-demo-headless/conf/templates/default
Option 2: Edit your bblayers.conf
file¶
Manually edit your bblayers.conf
file and add the layer:
Check the meta-layer is found¶
Bitbake should now be able to find the recipes to build the image if you run the following command:
Example output:
=== Matching recipes: ===
demo-image-headless:
meta-demo-headless 1.0
demo-image-headless-dbg:
meta-demo-headless 1.0
demo-image-headless-dev:
meta-demo-headless 1.0
demo-image-headless-tst:
meta-demo-headless 1.0
Build and run¶
Now that the image is accessible, simply build the image and deploy for your target:
After deploying it on your device or emulator and logging on the system, you will be able to see the application running and logging cpu usage periodically:
Mar 08 22:06:02 qemuarm-welma demo-headless-app[798]: demo-headless-app:cpu-info:cpu 2893 4 9018 133243 40 0 21 0 0 0
Mar 08 22:06:03 qemuarm-welma demo-headless-app[798]: demo-headless-app:cpu-info:cpu 2896 4 9020 133638 40 0 21 0 0 0
Mar 08 22:06:04 qemuarm-welma demo-headless-app[798]: demo-headless-app:cpu-info:cpu 2896 4 9020 134038 40 0 21 0 0 0
Mar 08 22:06:05 qemuarm-welma demo-headless-app[798]: demo-headless-app:cpu-info:cpu 2896 4 9020 134438 40 0 21 0 0 0
That's it ! You can now experiment with your own application, dive into the
implementation below, or look at the Next steps.
meta-demo-headless
layer content¶
This section explains the content of this meta-layer and how it is configured.
-
DISTRO
andMACHINE
are defined inconf/templates/${MACHINE}/local.conf.sample
. -
The bitbake layers are defined in
conf/templates/${MACHINE}/bblayers.conf.sample
-
The production image inherits
welma-image
and adds our demo headless application: -
The development image adds developer tools inherited from Welma's development image:
-
recipes-welma/images/license-digest.bbappend
configures the software license digest / SBOM to be generated for ourdemo-image-headless
image -
recipes-welma/images/all.bbappend
defines the recipes to be built bybitbake all
. -
The headless application and its systemd service are provided by the
demo-headless-app
recipe:
Next steps¶
Congratulations! You can now start a headless application automatically at boot. You can continue by:
- Running the Graphical application samples
- Configuring your distribution for Application development