LoginSignup
5
6

More than 5 years have passed since last update.

Yocto(sumo2.5)でraspberry pi2上で動くイメージを作成する

Posted at

これまでYoctoを使う側であったが、今回環境の構築からカスタマイズに関する知識を仕入れたくなり、Yocto(2.5 sumo)をいじった。そのときのことを備忘のため残す。

良い資料

岩松氏のYocto Projectハンズオンが良文書だった。これにならい、自宅に転がっていたRaspberry Pi2上で動かすイメージをYocto最新版(sumo)を使って作成した。(いまさらRaspberry Pi2?というのもあるが・・・)
このとき、Yoctoの仕様変化などの事情により困った部分をメモする。なお、ほぼ間違いなく、記載当時は上記スライドの記載内容は正しかったと思われる。よって、この文書は「マサカリ」でなく、個人の備忘録である。念のため。

スライドP38

「完了するとレイヤー名にmeta-というプリフィックスが付加された・・・」とあるが、sumoでは付加されないようだ。
よって、レイヤー名にはmeta-プリフィックスを明示的につける。

そして、そもそも、yocto-layerがいない・・・。ネットで調べてみると、sumo以降ではいくつかのコマンドが使えなくなるそうで、このことに起因すると思われる。
先のWeb Pageに従い、bitbake-layersコマンドを用いる。

fyoshida@ubuntu:~/rpi/poky$ bitbake-layers create-layer meta-practice1
NOTE: Starting bitbake server...
Add your new layer with 'bitbake-layers add-layer meta-practice1'
fyoshida@ubuntu:~/rpi/poky$ ls
LICENSE     README.hardware  README.qemu  bitbake-cookerdaemon.log  documentation  meta-poky       meta-raspberrypi  meta-skeleton   oe-init-build-env
README.LSB  README.poky      bitbake      build                     meta           meta-practice1  meta-selftest     meta-yocto-bsp  scripts

スライドp45

複数のWeb Pageでは「直接conf/bblayers.confをいじるのはよくない」とのこと(出典は失念)。
また、公式のドキュメント3.1.8. Creating a General Layer Using the bitbake-layers Scriptおよび3.1.9. Adding a Layer Using the bitbake-layers Scriptでもconf/bblayers.confへの変更をコマンドを使って実践している。よって、公式ドキュメントにならい、buildディレクトリで以下のコマンドを実行する。

bitbake-layers add-layer 追加したいレイヤのディレクトリパス(レイヤ名ではない)

実行例

fyoshida@ubuntu:~/rpi/poky/build$ bitbake-layers add-layer ../meta-practice1
NOTE: Starting bitbake server...
WARNING: Layer meta-practice1 should set LAYERSERIES_COMPAT_meta-practice1 in its conf/layer.conf file to list the core layer names it is compatible with.
Parsing recipes: 100% |#######################################################################################################################################################| Time: 0:00:44
Parsing of 839 .bb files complete (0 cached, 839 parsed). 1307 targets, 69 skipped, 0 masked, 0 errors.

Summary: There was 1 WARNING message shown.

実際にレイヤーが作成されたか、確認を行う。

fyoshida@ubuntu:~/rpi/poky/build$ bitbake-layers show-layer
NOTE: Starting bitbake server...
usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ...
bitbake-layers: error: argument <subcommand>: invalid choice: 'show-layer' (choose from 'add-layer', 'remove-layer', 'flatten', 'show-layers', 'show-overlayed', 'show-recipes', 'show-appends', 'show-cross-depends', 'layerindex-fetch', 'layerindex-show-depends', 'create-layer')
fyoshida@ubuntu:~/rpi/poky/build$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer                 path                                      priority
==========================================================================
meta                  /home/fyoshida/rpi/poky/meta              5
meta-poky             /home/fyoshida/rpi/poky/meta-poky         5
meta-yocto-bsp        /home/fyoshida/rpi/poky/meta-yocto-bsp    5
meta-raspberrypi      /home/fyoshida/rpi/poky/meta-raspberrypi  9
meta-practice1        /home/fyoshida/rpi/poky/meta-practice1    6
fyoshida@ubuntu:~/rpi/poky/build$ bitbake-layers show-appends
NOTE: Starting bitbake server...
WARNING: Layer meta-practice1 should set LAYERSERIES_COMPAT_meta-practice1 in its conf/layer.conf file to list the core layer names it is compatible with.
WARNING: Layer meta-practice1 should set LAYERSERIES_COMPAT_meta-practice1 in its conf/layer.conf file to list the core layer names it is compatible with.
Loading cache: 100% |#########################################################################################################################################################| Time: 0:00:00
Loaded 1307 entries from dependency cache.

Summary: There were 2 WARNING messages shown.
=== Appended recipes ===
bluez5_5.48.bb:
  /home/fyoshida/rpi/poky/meta-raspberrypi/recipes-connectivity/bluez5/bluez5_%.bbappend
busybox_1.27.2.bb:
  /home/fyoshida/rpi/poky/meta-poky/recipes-core/busybox/busybox_%.bbappend
core-image-minimal.bb:
  /home/fyoshida/rpi/poky/meta-practice1/recipes-core/images/core-image-minimal.bbappend
省略

なお、上コンソールログに現れるWarningはこのページを参照。あとは、スライド通りビルドすればうまくいくはずである。

core-image-minimalにPython3を追加する

Raspberry Pi2上でPython3を動かしたいので、イメージにPython3を含める。
poky/meta/recipes-devtools/python にpython3用のbbファイルがある。

fyoshida@ubuntu:~/rpi/poky/meta/recipes-devtools/python$ ls
python                   python-scons-native_3.0.1.bb  python3-dbus_1.2.6.bb     python3-pip_9.0.2.bb
python-async.inc         python-scons_3.0.1.bb         python3-docutils_0.14.bb  python3-pycairo_1.15.6.bb
python-git.inc           python-setuptools.inc         python3-git_2.1.8.bb      python3-pygobject_3.28.1.bb
python-gitdb.inc         python-setuptools_39.0.0.bb   python3-gitdb_2.0.3.bb    python3-setuptools_39.0.0.bb
python-mako.inc          python-six.inc                python3-iniparse          python3-six_1.11.0.bb
python-native            python-smmap.inc              python3-iniparse_0.4.bb   python3-smmap_0.9.0.bb
python-native_2.7.14.bb  python.inc                    python3-mako_1.0.7.bb     python3_3.5.5.bb
python-nose.inc          python3                       python3-native_3.5.5.bb   python_2.7.14.bb
python-nose_1.3.7.bb     python3-async_0.6.2.bb        python3-nose_1.3.7.bb

岩松氏のスライドでは、dropbearを追加するのにmeta-practice1/recipes-core/images/core-image-minimal.bbappendを作り、そこに追加する「パッケージ」を指定した。
今回は、meta/recipes-devtoolsにあるパッケージをcore-image-minimalに追加するのだから、meta-practice1/recipes-devtools/images/core-image-minimal.bbappendを作り、そこに追加するパッケージ(Python3)を指定する。

meta-practice1/recipes-devtools/images/core-image-minimal.bbappend
IMAGE_INSTALL += "python3"

これでbitbake core-image-minimalを実施する。起動すると、確かにpython3が追加されている。

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6