summaryrefslogtreecommitdiff
path: root/distribution/yocto-advanced/pres_yocto-advanced.tex
blob: e22bbc877aa17a39026b8107d339cc60efdd135e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
\input{configpres}

\title{YOCTO - Advanced}
\maketitle

\begin{frame}
\frametitle{Agenda}
\begin{itemize}
\item Using BSP layers (beaglebone)
\item Build a predefined image (beaglebone)
\item Creating a layer
\item Define a distribution
\item Create an image
\item Writing recipes
\item Yocto \& ELBE combined?
\end{itemize}
\end{frame}

\subsection{Using BSP layers}

\begin{frame}[fragile]
\frametitle{folder layout}
\begin{verbatim}
meta-mylayer
+ conf
|  + layer.conf
+ classes
|  + class1.bbclass
|  + class2.bbclass
+ recipes-category1
|  + package-1
|      + package-1.bb
|  + package-2
|      + package-2.bb
+ recipes-category2
| ..
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
	\frametitle{meta-*/conf/layer.conf}
	each layer needs a configuration file
	\begin{itemize}
		\item add conf and class directories to BBPATH
			\begin{verbatim}BBPATH =. "${LAYERDIR}"\end{verbatim}
		\pause
		\item add recipe directories to BBFILES
			\begin{verbatim}BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
			${LAYERDIR}/recipes-*/*/*.bbappend"\end{verbatim}
		\pause
		\item add layer name to BBFILE\_COLLECTIONS
			\begin{verbatim}BBFILE_COLLECTIONS += "mylayer"\end{verbatim}
		\pause
		\item set root of the layer
			\begin{verbatim}BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"\end{verbatim}
		\pause
		\item set default priority of the layer
			\begin{verbatim}BBFILE_PRIORITY_mylayer = "5"\end{verbatim}
		\pause
		\item set version of layer (only increment if dependencies with other
			layers are affected)
			\begin{verbatim}LAYERVERSION_mylayer = "2"\end{verbatim}
		\pause
		\item set dependencies to other layers
			\begin{verbatim}LAYERDEPENDS_mylayer = "meta-yocto"\end{verbatim}
	\end{itemize}
\end{frame}

\begin{frame}
\frametitle{bitbake-layers}
is useful to debug relations between different layers, options are:
\begin{description}
\item [show-layers] shows the current configured layers
		\pause
\item [show-recipes] lists available recipes and the layers that provide them.
		\pause
\item [show-overlayed] lists overlayed recipes
		\pause
\item [show-appends] lists .bbappend files
	and the recipe files to which they apply
		\pause
\item [show-cross-depends] lists dependency relationships
	between recipes that cross layer boundaries
		\pause
\item [flatten] flattens the layer configuration
	into a separate output directory.
\end{description}
\end{frame}

\begin{frame}
\frametitle{definitions}
\begin{itemize}
	\item It is possible for a recipe with a lower version number PV in a layer
that has a higher priority to take precedence.
		\pause
	\item Also, the layer priority does not currently affect the precedence
order of .conf or .bbclass files. Future versions of BitBake might address this.
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{get an existing layer}
retrive the layer from your BSP/SoC vendor
\begin{verbatim}
poky % git clone git://git.yoctoproject.org/meta-ti
poky % git branch -r
poky % git checkout <RELEASE>
\end{verbatim}
		\pause
have a look at it's dependencies
\begin{verbatim}
poky % cat meta-ti/conf/layer.conf | grep LAYERDEPENDS
LAYERDEPENDS_ti = "core"
\end{verbatim}
		\pause
and retrieve them also
\begin{verbatim}
poky % git clone -b daisy git://git.yoctoproject.org/meta-fsl-arm
\end{verbatim}
		\pause
check dependencies again
\begin{verbatim}
poky % git clone /home/devel/yocto/meta-mini
\end{verbatim}
		\pause
\dots no more dependencies?! \dots OK - finished.
\end{frame}

\begin{frame}[fragile]
\frametitle{generate a new build environment}
\begin{verbatim}
poky % . oe-init-build-env build-ti
poky/build-ti %
\end{verbatim}
\end{frame}

\subsection{Build a predefined image}
\begin{frame}
\frametitle{overview}
builds are configured using two configuration files
\begin{itemize}
	\item build-ti/conf/bblayers.conf
	\item build-ti/conf/local.conf
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{bblayers.conf}
additional layers are added with absolute! path to the BBLAYERS variable
\begin{verbatim}
BBLAYERS ?= " \
  /home/devel/poky/meta \
  /home/devel/poky/meta-yocto \
  /home/devel/poky/meta-yocto-bsp \
  "
\end{verbatim}
\pause
\begin{verbatim}
% bitbake-layers show-layers
layer                 path                                  priority
=====================================================================
meta                  /home/devel/poky/meta                 5
meta-yocto            /home/devel/poky/meta-yocto           5
meta-yocto-bsp        /home/devel/poky/meta-yocto-bsp       5
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{add ti layers}
modify the BBLAYERS variable in bblayers.conf
\begin{verbatim}
BBLAYERS ?= " \
  /home/devel/poky/meta \
  /home/devel/poky/meta-yocto \
  /home/devel/poky/meta-yocto-bsp \
  /home/devel/poky/meta-ti \
  "
\end{verbatim}
\pause
\begin{verbatim}
% bitbake-layers show-layers
layer                 path                                  priority
=====================================================================
meta                  /home/devel/poky/meta                 5
meta-yocto            /home/devel/poky/meta-yocto           5
meta-yocto-bsp        /home/devel/poky/meta-yocto-bsp       5
meta-ti               /home/devel/poky/meta-ti              5
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{overlayed recipes}
to see which recipes replace official ones:
\begin{verbatim}
poky/build-ti % bitbake-layers show-overlayed
Parsing recipes..done.
=== Overlayed recipes ===
directfb:
  meta                 1.7.1
  meta-ti              1.6.3
directfb-examples:
  meta                 1.7.0
  meta-ti              1.6.0
xserver-xorg:
  meta                 2:1.15.0
  meta-ti              2:1.14.4
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{local.conf}
is used to configure
\begin{itemize}
	\item the target machine
		\pause
	\item paths
		\pause
	\item the used distribution
		\pause
	\item package formats
		\pause
	\item arch of developer machine
		\pause
	\item additional image features
		\pause
	\item use additional classes
		\pause
	\item enable testing
		\pause
	\item devshell terminal
		\pause
	\item patch resolver
		\pause
	\item disk monitoring
		\pause
	\item sstate mirrors
		\pause
	\item qemu configuration
		\pause
	\item incompatible licenses, e.g. INCOMPATIBLE\_LICENSE = “GPLv3”
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{configure the machine}
to get a list of currently available machines configs:
\begin{verbatim}
poky/build-ti % grep -r '@NAME' ../meta*/conf/machine
\end{verbatim}
beaglebone.conf - seems to be the one for our bord, so set
imx6qsabrelite.conf - seems to be the one for our bord, so set
\begin{verbatim}
MACHINE ??= "beaglebone"
\end{verbatim}
in conf/local.conf
\end{frame}

\begin{frame}[fragile]
\frametitle{package format}
as we realized with toaster, rpm packaging consumes a lot of CPU time, so lets
try ipk, by setting
\begin{verbatim}
PACKAGE_CLASSES ?= "package_ipk"
\end{verbatim}
in conf/local.conf
\end{frame}

\begin{frame}[fragile]
\frametitle{set extra image features}
we want an image suitable for development, so set
\begin{verbatim}
EXTRA_IMAGE_FEATURES = "debug-tweaks tools-debug \
  eclipse-debug tools-profile"
\end{verbatim}
in conf/local.conf
\end{frame}

\begin{frame}[fragile]
\frametitle{build an predefined image}
use
\begin{verbatim}
ls ../*/*/images/
\end{verbatim}
to get a list of predefined images; however none of them fits my needs\dots
		\pause
\begin{verbatim}
poky/build-fsl % cd ..
poky % git clone -b daisy https://github.com/Freescale/meta-fsl-demos.git
poky % git clone -b daisy git://git.openembedded.org/meta-openembedded
poky % cd -
\end{verbatim}
		\pause
and edit conf/bblayers.conf, to match
\begin{verbatim}
BBLAYERS ?= " \
  /home/devel/poky/meta \
  /home/devel/poky/meta-yocto \
  /home/devel/poky/meta-yocto-bsp \
  /home/devel/poky/meta-fsl-arm \
  /home/devel/poky/meta-fsl-arm-extra \
  /home/devel/poky/meta-openembedded/meta-oe \
  /home/devel/poky/meta-fsl-demos \
  "
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{build a qt demo image}
\begin{verbatim}
poky/build-ti % source toaster start
poky/build-ti % bitbake qt4e-demo-image
Currently 4 running tasks (26 of 4459):
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{build a ti demo image}
\dots back from coffee break
\begin{verbatim}
ERROR: No new tasks can be executed since
       the disk space monitor action is "STOPTASKS"!
\end{verbatim}
what happened??
		\pause
\begin{verbatim}
poky/build-ti % df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda4       367G  348G  850M 100% /
poky/build-ti % du -sm .
31026   .
poky/build-ti % du -sm ../build
29172   ../build/
\end{verbatim}
		\pause
\dots so the solution is to cleanup the disk and run
\begin{verbatim}
poky/build-ti % bitbake qt4e-demo-image
\end{verbatim}
again.

A different behaviour can be configured in 'conf/local.conf'.
\end{frame}

\begin{frame}[fragile]
\frametitle{example of an issue with a sabrelite board}
\begin{verbatim}
ERROR: To use 'gpu-viv-bin-mx6q'
  you need to accept the Freescale EULA
  at '/home/local/src/poky/meta-ti-arm/EULA'.
  Please read it and in case you accept it, write:
  ACCEPT_FSL_EULA = "1" in your local.conf.
ERROR: Function failed: do_unpack
ERROR: Logfile of failure stored in:
  /home/local/src/poky/build-ti/tmp/work/
   cortexa9hf-vfp-neon-mx6-poky-linux-gnueabi/
   gpu-viv-bin-mx6q/1_3.10.17-1.0.0-hfp-r0/temp/
   log.do_unpack.6795
ERROR: Task 1105 (/home/local/src/poky/meta-ti-arm/
  recipes-graphics/gpu-viv-bin-mx6q/
  gpu-viv-bin-mx6q_3.10.17-1.0.0-hfp.bb, do_unpack) failed
  with exit code '1'
\end{verbatim}
		\pause
to solve this issue:
\begin{verbatim}
poky/build-ti % echo 'ACCEPT_FSL_EULA = "1"' >> conf/local.conf
\end{verbatim}
		\pause
\dots and run
\begin{verbatim}
poky/build-ti % bitbake qt4e-demo-image
\end{verbatim}
again.
\end{frame}

\begin{frame}[fragile]
\frametitle{flashing the image}
if the build is completed the image can be transfered to a sdcard:
\begin{verbatim}
poky/build-ti % sudo fdisk /dev/mmcblk0
# create a
# * bootable
# * primary partition with
# * about 100 MB and
# * Windows vFat format
# and another primary partition with Linux Ext format
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{flashing the image \#2}
\begin{verbatim}
poky/build-ti % sudo mkfs.vfat -F 16 -n boot /dev/mmcblk0p1
poky/build-ti % sudo mke2fs -j -L "root" /dev/mmcblk0p2
poky/build-ti % sudo mount /dev/mmcblk0p1 /mnt
poky/build-ti % sudo cp -a tmp/deploy/images/beaglebone/MLO-beaglebone \
  /mnt/MLO
poky/build-ti % sudo cp -a \
  tmp/deploy/images/beaglebone/u-boot-beaglebone.img \
  /mnt/u-boot.img
poky/build-ti % sudo umount /mnt
poky/build-ti % sudo mount /dev/mmcblk0p2 /mnt
poky/build-ti % sudo tar xjf \
  tmp/deploy/images/qt4e-demo-image-beaglebone.tar.bz2 -C /mnt
poky/build-ti % sudo umount /mnt
\end{verbatim}
\end{frame}

\subsection{Creating a layer}
\begin{frame}[fragile]
\frametitle{with yocto helper script}
\begin{verbatim}
poky/build-ti % cd ..
poky % yocto-layer create mini
Please enter the layer priority you'd like to use for the layer:
[default: 6] <return>
Would you like to have an example recipe created? (y/n)
[default: n] <return>
Would you like to have an example bbappend file created? (y/n)
[default: n] <return>
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{manage the layer with git}
\begin{verbatim}
poky % cd meta-mini
poky/meta-mini % git init .
poky/meta-mini % git add *
poky/meta-mini % git commit -sam 'inital version'
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\begin{verbatim}
poky/meta-mini % cd ../build-ti
\end{verbatim}
edit 'conf/bblayers.conf':
\begin{verbatim}
BBLAYERS ?= " \
  /home/devel/poky/meta \
  /home/devel/poky/meta-yocto \
  /home/devel/poky/meta-yocto-bsp \
  /home/devel/poky/meta-ti \
  /home/devel/poky/meta-mini \
  "
\end{verbatim}
\end{frame}

\subsection{Define a distribution}
\begin{frame}
\frametitle{why define a distribution?}
\begin{itemize}
\item naming of the toolchain (codenames, vendor)
		\pause
\item version numbers
		\pause
\item enable default features
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{distro features: file-systems}
\begin{description}
\item[cramfs] CramFS support
		\pause
\item[ext2] tools for supporting for devices with internal HDD/Microdrive
	for storing files (instead of Flash only devices)
		\pause
\item[nfs] NFS client support (for mounting NFS exports on device)
		\pause
\item[smbfs] SMB networks client support
	(for mounting Samba/Microsoft Windows shares on device)
\end{description}
\end{frame}

\begin{frame}
\frametitle{distro features: hardware support}
\begin{description}
\item[alsa] ALSA/sound support
	(OSS compatibility kernel modules installed if available)
		\pause
\item[bluetooth] bluetooth support (integrated BT only)
		\pause
\item[irda] IrDA support
		\pause
\item[wifi] WiFi support (integrated only).
		\pause
\item[keyboard] keyboard support (e.g. keymaps will be loaded during boot)
\end{description}
\end{frame}

\begin{frame}
\frametitle{distro features: grahpics}
\begin{description}
\item[opengl] the Open Graphics Library, which is a cross-language,
	multi-platform application programming interface used for rendering two
	and three-dimensional graphics
		\pause
\item[directfb] DirectFB support
\end{description}
\end{frame}

\begin{frame}
\frametitle{distro features: networking}
\begin{description}
\item[ipsec] IPSec support
		\pause
\item[ipv6] IPv6 support
		\pause
\item[ppp] PPP dialup support
\end{description}
\end{frame}

\begin{frame}
\frametitle{distro features: bus support}
\begin{description}
\item[pci] PCI bus support
		\pause
\item[pcmcia] PCMCIA/CompactFlash support
		\pause
\item[usbgadget] USB Gadget Device support (for USB networking/serial/storage)
		\pause
\item[usbhost] USB Host support
	(allows to connect external keyboard, mouse, storage, network etc)
\end{description}
\end{frame}

\begin{frame}
\frametitle{distro features: software}
\begin{description}
\item[systemd] support for this init manager, which is a full replacement of
	for init with parallel starting of services, reduced shell overhead,
	and other features. This init manager is used by many distributions
		\pause
\item[wayland] the Wayland display server protocol
	and the library that supports it
		\pause
\item[x11] X server and libraries
\end{description}
\end{frame}

\begin{frame}[fragile]
\frametitle{use a DISTRO\_FEATURE}
Normally the distro features are used in package groups in a core layer.
e.g. 'meta/recipes-core/packagegroups/packagegroup-base.bb':
\begin{verbatim}
PACKAGES = ' \
	..
	${@base_contains("DISTRO_FEATURES", \
	                 "opengl", "packagegroup-opengl", "", d)} \
	..
	'
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{exkurs: package groups}
are recipes that are used to group packages together:
\begin{verbatim}
DESCRIPTION = “My Package Group”
LICENSE = “MIT”
LIC_FILES_CHECKSUM = “file://<licfile>;md5=<chksum>
inherit packagegroup
PROVIDES = “${PACKAGES}”
PACKAGES = “packagegroup-mypkg-apps packagegroup-mypkg-tools”
RDEPENDS_packagegroup-mypkg-apps = “sqlite3 python-core python-sqlite3”
RDEPENDS_pacakgegroup-mypkg-tools = “sudo gzip tar”
\end{verbatim}
it can be used, to simplify image definitions
\end{frame}

\begin{frame}[fragile]
\frametitle{minimal distribution}
distros are defined in a layer, e.g.

meta-linutronix/conf/distro/mini.conf:
\begin{verbatim}
meta-mini/conf/distro/mini.conf:
DISTRO = "mini"
DISTRO_NAME = "mini 1.0 (for foo devices)"
DISTRO_VERSION = "1.0"
DISTRO_CODENAME = "mal"
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\begin{verbatim}
SDK_VENDOR = "-linutronix"
SDK_VERSION := "${@'${DISTRO_VERSION}'}"
SDK_NAME = "${DISTRO}-${TCLIBC}-${SDK_ARCH}-${IMAGE_BASENAME}-${TUNE_PKGARCH}"
SDKPATH = "/opt/${DISTRO}/${SDK_VERSION}"
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\begin{verbatim}
MAINTAINER = "Manuel Traut <manut@linutronix.de>"
TARGET_VENDOR = "-linutronix"
LOCALCONF_VERSION = "1"
LAYER_CONF_VERSION ?= "6"
DISTRO_FEATURES ?= "opengl ${DISTRO_FEATURES_DEFAULT} ${DISTRO_FEATURES_LIBC}"
DISTRO_FEATURES_append = " systemd"
TCLIBCAPPEND = ""
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\begin{verbatim}
PREMIRRORS ??= "\
bzr://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \n \
cvs://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \n \
git://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \n \
hg://.*/.*    http://downloads.yoctoproject.org/mirror/sources/ \n \
osc://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \n \
p4://.*/.*    http://downloads.yoctoproject.org/mirror/sources/ \n \
svk://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \n \
svn://.*/.*   http://downloads.yoctoproject.org/mirror/sources/ \n"
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\begin{verbatim}
MIRRORS =+ "\
ftp://.*/.*      http://downloads.yoctoproject.org/mirror/sources/ \n \
http://.*/.*     http://downloads.yoctoproject.org/mirror/sources/ \n \
https://.*/.*    http://downloads.yoctoproject.org/mirror/sources/ \n"

CONNECTIVITY_CHECK_URIS ?= " \
             https://eula-downloads.yoctoproject.org/index.php \
             http://bugzilla.yoctoproject.org/report.cgi"
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\begin{verbatim}
SANITY_TESTED_DISTROS ?= " \
            Ubuntu-14.04 \n \
            Debian-7.0 \n \
            Debian-7.1 \n \
            Debian-7.2 \n \
            Debian-7.3 \n \
            Debian-7.4 \n \
            "

BB_SIGNATURE_HANDLER ?= 'OEBasicHash'
OELAYOUT_ABI = "8"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{add distro to git repo}
\begin{verbatim}
poky/meta-mini % git add conf/distro/mini.conf
poky/meta-mini % git commit -sam 'add mini distro'
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{use mini distro}
edit DISTRO var in conf/local.conf
\begin{verbatim}
DISTRO ?= "mini"
\end{verbatim}
\end{frame}

\subsection{Creating images}
\begin{frame}[fragile]
\frametitle{based on core-image class}
build image with ssh support
\begin{verbatim}
poky/build-ti % bitbake-layers show-recipes | grep ssh
Parsing recipes..done.
libssh:
openssh:
packagegroup-core-ssh-dropbear:
packagegroup-core-ssh-openssh:
\end{verbatim}
\pause
create the file
'meta-mini/recipes-bsp/mini-image/mini-image.bb'
\begin{verbatim}
IMAGE_INSTALL += "openssh"
inherit core-image
\end{verbatim}
\pause
to build the image, use:
\begin{verbatim}
poky/build-ti % bitbake mini-image
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{first errors and warnings}
\begin{verbatim}
recommended that you use a tested distribution.
ERROR:  OE-core's config sanity checker detected a potential
        misconfiguration. Either fix the cause of this error or
        at your own risk disable the checker see sanity.conf).
Following is the list of potential problems / advisories:

libsdl-native is set to be ASSUME_PROVIDED but sdl-config can't be
found in PATH. Please either install it, or configure qemu not to
require sdl.
ERROR: Execution of event handler 'check_sanity_eventhandler' failed
ERROR: Command execution failed: Exited with 1
\end{verbatim}
\end{frame}
\begin{frame}[fragile]

	\frametitle{disable sdl support in qemu}
edit conf/local.conf:
\begin{verbatim}
# PACKAGECONFIG_pn-qemu-native = "sdl"
# PACKAGECONFIG_pn-nativesdk-qemu = "sdl"
# ASSUME_PROVIDED += "libsdl-native"
\end{verbatim}
\end{frame}

\subsection{Machines}
\begin{frame}[fragile]
\frametitle{create a beaglebone-black machine config}
create the file 'meta-mini/conf/machine/beaglebone-black.conf':
\begin{verbatim}
#@TYPE: Machine
#@NAME: BeagleBone Black
#@DESCRIPTION: Machine configuration for the http://beagleboard.org/bone board 

require conf/machine/include/ti33x.inc

IMAGE_FSTYPES += "ext3 tar.gz"
EXTRA_IMAGEDEPENDS += "u-boot"
SERIAL_CONSOLE = "115200 ttyO0"

SDCARD_ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"

SPL_BINARY = "MLO"
UBOOT_SUFFIX = "img"
UBOOT_MACHINE = "am335x_boneblack_config"
UBOOT_ENTRYPOINT = "0x80008000"
UBOOT_LOADADDRESS = "0x80008000"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{user and group configuration}
use this in an image recipe:
\begin{verbatim}
inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd -p '' tester; \
    groupadd developers; \
    userdel nobody; \
    groupdel -g video; \
    groupmod -g 1020 developers; \
    usermod -s /bin/sh tester; \
    "
\end{verbatim}
or the useradd class, for an example see useradd-example.bb
\end{frame}

\begin{frame}[fragile]
\frametitle{external sources}
e.g. for a heavily customized kernel
\begin{itemize}
\item kernel source directory on the development machine
\pause
\item inherit externalsrc class
\pause
\item set EXTERNALSRC variable to point to your external source code
\end{itemize}

this local.conf extension:
\begin{verbatim}
INHERIT += "externalsrc"
EXTERNALSRC_pn-myrecipe = "/some/path/to/your/source/tree"
\end{verbatim}
overrides the SOURCE\_URI of pn-myrecipe.bb
\end{frame}

\begin{frame}[fragile]
\frametitle{blacklist packages}
To blacklist a package, inherit the blacklist.bbclass globally and set
PNBLACKLIST for each recipe you wish to blacklist.


Specify the PN value as a variable flag (varflag) and provide a reason,
which is reported, if the package is requested to be built as the value:
\begin{verbatim}
INHERIT += "blacklist"
PNBLACKLIST[exoticware] = "Not supported by our organization."
\end{verbatim}
\end{frame}

\subsection{Writing recipes}
\begin{frame}[fragile]
\frametitle{adding a kernel}
create the file 'meta-mini/recipes-bsp/linux-vanilla/linux-vanilla\_3.16.1.bb':
\begin{verbatim}
SECTION = "kernel"
DESCRIPTION = "Linux vanilla kernel"
LICENSE = "GPLv2"
KERNEL_IMAGETYPE = "uImage"

inherit kernel
require recipes-kernel/linux/linux-dtb.inc
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{adding a kernel \#2}
\begin{verbatim}
COMPATILBE_MACHINE_beaglebone-black = "beaglebone-black"
KERNEL_DEVICETREE_beaglebone-black = \
"arch/arm/boot/dts/am335x-boneblack.dts"

S = "${WORKDIR}/linux-${PV}"
https://www.kernel.org/pub/linux/kernel/v3.x/linux-${PV}.tar.xz \
file://defconfig \
"

SRC_URI[md5sum] = "???"
SRC_URI[sha256sum] = "???"

KERNEL_EXTRA_ARGS += "LOADADDR=${UBOOT_ENTRYPOINT}"

do_configure_prepend() {
	cp '${WORKDIR}/defconfig' '${S}/.config'
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{adding a defconfig}
copy your .config file to
'meta-mini/recipes-bsp/linux-vanilla/files/beaglebone-black/defconfig'
\end{frame}

\begin{frame}[fragile]
\frametitle{using a specific kernel}
add
\begin{verbatim}
PREFERRED_PROVIDER_virtual/kernel = "linux-vanilla"
\end{verbatim}
to meta-mini/machine/beaglebone-black.conf
\end{frame}

\begin{frame}[fragile]
\frametitle{Providers}
\begin{verbatim}
--8<- meta/classos/kernel.bbclass --
PROVIDES += "virtual/kernel"
--8<--------------------------------
\end{verbatim}

PREFERRED\_PROVIDER\_virtual/kernel = "linux-yocto"


\pause
\vspace{2em}
also a preferred version can be set:

PREFERRED\_VERSION\_virtual/kernel = "3.18.5"
\end{frame}

\begin{frame}
\frametitle{Preferences}
\begin{itemize}
\item by default, files have a preference of "0"
\pause
\item setting DEFAULT\_PREFERENCE to "-1" makes the recipe unlikely to be used
	unless it is explicitly referenced.
\pause
\item setting DEFAULT\_PREFERENCE to "1" makes it likely the recipe is used
\pause
\item PREFERRED\_VERSION overrides any DEFAULT\_PREFERENCE setting
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{using a specific bootloader}
add
\begin{verbatim}
PREFERRED_PROVIDER_virtual/bootloader = "u-boot"
PREFERRED_PROVIDER_virtual/u-boot = "u-boot"
\end{verbatim}
to meta-mini/machine/beaglebone-black.conf
\end{frame}

\subsection{generate a sdcard image}
\begin{frame}[fragile]
\frametitle{sdcard generation}
create the file: 'meta-mini/classes/image\_sdcard.bbclass':
\begin{verbatim}
inherit image_types

IMAGE_BOOTLOADER ?= "u-boot"

# Handle u-boot suffixes
UBOOT_SUFFIX ?= "bin"
UBOOT_PADDING ?= "0"
UBOOT_SUFFIX_SDCARD ?= "${UBOOT_SUFFIX}"

# Linux bootstream
IMAGE_DEPENDS_linux.sb = "virtual/kernel:do_deploy"

# Boot partition volume id
BOOTDD_VOLUME_ID ?= "Boot ${MACHINE}"
# Boot partition size [in KiB]
BOOT_SPACE ?= "8192"
# Set alignment to 4MB [in KiB]
IMAGE_ROOTFS_ALIGNMENT = "4096"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{sdcard generation \#2}
\begin{verbatim}
IMAGE_DEPENDS_sdcard = "parted-native:do_populate_sysroot \
  dosfstools-native:do_populate_sysroot \
  mtools-native:do_populate_sysroot \
  virtual/kernel:do_deploy \
  ${@d.getVar('IMAGE_BOOTLOADER', True) and \
    'd.getVar('IMAGE_BOOTLOADER', True) + ':do_deploy' or ''}"

SDCARD = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.sdcard"
SDCARD_GENERATION_COMMAND_ti33x = "generate_ti_sdcard"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{sdcard generation \#3}
\begin{verbatim}
generate_ti_sdcard () {
  parted -s ${SDCARD} mklabel msdos

  parted -s ${SDCARD} unit KiB mkpart primary fat32 \
   ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ \
   ${BOOT_SPACE_ALIGNED})

  parted -s ${SDCARD} unit KiB mkpart primary \
   $(expr  ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) \
   $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ \
     $ROOTFS_SIZE)

  parted -s ${SDCARD} set 1 boot on
  parted ${SDCARD} print

  BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
    | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 1024 }')

  mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C \
    ${WORKDIR}/boot.img $BOOT_BLOCKS
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{sdcard generation \#4}
\begin{verbatim}
  # copy files to /boot
  mcopy -i ${WORKDIR}/boot.img -s \
    ${DEPLOY_DIR_IMAGE}/MLO-${MACHINE} ::/MLO
  mcopy -i ${WORKDIR}/boot.img -s \
    ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.img ::/u-boot.img
  mmd -i ${WORKDIR}/boot.img  ::/boot
  mcopy -i ${WORKDIR}/boot.img -s \
    ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin \
    ::/boot/${KERNEL_IMAGETYPE}
  mcopy -i ${WORKDIR}/boot.img -s \
    ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-am335x-boneblack.dtb \
    ::/boot/am335x-boneblack.dtb
  mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/uEnv.txt \
    ::/uEnv.txt

  # Burn Partition
  dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 \
    bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
  sync
  dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 \
    bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + \
         ${IMAGE_ROOTFS_ALIGNMENT} \* 1024)
  sync
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{sdcard generation \#5}
\begin{verbatim}
IMAGE_CMD_sdcard () {
  if [ -z "${SDCARD_ROOTFS}" ]; then
    bberror "SDCARD_ROOTFS is undefined."
    exit 1
  fi

  # Align boot partition and calculate total SD card image size
  BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
  BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - \
    ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
  SDCARD_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + \
    ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT})

  # Initialize a sparse file
  dd if=/dev/zero of=${SDCARD} bs=1 count=0 \
    seek=$(expr 1024 \* ${SDCARD_SIZE})

  ${SDCARD_GENERATION_COMMAND}
}

# The sdcard requires the rootfs filesystem to be built before using
# it so we must make this dependency explicit.
IMAGE_TYPEDEP_sdcard = "${@d.getVar('SDCARD_ROOTFS', 1).split('.')[-1]}"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{configure machine to use sdcard imagetype}
add the following lines to 'meta-mini/conf/machine/beaglebone-black.conf':
\begin{verbatim}
IMAGE_CLASSES += "image_sdcard"
SDCARD_ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
IMAGE_FSTYPES += "sdcard"
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{adding an own application}
\begin{itemize}
	\item recipe already available? check http://layers.openembedded.org
\pause
	\item look for a similar recipe
\pause
	\item proper bbclass available?
\end{itemize}
on the next slides, we have a look what is useful for very simple applications,
autotools and cmake based projects and qt applications.
\end{frame}

\begin{frame}[fragile]
\frametitle{as simple as posible}
use this folder layout
\begin{verbatim}
poky/meta-mini/recipes-hello % tree
hello
├── files
│   └── hello.c
└── hello.bb
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{as simple as posible \#2}
this is the content of hello.bb
\begin{verbatim}
DESCRIPTION = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT; \
  md5=0835ade698e0bcf8506ecda2f7b4f302"
PR = "r0"
SRC_URI = "file://hello.c"
S = "${WORKDIR}"

do_compile() {
  ${CC} hello.c -o hello
}

do_install() {
  install -d ${D}${bindir}
  install -m 0755 hello ${D}${bindir}
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{autools based project}
\begin{verbatim}
├── autohello_1.0.bb
└── files
    └── autohello-1.0.tar.gz
\end{verbatim}
\pause
\begin{verbatim}
DESCRIPTION = "GNU Helloworld application"
SECTION = "examples"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
PR = "r0"
SRC_URI = "file://autohello-${PV}.tar.gz"
SRC_URI[md5sum] = "4bfc9bed4d5d67a266d93e99e5883211"
inherit autotools
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{cmake based project}
\begin{verbatim}
.
├── files
│   └── hellocm-0.1.tar.bz2
└── hellocm_0.1.bb
\end{verbatim}
\pause
\begin{verbatim}
DESCRIPTION = "hellocm cmake example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SECTION = "examples"
SRC_URI = "file://${BPN}-${PV}.tar.bz2"
inherit cmake

#export EXTRA_OECMAKE = '-DBLUBB="bla"

FILES_{PN} = "${bindir}/hellocm"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{qt application}
\begin{verbatim}
├── files
│   └── helloqt-1.0.tar.bz2
└── helloqt_1.0.bb
\end{verbatim}
\pause
\begin{verbatim}
DESCRIPTION = "helloqt QT example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SECTION = "examples"
SRC_URI = "file://${BPN}-${PV}.tar.bz2"
inherit qt4e
PR = "r4"
do_install() {
        install -d ${D}${bindir}
        install -m 0755 helloqt ${D}${bindir}
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{adding a bootscript}
\begin{itemize}
	\item add 'systemd' to DISTRO\_FEATURES
\pause
	\item inherit from systemd.bbclass
\pause
	\item your package needs to set SYSTEMD\_SERVICE variable; e.g.
		\begin{verbatim}
SYSTEMD_SERVICE_${PN} = "connman.service"
		\end{verbatim}
\pause
	\item to disable the service, set  SYSTEMD\_AUTO\_ENABLE to 'disable'
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{user and group configuration}
use this in an image recipe:
\begin{verbatim}
inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd -p '' tester; \
    groupadd developers; \
    userdel nobody; \
    groupdel -g video; \
    groupmod -g 1020 developers; \
    usermod -s /bin/sh tester; \
    "
\end{verbatim}
or the useradd class, for an example see useradd-example.bb
\end{frame}

\begin{frame}[fragile]
\frametitle{external sources}
e.g. for a heavily customized kernel
\begin{itemize}
\item kernel source directory on the development machine
\item inherit externalsrc class
\item set EXTERNALSRC variable to point to your external source code
\end{itemize}

this local.conf extension:
\begin{verbatim}
INHERIT += "externalsrc"
EXTERNALSRC_pn-myrecipe = "/some/path/to/your/source/tree"
\end{verbatim}
overrides the SOURCE\_URI of pn-myrecipe.bb
\end{frame}

\begin{frame}[fragile]
\frametitle{blacklist packages}
To blacklist a package, inherit the blacklist.bbclass globally and set
PNBLACKLIST for each recipe you wish to blacklist.


Specify the PN value as a variable flag (varflag) and provide a reason,
which is reported, if the package is requested to be built as the value:
\begin{verbatim}
INHERIT += "blacklist"
PNBLACKLIST[exoticware] = "Not supported by our organization."
\end{verbatim}

\subsection{Resume}
\begin{frame}
	\begin{itemize}
		\item Yocto is a huge collection of tools
		\pause
		\item Bitbake can be used to create Images
		\pause
		\item The quality of the Images depend on the maintainance of the Layers
		\pause
		\item Only build your own distribution if you really need to!
	\end{itemize}
\end{frame}

\input{tailpres}