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


YoctoProject bitbake-setupを試す

はじめに

Yocto Project Pokyリポジトリのmasterブランチの更新停止でPokyリポジトリのmasterブランチの更新が停止された後のPokyのセットアップ手順のうち下記について試す。

b) use the new bitbake-setup

     https://docs.yoctoproject.org/bitbake/dev/bitbake-user-manual/bitbake-user-manual-environment-setup.html

環境作成

作業ディレクト

~/yocto/poky-bsを作業ディレクトリとする。

$ mkdir -p ~/yocto/poky-bs
$ cd ~/yocto/poky-bs

リポジトリの取得

https://docs.yoctoproject.org/bitbake/dev/bitbake-user-manual/bitbake-user-manual-environment-setup.html の手順に従う。

bitbakeリポジトリを取得する。

$ git clone https://git.openembedded.org/bitbake

環境の設定

まずbitbake-setup initを実行する。

$ ./bitbake/bin/bitbake-setup init

以下のようなプロンプトが表示される。

Bitbake-setup is using /home/mickey/yocto/poky-bs/bitbake-builds as top directory.

/home/mickey/yocto/poky-bs/bitbake-builds looks like a new top directory. If you would like to use a different directory, answer "n" below and either:
        1) Change the default bitbake-setup settings:
                bitbake-setup settings set default top-level-prefix <PATH>
                bitbake-setup settings set default top-level-name <NAME>
        2) Pass one or more options on the command line to change the top level directory in that invocation only:
                bitbake-setup --setting default top-dir-prefix <PATH> ...
                bitbake-setup --setting default top-dir-name <NAME> ...

A common site.conf file will be created, please check it is correct before running builds
    /home/mickey/yocto/poky-bs/bitbake-builds/site.conf

Proceed? (y/N):

"y"としてEnter。コンフィグレーション選択のプロンプトが表示される。 (先週試したときはoe-nodistro-masterとpoky-masterしかなかったが増えてる。)

Available configurations:
1. oe-nodistro-master   OpenEmbedded - 'nodistro' basic configuration
2. poky-whinlatter      Poky - The Yocto Project testing distribution configurations and hardware test platforms, release 5.3 'whinlatter' (supported until 2026-05-31)
3. poky-master  Poky - The Yocto Project testing distribution configurations and hardware test platforms
4. oe-nodistro-whinlatter       OpenEmbedded - 'nodistro' basic configuration, release 5.3 'whinlatter' (supported until 2026-05-31)

Please select one of the above configurations by its number:

poky-whinlatter(YP5.3)を試したいので"2"としてEnterする。 bitbakeのコンフィグレーション選択のプロンプトが表示される。

Available bitbake configurations:
1. poky Poky - The Yocto Project testing distribution
2. poky-with-sstate     Poky - The Yocto Project testing distribution with internet sstate acceleration. Use with caution as it requires a completely robust local network with sufficient bandwidth.

Please select one of the above bitbake configurations by its number:

sstate無しのpokyを選択するため"1"としてEnter。 マシン選択のプロンプトが表示される。

Target machines:
1. machine/qemux86-64
2. machine/qemuarm64
3. machine/qemuriscv64
4. machine/genericarm64
5. machine/genericx86-64

Please select one of the above options by its number:

qemuarm64を選択したいので"2"としてEnter。 ディストリビューション選択のプロンプトが表示される。

Distribution configuration variants:
1. distro/poky
2. distro/poky-altcfg
3. distro/poky-tiny

Please select one of the above options by its number:

ノーマルのpokyを選択したいので"1"としてEnter。 セットアップディレクトリ名を訪ねてくる。

Run 'bitbake-setup init --non-interactive poky-whinlatter poky distro/poky machine/qemuarm64' to select this configuration non-interactively.

Enter setup directory name: [poky-whinlatter]

デフォルトで問題ないのでこのままEnter。(先週試した時は"poky-master-poky-distro_poky-machine_qemuarm64"とかすごい名前だった) 最終確認のプロンプトが表示される。

Initializing a setup directory in
    /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter
Continue? (y/N):

このままで良いので"y"としてEnterを押す。

Pokyを構成するためのレイヤのダウンロードが開始される。

Fetching layer/tool repositories into /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter/layers
    bitbake
    openembedded-core
    meta-yocto
    yocto-docs

セットアップが完了すると、必要な情報を表示してツールは終了する。

Setting up bitbake configuration in
    /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter/build

This bitbake configuration provides:
    Poky - The Yocto Project testing distribution

Usage instructions and additional information are in
     /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter/build/README

To run builds, source the environment using
    . /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter/build/init-build-env

Run 'bitbake-config-build enable-fragment <fragment-name>' to enable additional fragments or replace built-in ones (e.g. machine/<name> or distro/<name> to change MACHINE or DISTRO).

The bitbake configuration files (local.conf, bblayers.conf and more) can be found in
    /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter/build/conf

ビルド

BitBakeの環境設定

bitbake-setupを使用する場合は従来のoe-init-build-envではなく、作成された環境のbuildディレクトリにあるinit-build-envを実行してBitBakeの環境設定を行う。

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

ビルド設定の確認

MACHINEとDISTROの設定を確認する。

$ bitbake -e | grep '^MACHINE='
MACHINE="qemuarm64"
$ bitbake -e | grep '^DISTRO='
DISTRO="poky"

bitbake-setupのプロンプトで選択したとおりに設定されている。

ビルド

試しにcore-image-minimalをビルドする。

$ bitbake core-image-minimal

従来どおりビルドができる。

ビルド設定の変更

後からbitbake-setupで選択したMACHINEを変更したいケースは普通にあると思う。

local.confで変更する場合

試しにconf/local.confでMACHINEの設定を変更してみる。

$ echo 'MACHINE = "qemuriscv64"' >> conf/local.conf

一旦dry-runしてみる。すると下記のようなエラーが表示される。

$ bitbake -n
ERROR: A builtin fragment 'machine/qemuarm64' is used while MACHINE has already got an assignment.
Please either disable the fragment or remove the value assignment.
To disable the fragment, use 'bitbake-config-build disable-fragment machine/qemuarm64'.

このメッセージを要約すると以下のようになる。

  1. fragmentでmachine/qemuarm64が設定されているのでMACHINEは設定済み
  2. local.confの値を有効化したい場合はfragmentを無効化する必要がある
  3. fragmentの無効化はbitbake-config-buildコマンドで行う

以下のコマンドでfragmentを無効化してみる。

$ bitbake-config-build disable-fragment machine/qemuarm64
Fragment machine/qemuarm64 removed from /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter/build/conf/toolcfg.conf.

効果を確認する。

$ bitbake -n
Nothing to do.  Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.

エラーは出なくなったのでMACHINEの設定を確認する。

$ bitbake -e | grep '^MACHINE='
MACHINE="qemuriscv64"

これで変更できた。

OE_FRAGMENTSで変更する場合

bitbake-setupで作成した環境では初期状態でDISTROMACHINEについては新たに導入されたOE_FRAGMENTSで管理されている。 local.confで変更しようとした際にエラーが発生したのもこの仕組みと競合するからとなる。

OE_FRAGMENTSはconf/toolcfg.confで以下のように設定されている。

# Automated config file controlled by tools
#
# Run 'bitbake-config-build enable-fragment <fragment-name>' to enable additional fragments
# or replace built-in ones (e.g. machine/<name> or distro/<name> to change MACHINE or DISTRO).

OE_FRAGMENTS += "distro/poky machine/qemuarm64"

これはbitbake.confの以下の設定によりdistro/DISTROに、machine/MACHINEマッピングされるようになっている。

OE_FRAGMENTS_BUILTIN ?= "machine:MACHINE distro:DISTRO"

そのため以下の設定と同等の効果を持っている。

  • DISTRO = "poky"
  • MACHINE = "qemuarm64"

これを変更するにはbitbake-config-buildコマンドを使用する必要がある。

local.confやtoolcfg.confが初期状態である上で、以下のようにすることでMACHINEを変更する。

$ bitbake-config-build enable-fragment machine/qemuriscv64
NOTE: Starting bitbake server...
Fragment machine/qemuriscv64 added to /home/mickey/yocto/poky-bs/bitbake-builds/poky-whinlatter/build/conf/toolcfg.conf.

効果を確認する。

$ bitbake -e | grep '^MACHINE='
MACHINE="qemuriscv64"

これで変更できた。

まとめ

  • bitbake-setupはbitbakeリポジトリで提供されている
  • bitbake-initをすることで必要なレイヤをダウンロードし、プロンプトでビルド環境の初期設定を行う
  • bitbakeの環境設定はoe-init-build-envではなくinit-build-envを使う
  • DISTROとMACHINEはOE_FRAGMENTSで管理されている

基本的な使い方をする分にはマニュアル通りで良さそうだが、ブラックボックスが多いため、 応用するにはマニュアルをもう少しきちんと理解する必要がある。

所感としては、最初に試したバージョン(厳密は日付は忘れた)と本日(2025-11-29)のバージョンでかなりエラーメッセージや初期設定などの品質が上がっているので、もっと使いやすくなりそうな感じはしている。




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

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