☁️

ADU: チュートリアルのRaspberry Pi OSイメージを作成してみる

2024/01/07に公開

チュートリアル: Raspberry Pi 3 B+ 参照イメージを使用した Device Update for Azure IoT HubのRaspberry Pi OSイメージを作成してみて、どんな手順なのかを体験しようと思います。

手順はこちらです。

https://github.com/Azure/iot-hub-device-update-yocto

作業環境はWSLのUbuntu 20.04を使います。

作業ディレクトリを用意して、環境変数proj_rootに設定しておきます。

mkdir adu-os-image
cd adu-os-image
proj_root=`pwd`

Clone the Yocto projectを実行。

  • cd $project_root/yoctoは間違い。正しくはcd $proj_root/yocto
yocto_release=honister
adu_release=main
git clone https://github.com/Azure/iot-hub-device-update-yocto -b main $proj_root
cd $proj_root/yocto
git clone --depth 1 --branch $yocto_release git://git.yoctoproject.org/poky

meta layer 6個をClone。

git clone --depth 1 --branch $yocto_release  https://github.com/sbabic/meta-swupdate
git clone --depth 1 --branch $yocto_release  git://git.openembedded.org/meta-openembedded
git clone --depth 1 --branch $yocto_release git://git.yoctoproject.org/meta-raspberrypi
git clone --branch $adu_release http://github.com/azure/meta-azure-device-update
git clone --branch $adu_release http://github.com/azure/meta-iot-hub-device-update-delta
git clone --branch $adu_release http://github.com/azure/meta-raspberrypi-adu

Install Build Dependencies and Toolsを実行する前に、ディレクトリがマズいので移動しておきます。

cd $proj_root

Install Build Dependencies and Toolsを実行。

  • sudo ./scripts/install-deps.hは間違い。正しくはsudo ./scripts/install-deps.sh
sudo ./scripts/install-deps.sh
cd yocto/poky
git fetch
git checkout -t origin/honister -b my-honister
git pull
source oe-init-build-env

Build The Projectを実行する前に、ディレクトリがマズいので移動しておきます。

cd $proj_root

Build The Projectを実行。
引数の意味が分からないので、とりあえず掲載されているものをそのままで実行してみます。

yocto_release=honister
adu_release=honister
adu_src_uri="gitsm://github.com/azure/iot-hub-device-update"
adu_git_branch=develop
adu_git_commit=e099aaca0ad2b8849de24a13b1aa8e3ddf009251
do_src_uri="gitsm://github.com/microsoft/do-client.git"
do_git_branch=main
do_git_commit=b61de2d347c8032562056b18f90ec710e531baf8
adu_delta_src_uri="gitsm://github.com/azure/iot-hub-device-update-delta"
adu_delta_git_branch=main
adu_delta_git_commit=b581e92458f458969b427051a2ac5d18d3528dc6
build_type=debug
build_number=1.0.1
build_output_dir=~/adu-yocto-build-output
./scripts/build.sh -c -t $build_type -v $build_number --adu-src-uri $adu_src_uri --adu-git-branch $adu_git_branch --adu-git-commit $adu_git_commit --do-src-uri $do_src_uri --do-git-branch $do_git_branch  --do-git-commit $do_git_commit --adu-delta-src-uri $adu_delta_src_uri --adu-delta-git-branch $adu_delta_git_branch --adu-delta-git-commit $adu_delta_git_commit -o $build_output_dir

9:36に開始して13:46に完了。約4時間かかりました。

  • Surface Book 3 (Quad-core 10th Gen Intel Core i7, RAM 32GiB, 1TiB PCIe SSD)

Azure Virtual Machineで試したところ、約1時間でした。

  • Standard D16ds v5 (vCPU 16, RAM 64GiB, OS Disk 256GiB)
...
Build Configuration:
BB_VERSION           = "1.52.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "ubuntu-20.04"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "raspberrypi3"
DISTRO               = "poky"
DISTRO_VERSION       = "3.4.4"
TUNE_FEATURES        = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard"
TARGET_FPU           = "hard"
meta
meta-poky
meta-yocto-bsp       = "my-honister:fd00d74f47ceb57a619c4d0a0553ff0a30bbb7a4"
meta-oe
meta-multimedia
meta-networking
meta-python          = "honister:0e6c34f82ca4d43cbca3754c5fe37c5b3bdd0f37"
meta-raspberrypi     = "honister:378d4b6e7ba64b6a9a701457cc3780fa896ba5dc"
meta-swupdate        = "honister:539c58405f4d27389a27c98d7f2cc153b55aa4e6"
meta-iot-hub-device-update-delta = "main:c2cee5ee56a91285e41bde147213dca918b7a405"
meta-azure-device-update = "main:433620b4c048e8d32037e894b311aa9dfec7bdd8"
meta-raspberrypi-adu = "main:a48bd20b2022f89e3501ab6a140c441019067923"
...
WARNING: boost-1.77.0-r0 do_fetch: Checksum mismatch for local file /home/ubuntu/adu-yocto-build-output/build/downloads/boost_1_77_0.tar.bz2
Cleaning and trying again.
WARNING: boost-1.77.0-r0 do_fetch: Renaming /home/ubuntu/adu-yocto-build-output/build/downloads/boost_1_77_0.tar.bz2 to /home/ubuntu/adu-yocto-build-output/build/downloads/boost_1_77_0.tar.bz2_bad-checksum_5e89103d9b70bba5c91a794126b169cb67654be2051f90cf7c22ba6893ede0ff
WARNING: boost-1.77.0-r0 do_fetch: Checksum failure encountered with download of https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2 - will attempt other sources if available
WARNING: python3-pygobject-3.40.1-r0 do_fetch: Failed to fetch URL http://ftp.gnome.org/pub/GNOME/sources/pygobject/3.40/pygobject-3.40.1.tar.xz, attempting MIRRORS if available
WARNING: bsdiff-git-r0 do_populate_lic: bsdiff: No generic license file exists for: bsdiff in any provider
WARNING: deliveryoptimization-agent-service-1.0-r0 do_package_qa: QA Issue: deliveryoptimization-agent-service: recipe doesn't inherit features_check [unhandled-features-check]
WARNING: adu-agent-service-1.0-r0 do_package_qa: QA Issue: adu-agent-service: recipe doesn't inherit features_check [unhandled-features-check]
WARNING: adu-base-image-1.0-r0 do_rootfs: The license listed bsdiff was not in the licenses collected for recipe bsdiff
...

結果はこちら。

  • Locationの$build_output_dir/tmp/deploy/images/raspberrypi3は間違い、正しくは$build_output_dir/build/tmp/deploy/images/raspberrypi3
$ ls -l adu-base-image-raspberrypi3.wic.gz adu-update-image-raspberrypi3.swu
lrwxrwxrwx 2 ubuntu ubuntu 56 Jan  7 13:46 adu-base-image-raspberrypi3.wic.gz -> adu-base-image-raspberrypi3-20240107003734.rootfs.wic.gz
lrwxrwxrwx 2 ubuntu ubuntu 48 Jan  7 13:46 adu-update-image-raspberrypi3.swu -> adu-update-image-raspberrypi3-20240107003734.swu
$ ls -l adu-base-image-raspberrypi3-20240107003734.rootfs.wic.gz adu-update-image-raspberrypi3-20240107003734.swu
-rw-r--r-- 2 ubuntu ubuntu 270872981 Jan  7 13:46 adu-base-image-raspberrypi3-20240107003734.rootfs.wic.gz
-rw-r--r-- 2 ubuntu ubuntu 124606464 Jan  7 13:46 adu-update-image-raspberrypi3-20240107003734.swu

まとめ

  • 手順に軽微な間違いがいくつかあったが、雰囲気で乗り切れた。あとで手順訂正のPR出そう。
  • 消費ディスク量は約67GiB。
  • 所要時間は約5時間。長かった...。今度はAzure VM使おう。

Discussion