Yocto - How to

From RidgeRun Developer Connection
Jump to: navigation, search





Previous: Tools Index Next: Contact Us




Introduction

In here you can see how to make various specific things with Yocto

Create Custom Image

Instead of changing the features and packages of an image through conf.local, you can create a custom image recipe, where you set all your preferred features and packages.

In this example, we will inherit from core-image-minimal, and will just add openssh.

Let's go to the directory where the core images are located:

cd poky/meta/recipes-core/images

Create a new file (let's say, my-cool-image.bb) with the following contents:

SUMMARY = "A very cool image (just core-image-minimal + ssh)"

LICENSE = "MIT"

inherit core-image

IMAGE_FEATURES += "ssh-server-openssh"

Now let's build our custom image:

bitbake my-cool-image

Test it with qemu:

runqemu my-cool-image

Login as root, and try to run:

ssh

You will see the usage message. It means that our image has openssh.

You can even get the ip of the image running the emulator and try to connect to it using ssh from your computer.

Create Custom Distro

Similar to a custom image, you can also create a custom distribution, which takes out the overhead of adding everything to the local.conf of the build.

To do so, follows these steps:

1. Create or use a new layer and modify its conf, in this case, we use meta-mydistro

bitbake-layers create-layer meta-mydistro
cd meta-mydistro
mkdir -p conf/distro

2. Create a configuration file distro-name.conf for the distro with the following content:

DISTRO = "distro-name"
DISTROOVERRIDES = "poky"
require conf/distro/poky.conf

Here you can add any new configuration you want to add for the distribution, as if it was you local.conf of the build.

3. In you local.conf just use this new distro by adding:

DISTRO ?= "distro-name"

Preferred Recipe Version

To set a preferred version you can for example:

Add the curl package to conf/local.conf

IMAGE_INSTALL_append += " curl"

And then choose the version we just copied (conf/local.conf too):

PREFERRED_VERSION_curl ?= "7.64.1"

Build your image: bitbake core-image-minimal

Now let's run qemu to be sure our version was added:

runqemu core-image-minimal

Login as root and then run:

curl --version

You should see a message with version 7.64.1, which indicates we installed the version we set at the config file.


Previous: Tools Index Next: Contact Us