目的
最近のARMマイコンではLinuxOSを使用することが多い。raspberrypiのように有名なボードの場合は多くの機能を盛り込んだ専用のOSイメージが提供されているが、マイコンという特性上、必要な機能を最低限に抑え、かつ必要な機能を後付けしたりということが必要であったりする。
yocotというLinuxOSを使用することで、機能が最小限かつオリジナルのOSイメージを作成することができる。
今回はraspberrypi3bを対象にyoctoのOSイメージの作成をしてみることにした。
作成環境・対象イメージ
PC環境
OS:ubuntu20.4LTS
CPU:Corei5 3470
メモリ:8GB
HDD:2TB
作成するイメージ
yocto3.1.17(dunfell)
core-image-minimal
対象機器
raspberrypi3b
事前準備
1.各種ソフトウェアインストール
$ sudo apt install git
$ sudo apt install bmap-tools
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo \
gcc-multilib build-essential chrpath socat cpio python python3 \
python3-pip python3-pexpect xz-utils debianutils iputils-ping \
python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 \
xterm p7zip-full
2.Ubuntuをリモートデスクトップ接続設定する場合(必要であれば)
別のWindowsPCからUbuntuPCへリモートデスクトップ接続する場合は以下のようにxdrpをインストールします。
$ sudo apt install xdrp
3.Emacsをインストール(必要であれば)
Ubuntu20.4LTSに標準でインストールされているviエディタやnanoエディタでOKという方は省略してOK。
$ sudo apt install emacs
4.vsftpdをインストール(必要であれば)
$ sudo apt install vsftpd
gitconfig設定
$ git config --global user.email "xxxxxxx@yahoo.co.jp"
$ git config --global user.name "xxxxxxx"
$ git config --global url."https://".insteadOf git://
$ git config --global url."https://git.yoctoproject.org/git/".insteadOf git://git.yoctoproject.org/
$ git config --global url."https://anongit.freedesktop.org/git/".insteadOf git://anongit.freedesktop.org/
$ git config --global http.postBuffer 54288000
$ git config -l
イメージ作成手順
dunfellフォルダを作成
$ mkdir dunfell
$ cd dunfell
poky meta-raspberrypi meta-openembedded をgitからダウンロード
$ git clone -b dunfell git://git.yoctoproject.org/poky.git
Cloning into 'poky'...
remote: Enumerating objects: 568269, done.
remote: Counting objects: 100% (689/689), done.
remote: Compressing objects: 100% (315/315), done.
remote: Total 568269 (delta 514), reused 405 (delta 371), pack-reused 567580
Receiving objects: 100% (568269/568269), 184.13 MiB | 5.36 MiB/s, done.
Resolving deltas: 100% (412811/412811), done.
$ git clone -b dunfell https://github.com/agherzan/meta-raspberrypi.git
Cloning into 'meta-raspberrypi'...
remote: Enumerating objects: 9964, done.
remote: Counting objects: 100% (1406/1406), done.
remote: Compressing objects: 100% (696/696), done.
remote: Total 9964 (delta 775), reused 1092 (delta 667), pack-reused 8558
Receiving objects: 100% (9964/9964), 2.22 MiB | 7.48 MiB/s, done.
Resolving deltas: 100% (5184/5184), done.
$ git clone -b dunfell git://git.openembedded.org/meta-openembedded
Cloning into 'meta-openembedded'...
環境変数を設定
$ source poky/oe-init-build-env
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to, for
example, select a different MACHINE (target hardware). See conf/local.conf
for more information as common configuration options are commented.
You had no conf/bblayers.conf file. This configuration file has therefore been
created for you with some default values. To add additional metadata layers
into your configuration please add entries to conf/bblayers.conf.
The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
https://docs.yoctoproject.org
For more information about OpenEmbedded see their website:
https://www.openembedded.org/
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86'
Other commonly useful commands are:
- 'devtool' and 'recipetool' handle common recipe tasks
- 'bitbake-layers' handles common layer tasks
- 'oe-pkgdata-util' handles common target package tasks
レイヤを追加
$ bitbake-layers -h
NOTE: Starting bitbake server...
usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ...
BitBake layers utility
optional arguments:
-d, --debug Enable debug output
-q, --quiet Print only errors
-F, --force Force add without recipe parse verification
--color COLOR Colorize output (where COLOR is auto, always, never)
-h, --help show this help message and exit
subcommands:
<subcommand>
add-layer Add one or more layers to bblayers.conf.
remove-layer Remove one or more layers from bblayers.conf.
flatten flatten layer configuration into a separate output
directory.
layerindex-fetch Fetches a layer from a layer index along with its
dependent layers, and adds them to conf/bblayers.conf.
layerindex-show-depends
Find layer dependencies from layer index.
show-layers show current configured layers.
show-overlayed list overlayed recipes (where the same recipe exists
in another layer)
show-recipes list available recipes, showing the layer they are
provided by
show-appends list bbappend files and recipe files they apply to
show-cross-depends Show dependencies between recipes that cross layer
boundaries.
create-layer Create a basic layer
Use bitbake-layers <subcommand> --help to get help on a specific command
$ bitbake-layers add-layer \
> /home/s8220jp/dunfell/meta-openembedded/meta-oe \
> /home/s8220jp/dunfell/meta-openembedded/meta-multimedia \
> /home/s8220jp/dunfell/meta-openembedded/meta-networking \
> /home/s8220jp/dunfell/meta-openembedded/meta-python \
> /home/s8220jp/dunfell/meta-raspberrypi
NOTE: Starting bitbake server...
local.confの末尾に以下行を追加した。
ENABLE_UART = "1"でUART通信を有効に設定。
RPI_USE_U_BOOT = "1"でraspberrypiのu_booot設定を有効に設定。
MACHINE = "raspberrypi3"
ENABLE_UART = "1"
RPI_USE_U_BOOT = "1"
core-image-minimalでイメージを作成する
$ bitbake core-image-minimal
Parsing recipes: 100% |##########################################| Time: 0:01:24
Parsing of 2199 .bb files complete (0 cached, 2199 parsed). 3297 targets, 142 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.46.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "ubuntu-20.04"
TARGET_SYS = "arm-poky-linux-gnueabi"
MACHINE = "raspberrypi3"
DISTRO = "poky"
DISTRO_VERSION = "3.1.17"
TUNE_FEATURES = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard"
TARGET_FPU = "hard"
meta
meta-poky
meta-yocto-bsp = "dunfell:17c23e485e472baf117811688d172038b6f2130d"
meta-oe
meta-multimedia
meta-networking
meta-python = "dunfell:52cee67833d1975a5bd52e4556c4cd312425a017"
meta-raspberrypi = "dunfell:2081e1bb9a44025db7297bfd5d024977d42191ed"
NOTE: Fetching uninative binary shim http://downloads.yoctoproject.org/releases/uninative/3.6/x86_64-nativesdk-libc-3.6.tar.xz;sha256sum=9bfc4c970495b3716b2f9e52c4df9f968c02463a9a95000f6657fbc3fde1f098 (will check PREMIRRORS first)
Initialising tasks: 100% |#######################################| Time: 0:00:03
Sstate summary: Wanted 1178 Found 0 Missed 1178 Current 0 (0% match, 0% complete)
NOTE: Executing Tasks
WARNING: gnu-config-native-20200117+gitAUTOINC+5256817ace-r0 do_fetch: Failed to fetch URL git://git.savannah.gnu.org/git/config.git;protocol=https;branch=master, attempting MIRRORS if available
NOTE: Tasks Summary: Attempted 3203 tasks of which 8 didn't need to be rerun and all succeeded.
Summary: There was 1 WARNING message shown.
/dunfell/build/tmp/deploy/images/raspberrypi3にcore-image-minimal-raspberrypi3.wic.bz2が生成できた。
イメージ作成完了まで半日程度かかります。