以下の内容はhttps://mickey-happygolucky.hatenablog.com/entry/2025/11/30/161138より取得しました。


YoctoProject bitbake-setup環境でmeta-raspberrypi

はじめに

以下の続き

bitbake-setupを使用した環境で、サードパーティのレイヤを追加する手順を試す。

今回はmeta-raspberrypiを使用する。

環境構築

作業ディレクト

~/yocto/poky-bsに作成したTop Directoryに、新たにSetupを追加する。

まずは作業ディレクトリに移動する。

$ cd ~/yocto/poky-bs

Setupの作成

"bitbake-setup init"でラズベリーパイ用のSetupを作成する。

$ ./bitbake/bin/bitbake-setup init \
--non-interactive poky-whinlatter poky distro/poky machine/qemuarm64 \
--setup-dir-name poky-whinlatter-rpi

--non-interactiveオプション

--non-interactiveオプションを使用すると、以下のような感じで、答えを記述しておくことでプロンプトをスキップすることができる。(試した感じでは順番はどうでも良さそう。)

--non-interactive <Generic Configuration> <bitbake configuration> <distro> <machine>

--setup-dir-name

--setup-dir-nameオプションを使用すると、Setupディレクトリの名前を明示的に指定することができる。

bitbake-setupのデフォルトのオプションでは、以下の順番で評価し同じものがある場合は次のものを提案してくる。

  1. 簡易名(Generic Configuraionと同じ)
  2. フルネーム(Generic Configuration + bitbake configuration + distro + machine )
  3. エラー終了

フルネームの例は「poky-whinlatter-poky-distro_poky-machine_qemuarm64」となる。 OE_FRAGMENTSの部分(MACHINEやDISTRO)がSetup名に入ると後から変更したときに整合性が取れなくなるので開発中では不便。

特に今回はMACHINEを書き換える前提の作業なのでフルネームにはしたくない。 そのため、--setup-dir-nameで「poky-whinlatter-rpi」を指定する。

BitBakeの環境設定

Setupに作成されたinit-build-envでBitBakeの環境を設定する。

$ source bitbake-builds/poky-whinlatter-rpi/build/init-build-env

meta-raspberrypiの追加

この時点でbitbake-layersなどのコマンドが使用可能になるので以下のようにmeta-raspberrypiを追加する。

$ bitbake-layers layerindex-fetch meta-raspberrypi -f ../layers

-f ../layersでSetup中のlayersディレクトリにダウンロード先を指定することがポイント

ブランチの問題

執筆時点(2025-11-30)ではmeta-raspberrypiにwhinlatterブランチが存在しないため以下のようなエラーになる。

Traceback (most recent call last):
  File "/home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/bitbake/bin/bitbake-layers", line 109, in <module>
    ret = main()
  File "/home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/bitbake/bin/bitbake-layers", line 104, in main
    return args.func(args)
  File "/home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/bitbake/lib/bblayers/layerindex.py", line 138, in do_layerindex_fetch
    remoteIndex.load_layerindex(remoteurl)
  File "/home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/bitbake/lib/layerindexlib/__init__.py", line 219, in load_layerindex
    indexEnt = plugin.load_index(indexURI, load)
  File "/home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/bitbake/lib/layerindexlib/restapi.py", line 45, in load_index
    return self.load_index_web(up, url, load)
  File "/home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/bitbake/lib/layerindexlib/restapi.py", line 216, in load_index_web
    logger.debug("No valid branches (%s) found at url %s." % (branch, url))
UnboundLocalError: local variable 'branch' referenced before assignment

これを回避するには-b masterとしてmasterブランチを指定する必要がある。 ただしmasterブランチを指定すると、依存関係の問題で何故かとても古い互換性のないレイヤを追加しようとするため 以下のような別のエラーが発生する。

ERROR: Variable BB_ENV_EXTRAWHITE has been renamed to BB_ENV_PASSTHROUGH_ADDITIONS (file: /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/openembedded-core/meta-yocto-kernel-extras/meta-kernel-dev/conf/layer.conf line: 12)
ERROR: Variable BB_DANGLINGAPPENDS_WARNONLY support for the variable was removed as it unconditionally affects all layers (file: /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi-test/layers/openembedded-core/meta-yocto-kernel-extras/meta-kernel-dev/conf/layer.conf line: 3)
ERROR: Parse failure with the specified layer added, exiting.

こちらのエラーはbitbake-layers add相当の処理が失敗しているだけなので、ダウンロード自体は成功している。

そのため、以下のような手順で作業すれば問題ない。

$ bitbake-layers layerindex-fetch meta-raspberrypi -f ../layers -b master
$ bitbake-layers add-layer ../layers/meta-raspberrypi

一応確認する。

$ bitbake-layers show-layers
... (snip) ...
layer                 path                                                                    priority
========================================================================================================
core                  /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi/layers/openembedded-core/meta  5
yoctobsp              /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi/layers/meta-yocto/meta-yocto-bsp  5
yocto                 /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi/layers/meta-yocto/meta-poky  5
raspberrypi           /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter-rpi/layers/meta-raspberrypi  9

これで問題ない。

MACHINEの変更

MACHINEをraspberrypi4-64に設定する。

$ bitbake-config-build enable-fragment machine/raspberrypi4-64

確認する。

$ bitbake -e | grep '^MACHINE='
MACHINE="raspberrypi4-64"

これでビルドが可能となる。

ビルド実行

$ bitbake core-image-minimal

site.confについて

bitbake-setupで作成されたsite.confにはDL_DIRの指定がされている。 つまり、すべてのSetupが自動的に同じダウンロードキャッシュを参照するようになっている。 これまでこの設定は手動で行う必要があったので地味に便利。

# This file is intended for build host-specific bitbake settings

# Where to place downloads
#
# During a first build the system will download many different source code
# tarballs from various upstream projects. This can take a while, particularly
# if your network connection is slow. These are all stored in DL_DIR. When
# wiping and rebuilding you can preserve this directory to speed up this part of
# subsequent builds. This directory is safe to share between multiple builds on
# the same machine too.
DL_DIR = "/home/mickey/yocto/poky-bs/bitbake-builds/.bitbake-setup-downloads"

まとめ

bitbake-setup環境でサードパーティのレイヤを追加する手順を試した。 以下の点が地味な便利ポイント

  • 最低限の手順ではlocal.confを一度も参照、変更しなくて良い
  • Setup間のDL_DIRの共有も意識せずに行われる
  • Setupに関して、削除しても新たに作成することが簡単

bitbake-setupは慣れれば便利だと思う。




以上の内容はhttps://mickey-happygolucky.hatenablog.com/entry/2025/11/30/161138より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14