Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc /}}
3 {{/box}}
4
5 = Build linphone-sdk and flexisip on Yocto =
6
7 This pages describes how to build linphone-sdk and/or Flexisip on Yocto, on any hardware platform.
8 This is not a Yocto tutorial, and therefore this requires a little bit of first-hand Yocto experience.
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.
10
11 This setup has been tested with **Yocto Sumo** and **Yocto Thud**.
12
13 == Set up your build system ==
14
15 Before jumping into building anything for your platform, you must ensure your host build system is correctly setup with the appropriate tools.
16
17 === Install required packages ===
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 :
20 [[YoctoProject-required-packages>>http://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#required-packages-for-the-host-development-system]]
21
22 === Get the Yocto build system for your platform ===
23
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.
25
26 The main steps to setup the adequate Yocto build environment and layers for your platform are as follows:
27
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
34
35 {{code}}
36 source oe-init-build-env
37 {{/code}}
38
39 * Add the openembedded layers to the bblayers configuration file
40
41 === Add the Linphone recipe ===
42
43 In order to build linphone-sdk and its dependencies with Yocto, the following steps must be completed :
44
45 * Get the linphone-sdk recipes.
46 * Add the layer to the bblayers configuration file
47 * Add linphone-sdk to the image build
48 * Add the commercial license to the white flags list (needed by a linphone dependency)
49 * Add LATEST_REVISIONS, LINPHONE_SDK_REV and LINPHONE_SDK_BRANCH to BB_ENV_EXTRAWHITE.
50
51 There are a few optional additional steps described here:
52
53 * Change the packaging options
54 * Disable video support
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
59
60 === Get Linphone recipes ===
61
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/.
63
64 The yocto-sumo branch provides the linphone-sdk for yocto-sumon
65
66 {{code}}
67 git clone https://gitlab.linphone.org/BC/public/meta-bc.git -b yocto-sumo
68 {{/code}}
69
70 Your metadata directory should now look like this:
71
72 {{code}}
73 [matthieu@linux-3 sources]$ ls
74 meta-bc meta-openembedded openembedded-core
75
76 [matthieu@linux-3 meta-bc]$ ls
77 classes conf README.md recipes-bc
78
79 [matthieu@linux-3 recipes-bc]$ ls
80 flexisip linphone-sdk
81
82 [matthieu@linux-3 linphone-sdk]$ ls
83 linphone-sdk
84 {{/code}}
85
86 This repository also contains the bitbake recipes for Flexisip (SIP proxy server).
87
88 === Add the linphone recipe to the layers ===
89
90 In the **bblayers.conf** file, under build/conf/ add the following line:
91
92 {{code}}
93 ${BSPDIR}/sources/meta-bc
94 {{/code}}
95
96 The file should be similar to this:
97
98 {{code}}
99 POKY_BBLAYERS_CONF_VERSION = "2"
100
101 BBPATH = "${TOPDIR}"
102 BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"
103
104 BBFILES ?= ""
105 BBLAYERS = " \
106 ${BSPDIR}/meta \
107 ${BSPDIR}/meta-yocto \
108 ${BSPDIR}/meta-yocto-bsp \
109 ${BSPDIR}/sources/openembedded-core/meta \
110 ${BSPDIR}/sources/meta-openembedded/meta-oe \
111 ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
112 ${BSPDIR}/sources/meta-openembedded/meta-networking \
113 ${BSPDIR}/sources/meta-openembedded/meta-python \
114 ${BSPDIR}/sources/meta-bc \
115 "
116 {{/code}}
117
118 === Add linphone to the image build ===
119
120 Once Linphone is built you can add it to the final image in **local.conf** using the following lines:
121
122 {{code}}
123 IMAGE_INSTALL_append = " linphone-sdk"
124 {{/code}}
125
126 === Choose linphone-sdk version ===
127
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**:
129
130 {{code}}
131 LATEST_REVISIONS = "1"
132 {{/code}}
133
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"
138 LINPHONE_SDK_BRANCH = "master"
139 {{/code}}
140
141 === Add the commercial license to the white flags list ===
142
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}}
146
147 This is useful for libav, otherwise the linphone build will fail. In the **local.conf** file under build/conf/, add the following lines :
148
149 {{code}}
150 LICENSE_FLAGS_WHITELIST = "commercial"
151 BB_ENV_EXTRAWHITE += "LATEST_REVISIONS"
152 BB_ENV_EXTRAWHITE += "LINPHONE_SDK_REV"
153 BB_ENV_EXTRAWHITE += "LINPHONE_SDK_BRANCH"
154 {{/code}}
155
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:
157
158 {{code}}
159 BBMASK += "/path/to/poky/sources/meta-bc/linphone/libav/libav_%.bbappend"
160 {{/code}}
161
162
163
164 {{info}}
165 The following steps are optional but can be very useful if you want to customize your build
166 {{/info}}
167
168 === Change the packaging option ===
169
170 In the file **local.conf**, under build/conf/, make sure the PACKAGE_CLASSES is set to package_ipk:
171
172 {{code}}
173 PACKAGE_CLASSES ?= "package_ipk"
174 {{/code}}
175
176 === Add liblinphone_tester or flexisip ===
177
178 If you want to add liblinphone_tester and/or flexisip to the final image you can add the following line in **local.conf**:
179
180 {{code}}
181 IMAGE_INSTALL_append = " flexisip"
182 {{/code}}
183
184 === Disable the video options ===
185
186 If you don't need video support, add the following line in **local.conf**:
187
188 {{code}}
189 DISTRO_FEATURES_remove = "x11 wayland"
190 {{/code}}
191
192 In the **linphone.inc** recipe file under /meta-bc/recipes-bc/linphone/linphone, remove the video with the following line :
193
194 {{code}}
195 PACKAGECONFIG ??= "sqlite zlib video ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}"
196 {{/code}}
197
198 Or add a linphone_%.bbappend file containing the following:
199
200 {{code}}
201 PACKAGECONFIG_remove = "video"
202 {{/code}}
203
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
206 {{code}}
207 IMAGE_INSTALL_append = " glew"
208 {{/code}}
209
210 === Select number of CPU cores used for the build ===
211
212 In the **local.conf** file under build/conf/, add the following line:
213
214 {{code}}
215 BB_NUMBER_THREADS ?= "X"
216 {{/code}}
217
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
222 If you want to add networking packages to the core images, for example you can add the following lines to **local.conf**:
223
224 {{code}}
225 CORE_IMAGE_EXTRA_INSTALL += "dhcpcd"
226 CORE_IMAGE_EXTRA_INSTALL += "init-ifupdown"
227 {{/code}}
228
229 === Save disk space during builds ===
230
231 You can save disk space during build by adding the following line to **local.conf**:
232
233 {{code}}
234 INHERIT += "rm_work"
235 {{/code}}
236
237 === Add ssh server if necessary ===
238
239 If you want to add an ssh server to the core images, you can modify the following line to **local.conf**:
240
241 {{code}}
242 EXTRA_IMAGE_FEATURES = "debug-tweaks ssh-server-openssh"
243 {{/code}}
244
245 == Build linphone-sdk, flexisip and the final image ==
246
247 Linphone-sdk and Flexisip must be built first before integrating them to the final image.
248
249 === Build Linphone-sdk ===
250
251 Now that you're environment is all set up, run the following commands to build the linphone-sdk and/or the Flexisip packages:
252
253 {{code}}
254 bitbake linphone-sdk
255 bitbake flexisip
256 {{/code}}
257
258 === Build the final image ===
259
260 Then you can build the image you want using the following example command, which will use the configuration you specified in **local.conf**:
261
262 {{code}}
263 bitbake core-image-minimal
264 {{/code}}
265
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
268 == Build for Wandboard Solo Freescale i.MX6 Cortex-A9 ==
269
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.
271
272 In order to successfully build Linphone for the Wandboard Solo, the following steps must be followed:
273
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
280 * Start liblinphone_tester and linphone-daemon
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
292 You can now add the layers to the **bblayers.conf** configuration file under /build/conf/, which should now be similar to this:
293
294 {{code}}
295 POKY_BBLAYERS_CONF_VERSION = "2"
296
297 BBPATH = "${TOPDIR}"
298 BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"
299
300 BBFILES ?= ""
301 BBLAYERS = " \
302 ${BSPDIR}/meta \
303 ${BSPDIR}/meta-yocto \
304 ${BSPDIR}/meta-yocto-bsp \
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
319 In order to use the wandboard layers of metadata for the build you need to change to target machine in **local.conf**:
320
321 {{code}}
322 MACHINE = "wandboard"
323 {{/code}}
324
325 === Accept Freescale EULA ===
326
327 To accept the Freescale EULA you can add the following line to **local.conf**:
328
329 {{code}}
330 ACCEPT_FSL_EULA = "1"
331 {{/code}}
332
333 === Clean and re-build the image ===
334
335 Before building the Wandboard version of your image you may need to clean the linphone and image targets:
336
337 {{code}}
338 bitbake -c cleanall core-image-minimal
339 bitbake -c cleanall linphone-sdk
340 {{/code}}
341
342 Then you can build the Wandboard image with bitbake:
343
344 {{code}}
345 bitbake -f linphone-sdk
346 bitbake -f core-image-minimal
347 {{/code}}
348
349 === Unzip wic.gz and flash the image on sd card ===
350
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:
352
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
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
363 {{code}}
364 sudo dd if=core-image-minimal-wandboard.wic of=/dev/sdb bs=1024
365 {{/code}}
366
367 == Using linphone-sdk and flexisip binaries ==
368
369 === Start linphone or flexisip binaries ===
370
371 All installed files from linphone and flexisip can be found in the directory /opt/belledonne-communications/
372
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
377 === Link against liblinphone in your own recipe ===
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
381 Here is an example recipe of a test program linking against liblinphone:
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() {
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
397 }
398
399 do_install() {
400 install -m 0755 -d ${D}${bindir}
401 install -m 0755 ${S}/test ${D}${bindir}
402 }
403
404 {{/code}}
405
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).
407
408 The important option here is `-Wl,-rpath-link` which will make the compiler check for libraries at link time in the given directory.
409
410
411 == Previous yocto versions and linphone recipes ==
412
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}}