はじめに
The Qt Companyが提供しているYoctoレシピを使用して
Raspberry Pi3
で動作するQt5.12.3のLinux imageと開発環境の構築をおこないます。
詳細は、以下のディレクトリ!
https://doc.qt.io/QtForDeviceCreation/qtee-custom-embedded-linux-image.html
Yoctoとは
Linuxをビルドするパッケージ管理プロジェクトです。
- Linux OS
- 使用するLinux library/module関連
をbitbakeというビルドツールを利用して、buildをおこないます。
またレシピという概念を利用して、簡単?に必要なlibrary/moduleの追加を行えます。
Yoctoのバージョン
Yoctoには、様々なバージョンがあります。
使用するレシピでどのようなバージョンを使用するか事前に調べておく事が良いです。
https://wiki.yoctoproject.org/wiki/Releases
YoctoレイヤーBoot2Qtをbuildする
Pokyの導入
Poky は Yocto Project のリファレンス・ビルド・システムです。
Poky には、BitBake、OpenEmbedded-Core、BSP (Board Support Package) といった基本的なもの含まれています。
gitリポジトリから取得する
$ cd /opt/yocto
$ git clone git://git.yoctoproject.org/poky
$ cd /opt/yocto/poky
Yoctoのバージョンをsumoにする
Yoctoのリリースページ(https://wiki.yoctoproject.org/wiki/Releases)
Boot2-Qtのページ(https://code.qt.io/cgit/yocto/meta-boot2qt.git/)
のCommit履歴を見るとQt5.12.3はsumoブランチにあり。
今回は、sumo current version 2.5.3をbanch取得する
$ git checkout -b Branch_yocto-2.5.3 yocto-2.5.3
Switched to a new branch 'Branch_yocto-2.5.3'
あらかじめBuildに使用する環境変数をセットします。
$ source oe-init-build-env
Boot2-Qtのレシピの取得
poky ディレクトリ内でmeta-boot2qtのsumo branchを取得する
https://code.qt.io/cgit/yocto/meta-boot2qt.git/
から取得
$ git clone -b sumo git://code.qt.io/yocto/meta-boot2qt.git
$ cd ./meta-boot2qt
$ git checkout -b Tag_v5.12.3 v5.12.3
Boot2-Qtのを取得
git clone した meta-boot2qt以下のb2qt-init-build-envのHelpが参考になります。
$ ./b2qt-init-build-env help
Usage: b2qt-init-build-env COMMAND [ARGS]
Initialize build environment:
b2qt-init-build-env init --device <name> [--reference <mirror path>] [--manifest-dir <dir path>] [--internal]
--device <name>: target device name or 'all'
--reference <mirror path>: path to local mirror, initialized previously with 'b2qt-init-build-env mirror'
--manifest-dir <dir path>: path to a directory containing repo manifest file(s)
--internal: fetch internal repositories, available only inside The Qt Company network.
Initialize local mirror:
b2qt-init-build-env mirror
List available devices:
b2qt-init-build-env list-devices
たとえば、
./b2qt-init-build-env list-devices
を使用することによりBuildできるデバイス一覧が確認できます。
Boot2-QtにてRaspberry Pi3を設定する
$ b2qt-init-build-env init --device raspberrypi3
をおこなう事によりBuildに必要なレシピ群を取得し、Raspberry Pi3用の設定がされます。
poky/build のディレクトリに自動で移動しますので、そのまま
$ export MACHINE=raspberrypi3
$ source ./setup-environment.sh
を実行する。
Boot2-Qtを利用したYoctoのbuild
$ bitbake b2qt-embedded-qt5-image
$ bitbake meta-toolchain-b2qt-embedded-qt5-sdk
boot2Qtのimageは、以下の所にある。
The target rootfs image is located in the /tmp/deploy/images/${MACHINE}/b2qt-automation-qt5-image-${MACHINE}.img
/opt/yocto/poky/build/build-raspberrypi3/tmp/deploy/images/raspberrypi3
b2qt-embedded-qt5-image-raspberrypi3.img
b2qt-embedded-qt5-image-raspberrypi3.imgはシンボリックリンクとなっており実体は
b2qt-embedded-qt5-image-raspberrypi3.img -> b2qt-embedded-qt5-image-raspberrypi3-20190606081703.rootfs.rpi-sdimg
容量をみてみると、1.6GB程度なので、4GBぐらいのmicroSDCardを用意するば良さそうです。
-rw-r--r-- 2 sazus sazus 1.6G 6月 6 17:24 b2qt-embedded-qt5-image-raspberrypi3-20190606081703.rootfs.rpi-sdimg
lrwxrwxrwx 2 sazus sazus 68 6月 6 17:24 b2qt-embedded-qt5-image-raspberrypi3.img -> b2qt-embedded-qt5-image-raspberrypi3-20190606081703.rootfs.rpi-sdimg
lrwxrwxrwx 2 sazus sazus 68 6月 6 17:24 b2qt-embedded-qt5-image-raspberrypi3.rpi-sdimg -> b2qt-embedded-qt5-image-raspberrypi3-20190606081703.rootfs.rpi-sdimg
microSDCardへの書き込み
$ cd /opt/yocto/poky/build/build-raspberrypi3/tmp/deploy/images/raspberrypi3
$ sudo dd if=./b2qt-embedded-qt5-image-raspberrypi3.img of=/dev/mmcblk0
3186688+0 レコード入力
3186688+0 レコード出力
1631584256 bytes (1.6 GB, 1.5 GiB) copied, 655.174 s, 2.5 MB/s
SDKのInstall
$ ./b2qt-x86_64-meta-toolchain-b2qt-embedded-qt5-sdk-raspberrypi3.sh
Boot2Qtの実行
Raspberry Piに焼いたmicroSDCardをさして実行します!