Hide last authors
SandrineAvakian 1.1 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc /}}
3 {{/box}}
4
NicolasMichon 48.1 5 = Build linphone-sdk and flexisip on Yocto =
SandrineAvakian 2.1 6
NicolasMichon 48.1 7 This pages describes how to build linphone-sdk and/or Flexisip on Yocto, on any hardware platform.
SandrineAvakian 2.1 8 This is not a Yocto tutorial, and therefore this requires a little bit of first-hand Yocto experience.
MatthieuTanon 37.1 9 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.
SandrineAvakian 1.1 10
NicolasMichon 48.1 11 This setup has been tested with **Yocto Sumo** and **Yocto Thud**.
SandrineAvakian 1.1 12
SandrineAvakian 2.1 13 == Set up your build system ==
14
MatthieuTanon 37.1 15 Before jumping into building anything for your platform, you must ensure your host build system is correctly setup with the appropriate tools.
SandrineAvakian 1.1 16
SandrineAvakian 3.1 17 === Install required packages ===
SandrineAvakian 2.1 18
19 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 :
SandrineAvakian 5.1 20 [[YoctoProject-required-packages>>http://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#required-packages-for-the-host-development-system]]
SandrineAvakian 1.1 21
SandrineAvakian 2.1 22 === Get the Yocto build system for your platform ===
23
François Grisez 45.1 24 The Yocto project Complete documentation set covers this in details, and is available on their official website here : [[Yocto Documentation Website>>https://www.yoctoproject.org/documentation]]. The Yocto Project Quick Start guide is particularly helpful for the execution of the following steps.
MatthieuTanon 17.1 25
SandrineAvakian 1.1 26 The main steps to setup the adequate Yocto build environment and layers for your platform are as follows:
27
MatthieuTanon 17.1 28 * Get Bitbake and the OpenEmbedded components (known as Poky)
29 ** poky
30 ** openembedded-core
31 ** meta-openembedded
32 * Check out the corresponding distribution version for each repository
33 * Initialize the build environment to setup Bitbake
SandrineAvakian 1.1 34
MatthieuTanon 17.1 35 {{code}}
36 source oe-init-build-env
37 {{/code}}
38
39 * Add the openembedded layers to the bblayers configuration file
40
NicolasMichon 48.1 41 === Add the Linphone recipe ===
MatthieuTanon 30.1 42
NicolasMichon 49.1 43 In order to build linphone-sdk and its dependencies with Yocto, the following steps must be completed :
SandrineAvakian 2.1 44
jehan monnier 51.2 45 * Get the linphone-sdk recipes.
MatthieuTanon 17.1 46 * Add the layer to the bblayers configuration file
NicolasMichon 49.1 47 * Add linphone-sdk to the image build
SandrineAvakian 1.1 48 * Add the commercial license to the white flags list (needed by a linphone dependency)
jehan monnier 51.2 49 * Add LATEST_REVISIONS, LINPHONE_SDK_REV and LINPHONE_SDK_BRANCH to BB_ENV_EXTRAWHITE.
SandrineAvakian 1.1 50
MatthieuTanon 17.1 51 There are a few optional additional steps described here:
SandrineAvakian 2.1 52
MatthieuTanon 17.1 53 * Change the packaging options
SandrineAvakian 1.1 54 * Disable video support
MatthieuTanon 17.1 55 * Select the number of CPU cores used for the build
56 * Add networking packages
57 * Save disk space during builds
58 * Add an ssh server
SandrineAvakian 1.1 59
SandrineAvakian 3.1 60 === Get Linphone recipes ===
SandrineAvakian 2.1 61
MatthieuTanon 31.2 62 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/.
SandrineAvakian 1.1 63
jehan monnier 51.2 64 The yocto-sumo branch provides the linphone-sdk for yocto-sumon
SandrineAvakian 8.1 65
MatthieuTanon 17.1 66 {{code}}
jehan monnier 52.1 67 git clone https://gitlab.linphone.org/BC/public/meta-bc.git -b yocto-sumo
MatthieuTanon 17.1 68 {{/code}}
SandrineAvakian 8.1 69
MatthieuTanon 17.1 70 Your metadata directory should now look like this:
MatthieuTanon 26.1 71
MatthieuTanon 27.1 72 {{code}}
73 [matthieu@linux-3 sources]$ ls
MatthieuTanon 17.1 74 meta-bc meta-openembedded openembedded-core
SandrineAvakian 1.1 75
MatthieuTanon 17.1 76 [matthieu@linux-3 meta-bc]$ ls
NicolasMichon 49.1 77 classes conf README.md recipes-bc
MatthieuTanon 17.1 78
79 [matthieu@linux-3 recipes-bc]$ ls
NicolasMichon 49.1 80 flexisip linphone-sdk
MatthieuTanon 17.1 81
NicolasMichon 49.1 82 [matthieu@linux-3 linphone-sdk]$ ls
83 linphone-sdk
MatthieuTanon 27.1 84 {{/code}}
MatthieuTanon 17.1 85
SandrineAvakian 1.1 86 This repository also contains the bitbake recipes for Flexisip (SIP proxy server).
87
MatthieuTanon 17.1 88 === Add the linphone recipe to the layers ===
SandrineAvakian 2.1 89
MatthieuTanon 38.1 90 In the **bblayers.conf** file, under build/conf/ add the following line:
SandrineAvakian 1.1 91
MatthieuTanon 27.1 92 {{code}}
93 ${BSPDIR}/sources/meta-bc
94 {{/code}}
MatthieuTanon 26.1 95
MatthieuTanon 20.1 96 The file should be similar to this:
97
98 {{code}}
MatthieuTanon 32.1 99 POKY_BBLAYERS_CONF_VERSION = "2"
100
SandrineAvakian 1.1 101 BBPATH = "${TOPDIR}"
102 BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"
103
104 BBFILES ?= ""
105 BBLAYERS = " \
MatthieuTanon 31.2 106 ${BSPDIR}/meta \
107 ${BSPDIR}/meta-yocto \
MatthieuTanon 32.1 108 ${BSPDIR}/meta-yocto-bsp \
MatthieuTanon 17.1 109 ${BSPDIR}/sources/openembedded-core/meta \
SandrineAvakian 1.1 110 ${BSPDIR}/sources/meta-openembedded/meta-oe \
111 ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
MatthieuTanon 17.1 112 ${BSPDIR}/sources/meta-openembedded/meta-networking \
113 ${BSPDIR}/sources/meta-openembedded/meta-python \
SandrineAvakian 1.1 114 ${BSPDIR}/sources/meta-bc \
MatthieuTanon 20.1 115 "
116 {{/code}}
SandrineAvakian 1.1 117
MatthieuTanon 17.1 118 === Add linphone to the image build ===
119
MatthieuTanon 38.1 120 Once Linphone is built you can add it to the final image in **local.conf** using the following lines:
MatthieuTanon 17.1 121
MatthieuTanon 27.1 122 {{code}}
jehan monnier 52.1 123 IMAGE_INSTALL_append = " linphone-sdk"
MatthieuTanon 27.1 124 {{/code}}
MatthieuTanon 23.1 125
jehan monnier 51.2 126 === Choose linphone-sdk version ===
MatthieuTanon 23.1 127
jehan monnier 51.2 128 Linphone-sdk can be built by Yocto as a stable version 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**:
MatthieuTanon 24.1 129
MatthieuTanon 25.1 130 {{code}}
131 LATEST_REVISIONS = "1"
132 {{/code}}
MatthieuTanon 23.1 133
jehan monnier 51.2 134 If you aim to build linphone-sdk specify version, you need to set both branch name and commit it using LINPHONE_SDK_REV and LINPHONE_SDK_BRANCH
135
136 {{code}}
137 LINPHONE_SDK_REV = "cdc0d522dca3a52c083a90d08790891392513ba9"
jehan monnier 53.1 138 LINPHONE_SDK_BRANCH = "master"
jehan monnier 51.2 139 {{/code}}
140
SandrineAvakian 3.1 141 === Add the commercial license to the white flags list ===
SandrineAvakian 2.1 142
MatthieuTanon 43.1 143 {{info}}
144 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),
145 {{/info}}
SandrineAvakian 1.1 146
MatthieuTanon 43.1 147 This is useful for libav, otherwise the linphone build will fail. In the **local.conf** file under build/conf/, add the following lines :
SandrineAvakian 2.1 148
MatthieuTanon 27.1 149 {{code}}
150 LICENSE_FLAGS_WHITELIST = "commercial"
jehan monnier 51.2 151 BB_ENV_EXTRAWHITE += "LATEST_REVISIONS"
152 BB_ENV_EXTRAWHITE += "LINPHONE_SDK_REV"
153 BB_ENV_EXTRAWHITE += "LINPHONE_SDK_BRANCH"
MatthieuTanon 27.1 154 {{/code}}
SandrineAvakian 1.1 155
MatthieuTanon 43.1 156 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:
MatthieuTanon 26.1 157
MatthieuTanon 43.1 158 {{code}}
159 BBMASK += "/path/to/poky/sources/meta-bc/linphone/libav/libav_%.bbappend"
160 {{/code}}
161
162
163
MatthieuTanon 17.1 164 {{info}}
165 The following steps are optional but can be very useful if you want to customize your build
166 {{/info}}
167
SandrineAvakian 3.1 168 === Change the packaging option ===
SandrineAvakian 2.1 169
MatthieuTanon 38.1 170 In the file **local.conf**, under build/conf/, make sure the PACKAGE_CLASSES is set to package_ipk:
SandrineAvakian 1.1 171
MatthieuTanon 27.1 172 {{code}}
MatthieuTanon 28.1 173 PACKAGE_CLASSES ?= "package_ipk"
MatthieuTanon 27.1 174 {{/code}}
SandrineAvakian 1.1 175
MatthieuTanon 38.1 176 === Add liblinphone_tester or flexisip ===
MatthieuTanon 17.1 177
MatthieuTanon 38.1 178 If you want to add liblinphone_tester and/or flexisip to the final image you can add the following line in **local.conf**:
MatthieuTanon 17.1 179
MatthieuTanon 27.1 180 {{code}}
MatthieuTanon 38.1 181 IMAGE_INSTALL_append = " flexisip"
MatthieuTanon 27.1 182 {{/code}}
MatthieuTanon 17.1 183
184 === Disable the video options ===
185
MatthieuTanon 38.1 186 If you don't need video support, add the following line in **local.conf**:
MatthieuTanon 17.1 187
MatthieuTanon 27.1 188 {{code}}
189 DISTRO_FEATURES_remove = "x11 wayland"
190 {{/code}}
MatthieuTanon 17.1 191
MatthieuTanon 38.1 192 In the **linphone.inc** recipe file under /meta-bc/recipes-bc/linphone/linphone, remove the video with the following line :
MatthieuTanon 17.1 193
MatthieuTanon 27.1 194 {{code}}
195 PACKAGECONFIG ??= "sqlite zlib video ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
196 {{/code}}
MatthieuTanon 17.1 197
NicolasMichon 46.1 198 Or add a linphone_%.bbappend file containing the following:
199
200 {{code}}
201 PACKAGECONFIG_remove = "video"
202 {{/code}}
203
MatthieuTanon 17.1 204 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:
205
MatthieuTanon 27.1 206 {{code}}
207 IMAGE_INSTALL_append = " glew"
208 {{/code}}
MatthieuTanon 17.1 209
210 === Select number of CPU cores used for the build ===
211
MatthieuTanon 38.1 212 In the **local.conf** file under build/conf/, add the following line:
MatthieuTanon 17.1 213
MatthieuTanon 27.1 214 {{code}}
215 BB_NUMBER_THREADS ?= "X"
216 {{/code}}
MatthieuTanon 26.1 217
MatthieuTanon 17.1 218 X being the number of threads that you want to use (twice the number of CPU cores)
219
220 === Add networking packages if necessary ===
221
MatthieuTanon 38.1 222 If you want to add networking packages to the core images, for example you can add the following lines to **local.conf**:
MatthieuTanon 17.1 223
MatthieuTanon 27.1 224 {{code}}
225 CORE_IMAGE_EXTRA_INSTALL += "dhcpcd"
MatthieuTanon 29.1 226 CORE_IMAGE_EXTRA_INSTALL += "init-ifupdown"
MatthieuTanon 27.1 227 {{/code}}
MatthieuTanon 17.1 228
229 === Save disk space during builds ===
230
MatthieuTanon 38.1 231 You can save disk space during build by adding the following line to **local.conf**:
MatthieuTanon 17.1 232
MatthieuTanon 27.1 233 {{code}}
234 INHERIT += "rm_work"
235 {{/code}}
MatthieuTanon 17.1 236
237 === Add ssh server if necessary ===
238
MatthieuTanon 38.1 239 If you want to add an ssh server to the core images, you can modify the following line to **local.conf**:
MatthieuTanon 17.1 240
MatthieuTanon 27.1 241 {{code}}
242 EXTRA_IMAGE_FEATURES = "debug-tweaks ssh-server-openssh"
243 {{/code}}
MatthieuTanon 17.1 244
NicolasMichon 49.1 245 == Build linphone-sdk, flexisip and the final image ==
MatthieuTanon 17.1 246
jehan monnier 51.2 247 Linphone-sdk and Flexisip must be built first before integrating them to the final image.
MatthieuTanon 19.1 248
jehan monnier 51.2 249 === Build Linphone-sdk ===
MatthieuTanon 19.1 250
NicolasMichon 49.1 251 Now that you're environment is all set up, run the following commands to build the linphone-sdk and/or the Flexisip packages:
MatthieuTanon 17.1 252
MatthieuTanon 27.1 253 {{code}}
NicolasMichon 49.1 254 bitbake linphone-sdk
MatthieuTanon 38.1 255 bitbake flexisip
MatthieuTanon 27.1 256 {{/code}}
MatthieuTanon 26.1 257
MatthieuTanon 19.1 258 === Build the final image ===
259
MatthieuTanon 38.1 260 Then you can build the image you want using the following example command, which will use the configuration you specified in **local.conf**:
MatthieuTanon 17.1 261
MatthieuTanon 27.1 262 {{code}}
263 bitbake core-image-minimal
264 {{/code}}
MatthieuTanon 18.1 265
MatthieuTanon 40.1 266 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.
267
MatthieuTanon 18.1 268 == Build for Wandboard Solo Freescale i.MX6 Cortex-A9 ==
MatthieuTanon 19.1 269
MatthieuTanon 39.1 270 Example of a build for a specific hardware board with an ARMv7 architecture, which can help understand how to build for your own hardware.
MatthieuTanon 19.1 271
272 In order to successfully build Linphone for the Wandboard Solo, the following steps must be followed:
273
MatthieuTanon 20.1 274 * Get the Wandboard specific layers of metadata
275 * Add these layers to bblayers.conf
276 * Change target machine to "wandboard"
277 * Accept Freescale EULA
278 * Clean and re-build the image
279 * Unzip wic.gz and flash the image on sd card
MatthieuTanon 22.1 280 * Start liblinphone_tester and linphone-daemon
MatthieuTanon 20.1 281
282 === Get the Wandboard specific layers of metadata ===
283
284 In order to support this specific architecture, you need to clone and checkout the corresponding branch of three layers of metadata :
285
286 * meta-freescale
287 * meta-freescale-distro
288 * meta-freescale-3rdparty
289
290 === Add these layers to bblayers.conf ===
291
MatthieuTanon 38.1 292 You can now add the layers to the **bblayers.conf** configuration file under /build/conf/, which should now be similar to this:
MatthieuTanon 20.1 293
294 {{code}}
MatthieuTanon 32.1 295 POKY_BBLAYERS_CONF_VERSION = "2"
296
MatthieuTanon 20.1 297 BBPATH = "${TOPDIR}"
298 BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"
299
300 BBFILES ?= ""
301 BBLAYERS = " \
MatthieuTanon 32.1 302 ${BSPDIR}/meta \
303 ${BSPDIR}/meta-yocto \
304 ${BSPDIR}/meta-yocto-bsp \
MatthieuTanon 20.1 305 ${BSPDIR}/sources/openembedded-core/meta \
306 ${BSPDIR}/sources/meta-openembedded/meta-oe \
307 ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
308 ${BSPDIR}/sources/meta-openembedded/meta-networking \
309 ${BSPDIR}/sources/meta-openembedded/meta-python \
310 ${BSPDIR}/sources/meta-freescale \
311 ${BSPDIR}/sources/meta-freescale-distro \
312 ${BSPDIR}/sources/meta-freescale-3rdparty \
313 ${BSPDIR}/sources/meta-bc \
314 "
315 {{/code}}
316
317 === Change target machine to "wandboard" ===
318
MatthieuTanon 38.1 319 In order to use the wandboard layers of metadata for the build you need to change to target machine in **local.conf**:
MatthieuTanon 20.1 320
MatthieuTanon 21.1 321 {{code}}
322 MACHINE = "wandboard"
323 {{/code}}
MatthieuTanon 20.1 324
325 === Accept Freescale EULA ===
326
MatthieuTanon 38.1 327 To accept the Freescale EULA you can add the following line to **local.conf**:
MatthieuTanon 20.1 328
MatthieuTanon 21.1 329 {{code}}
330 ACCEPT_FSL_EULA = "1"
331 {{/code}}
MatthieuTanon 20.1 332
333 === Clean and re-build the image ===
334
MatthieuTanon 21.1 335 Before building the Wandboard version of your image you may need to clean the linphone and image targets:
MatthieuTanon 20.1 336
MatthieuTanon 21.1 337 {{code}}
338 bitbake -c cleanall core-image-minimal
NicolasMichon 49.1 339 bitbake -c cleanall linphone-sdk
MatthieuTanon 21.1 340 {{/code}}
341
342 Then you can build the Wandboard image with bitbake:
343
344 {{code}}
NicolasMichon 49.1 345 bitbake -f linphone-sdk
MatthieuTanon 21.1 346 bitbake -f core-image-minimal
347 {{/code}}
348
MatthieuTanon 20.1 349 === Unzip wic.gz and flash the image on sd card ===
350
MatthieuTanon 21.1 351 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:
MatthieuTanon 20.1 352
MatthieuTanon 21.1 353 {{code}}
354 gunzip -f core-image-minimal-wandboard.wic.gz
355 {{/code}}
356
357 Then you can flash it on an sd card with the dd command. In this example the sd card device is called /dev/sdb.
358
MatthieuTanon 38.1 359 {{info}}
360 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.
361 {{/info}}
362
MatthieuTanon 21.1 363 {{code}}
364 sudo dd if=core-image-minimal-wandboard.wic of=/dev/sdb bs=1024
365 {{/code}}
366
NicolasMichon 49.1 367 == Using linphone-sdk and flexisip binaries ==
MatthieuTanon 21.1 368
NicolasMichon 49.1 369 === Start linphone or flexisip binaries ===
NicolasMichon 47.1 370
NicolasMichon 49.1 371 All installed files from linphone and flexisip can be found in the directory /opt/belledonne-communications/
NicolasMichon 48.1 372
NicolasMichon 49.1 373 You can find and launch any executable present in /opt/belledonne-communications/bin/
374
375 For example /opt/belledonne-communications/bin/liblinphone_tester or /opt/belledonne-communications/bin/flexisip
376
jehan monnier 51.2 377 === Link against liblinphone in your own recipe ===
NicolasMichon 49.1 378
379 Since the installation prefix of linphone libraries is not the default system one, compiling and linking against these libraries can be tricky.
380
NicolasMichon 50.1 381 Here is an example recipe of a test program linking against liblinphone:
NicolasMichon 49.1 382
383 {{code}}
384 ​DESCRIPTION = "Example compilation of yocto program based on linphone"
385
386 PR = "r0"
387 LICENSE = "CLOSED"
388 S = "${WORKDIR}"
389
390 DEPENDS = "linphone-sdk"
391
392 LINPHONE_INSTALL_PATH = "/opt/belledonne-communications"
393
394 do_compile() {
NicolasMichon 50.1 395 ${CC} ${CFLAGS} ${LDFLAGS} -I ${STAGING_DIR_HOST}${LINPHONE_INSTALL_PATH}/include -c test.c -o test.o
396 ${CC} ${CFLAGS} ${LDFLAGS} -L${STAGING_DIR_HOST}${LINPHONE_INSTALL_PATH}/lib -llinphone -Wl,-rpath-link=${STAGING_DIR_HOST}${LINPHONE_INSTALL_PATH}/lib test.o -o test
NicolasMichon 49.1 397 }
NicolasMichon 50.1 398
NicolasMichon 49.1 399 do_install() {
400 install -m 0755 -d ${D}${bindir}
NicolasMichon 50.1 401 install -m 0755 ${S}/test ${D}${bindir}
NicolasMichon 49.1 402 }
403
404 {{/code}}
405
NicolasMichon 50.1 406 The STAGING_DIR_HOST points to the recipe-sysroot folder of your recipe which should contain all linphone-sdk related files (because the recipe DEPENDS on linphone-sdk).
NicolasMichon 49.1 407
NicolasMichon 50.2 408 The important option here is `-Wl,-rpath-link` which will make the compiler check for libraries at link time in the given directory.
NicolasMichon 50.1 409
NicolasMichon 50.2 410
NicolasMichon 49.1 411 == Previous yocto versions and linphone recipes ==
412
NicolasMichon 48.1 413 === Using cmake 3 with Fido ===
414
415 {{info}}
416 You don't need this step if you are using Yocto Morty
417 {{/info}}
418
419 Yocto Fido uses **cmake version 2.8.12**. However, the linphone recipes require **cmake version 3 and higher** to be compiled.
420
421 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>>url:http://cgit.openembedded.org/openembedded-core/patch/?id=c171909352b5ed92166857b0bbcd901ae0f74996]] from [[http:~~/~~/cgit.openembedded.org/openembedded-core/commit/?id=c171909352b5ed92166857b0bbcd901ae0f74996>>url: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>>attach:cmake_upgrade_to_3.2.2.patch]]
422
423 If you put the file under the **openembedded-core** directory, starting the patch from the same directory, the command would be:
424
425 {{code}}
426 git apply cmake_ugrade_to_3.2.2.patch
427 {{/code}}