Build Linphone and Flexisip on Yocto

This pages describes how to build Linphone and/or Flexisip on Yocto, on any hardware platform.
This is not a Yocto tutorial, and therefore this requires a little bit of first-hand Yocto experience.
A few leads and links are given for the installation of packages on the target machine, however it is mainly out of this wiki page's scope.

This setup has been tested with Yocto Fido and Yocto Morty.

Set up your build system

Before jumping into building anything for your platform, you must ensure your host build system is correctly setup with the appropriate tools.

Install required packages

Install the required packages for the host development system. The Yocto Project documentation has a list of everything needed for each host type (Ubuntu, CentOS, etc.) as well as the matching install commands for them here :
YoctoProject-required-packages

Get the Yocto build system for your platform

The Yocto project Complete documentation set covers this in details, and is available on their official website here : Yocto Documentation Website. The Yocto Project Quick Start guide is particularly helpful for the execution of the following steps.

The main steps to setup the adequate Yocto build environment and layers for your platform are as follows:

  • Get Bitbake and the OpenEmbedded components (known as Poky)
    • poky
    • openembedded-core
    • meta-openembedded
  • Check out the corresponding distribution version for each repository
  • Initialize the build environment to setup Bitbake
source oe-init-build-env
  • Add the openembedded layers to the bblayers configuration file

Using cmake 3 with Fido

You don't need this step if you are using Yocto Morty

Yocto Fido uses cmake version 2.8.12. However, the linphone recipes require cmake version 3 and higher to be compiled.

Fortunately, a patch has been done to allow porting cmake 3.2.2 to Fido , the commit is here http://cgit.openembedded.org/openembedded-core/patch/?id=c171909352b5ed92166857b0bbcd901ae0f74996 from http://cgit.openembedded.org/openembedded-core/commit/?id=c171909352b5ed92166857b0bbcd901ae0f74996 . The following file contains the patch based on this commit cmake_upgrade_to_3.2.2.patch

If you put the file under the openembedded-core directory, starting the patch from the same directory, the command would be:

git apply cmake_ugrade_to_3.2.2.patch

Add the Linphone recipe

In order to build Linphone and its dependencies with Yocto, the following steps must be completed : 

  • Get the Linphone recipe by cloning the repository
  • Add the layer to the bblayers configuration file
  • Add linphone to the image build
  • Add the commercial license to the white flags list (needed by a linphone dependency) 
  • Make sure either antlr3 is available on your host or set JAVA_HOME environment variable.
  • Add JAVA_HOME to BB_ENV_EXTRAWHITE.

There are a few optional additional steps described here:

  • Change the packaging options
  • Add liblinphone_tester
  • Disable video support
  • Select the number of CPU cores used for the build
  • Add networking packages
  • Save disk space during builds
  • Add an ssh server

Get Linphone recipes

Clone the Linphone layers repository on the same level as the other metadata. In this example, all the metadata layers are cloned into a "sources" directory under poky/.

The master branch provides the linphone from master.

git clone https://gitlab.linphone.org/BC/public/meta-bc.git

Your metadata directory should now look like this:

[matthieu@linux-3 sources]$ ls
meta-bc   meta-openembedded   openembedded-core

[matthieu@linux-3 meta-bc]$ ls
conf   README   recipes-bc

[matthieu@linux-3 recipes-bc]$ ls
flexisip   linphone

[matthieu@linux-3 linphone]$ ls
antlr3        belr          msamr          spandsp       bcg729        bzrtp         msopenh264       speex-bc       bctoolbox      libav           mswebrtc        
srtp          bcunit        libgsm         opus          tunnel        belcard       linphone         ortp           belle-sip      mediastreamer2  polarssl

This repository also contains the bitbake recipes for Flexisip (SIP proxy server).

Add the linphone recipe to the layers

In the bblayers.conf file, under build/conf/ add the following line:

${BSPDIR}/sources/meta-bc

The file should be similar to this:

POKY_BBLAYERS_CONF_VERSION = "2"

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

BBFILES ?= ""
BBLAYERS = " \
  ${BSPDIR}/meta \
  ${BSPDIR}/meta-yocto \
  ${BSPDIR}/meta-yocto-bsp \
  ${BSPDIR}/sources/openembedded-core/meta \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  ${BSPDIR}/sources/meta-openembedded/meta-networking \
  ${BSPDIR}/sources/meta-openembedded/meta-python \
  ${BSPDIR}/sources/meta-bc \
"

Add linphone to the image build

Once Linphone is built you can add it to the final image in local.conf using the following lines:

IMAGE_INSTALL_append = " linphone"

Choose linphone version

Linphone can be built by Yocto as a stable version (equivalent to linphone-desktop last stable version for linphone and its dependencies) or as HEAD of master branch, which sets the latest git revision for all submodules automatically. By default the stable version mode is selected but if you want to use the master/HEAD mode you need to add the following line in local.conf:

LATEST_REVISIONS = "1"

Add the commercial license to the white flags list

The following step is relative to license issues, please be careful if you intend to build a commercial product. The following .bbappend files for libav and ffmpeg disable their GPL license respectively. Their use depends on the Yocto version you are using (Fido uses libav, Morty uses ffmpeg),

This is useful for libav, otherwise the linphone build will fail. In the local.conf file under build/conf/, add the following lines :

LICENSE_FLAGS_WHITELIST = "commercial"
BB_ENV_EXTRAWHITE += "JAVA_HOME"

Since Yocto Krogoth, libav has been replaced by ffmpeg. In order to ignore the .bbappend file concerning libav the following line is necessary for a Yocto Morty build:

BBMASK += "/path/to/poky/sources/meta-bc/linphone/libav/libav_%.bbappend"

The following steps are optional but can be very useful if you want to customize your build

Change the packaging option

In the file local.conf, under build/conf/, make sure the PACKAGE_CLASSES is set to package_ipk:

PACKAGE_CLASSES ?= "package_ipk"

Add liblinphone_tester or flexisip

If you want to add liblinphone_tester and/or flexisip to the final image you can add the following line in local.conf:

IMAGE_INSTALL_append = " linphone-tester"
IMAGE_INSTALL_append = " flexisip"

Disable the video options

If you don't need video support, add the following line in local.conf:

DISTRO_FEATURES_remove = "x11 wayland"

In the linphone.inc recipe file under /meta-bc/recipes-bc/linphone/linphone, remove the video with the following line :

PACKAGECONFIG ??= "sqlite zlib video ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"

Do not disable the video options if you intend to use liblinphone_tester on the final image. If you want to use liblinphoner_tester without having a video output, you might need to build glew and add it to the image using the following line:

IMAGE_INSTALL_append = " glew"

Select number of CPU cores used for the build

In the local.conf file under build/conf/, add the following line:

BB_NUMBER_THREADS ?= "X"

X being the number of threads that you want to use (twice the number of CPU cores)

Add networking packages if necessary

If you want to add networking packages to the core images, for example you can add the following lines to local.conf:

CORE_IMAGE_EXTRA_INSTALL += "dhcpcd"
CORE_IMAGE_EXTRA_INSTALL += "init-ifupdown"

Save disk space during builds

You can save disk space during build by adding the following line to local.conf:

INHERIT += "rm_work"

Add ssh server if necessary

If you want to add an ssh server to the core images, you can modify the following line to local.conf:

EXTRA_IMAGE_FEATURES = "debug-tweaks ssh-server-openssh"

Build Linphone, Flexisip and the final image

Linphone and Flexisip must be built first before integrating them to the final image.

Build Linphone

Now that you're environment is all set up, run the following commands to build the Linphone and/or the Flexisip packages:

bitbake linphone
bitbake flexisip

Build the final image

Then you can build the image you want using the following example command, which will use the configuration you specified in local.conf:

bitbake core-image-minimal

By default the machine architecture for which Yocto builds the image is qemux86 but you can choose to build for any available emulated or hardware machine by specifying it in the local.conf file under the "Machine Selection" section.

The Linphone package detailed here allows you to use linphone-daemon and linphonec, as well as liblinphone_tester if you added it in the configuration files.

Build for Wandboard Solo Freescale i.MX6 Cortex-A9

Example of a build for a specific hardware board with an ARMv7 architecture, which can help understand how to build for your own hardware.

In order to successfully build Linphone for the Wandboard Solo, the following steps must be followed:

  • Get the Wandboard specific layers of metadata
  • Add these layers to bblayers.conf
  • Change target machine to "wandboard"
  • Accept Freescale EULA
  • Clean and re-build the image
  • Unzip wic.gz and flash the image on sd card
  • Start liblinphone_tester and linphone-daemon

Get the Wandboard specific layers of metadata

In order to support this specific architecture, you need to clone and checkout the corresponding branch of three layers of metadata :

  • meta-freescale
  • meta-freescale-distro
  • meta-freescale-3rdparty

Add these layers to bblayers.conf

You can now add the layers to the bblayers.conf configuration file under /build/conf/, which should now be similar to this:

POKY_BBLAYERS_CONF_VERSION = "2"

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

BBFILES ?= ""
BBLAYERS = " \
  ${BSPDIR}/meta \
  ${BSPDIR}/meta-yocto \
  ${BSPDIR}/meta-yocto-bsp \
  ${BSPDIR}/sources/openembedded-core/meta \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  ${BSPDIR}/sources/meta-openembedded/meta-networking \
  ${BSPDIR}/sources/meta-openembedded/meta-python \
  ${BSPDIR}/sources/meta-freescale \
  ${BSPDIR}/sources/meta-freescale-distro \
  ${BSPDIR}/sources/meta-freescale-3rdparty \
  ${BSPDIR}/sources/meta-bc \
"

Change target machine to "wandboard"

In order to use the wandboard layers of metadata for the build you need to change to target machine in local.conf:

MACHINE = "wandboard"

Accept Freescale EULA

To accept the Freescale EULA you can add the following line to local.conf:

ACCEPT_FSL_EULA = "1"

Clean and re-build the image

Before building the Wandboard version of your image you may need to clean the linphone and image targets:

bitbake -c cleanall core-image-minimal
bitbake -c cleanall linphone

Then you can build the Wandboard image with bitbake:

bitbake -f linphone
bitbake -f core-image-minimal

Unzip wic.gz and flash the image on sd card

If your Wandboard build is successful, you can find the final images in /build/tmp/deploy/images/wandboard/. To retreive the .wic image you need to unzip the .wic.gz file with the following command:

gunzip -f core-image-minimal-wandboard.wic.gz

Then you can flash it on an sd card with the dd command. In this example the sd card device is called /dev/sdb.

The following step is critical, be sure to target the correct device before executing the "dd" command. The "lsblk" command is very useful to determine to correct device.

sudo dd if=core-image-minimal-wandboard.wic of=/dev/sdb bs=1024

Start liblinphone_tester and linphone-daemon

Once the sd card is in the Wanboard you can boot with the default login "root". You can find liblinphone_tester, linphone-daemon and linphonec under /usr/bin/.