はじめに
AMDが提供するPetaLinux (rel-v2021.2) をビルドし、QEMUで動かしてみました。
参考にしたサイト
- https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821854264/Launching+QEMU+Using+Xilinx+Yocto+toolchains
- https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821395464/QEMU+User+Documentation
構成図
+------------------------------------------------------+
| +--------------------------------------------------+ |
| | +----------------------------------------------+ | |
| | | +------------------------------------------+ | | |
| | | | PetaLinux (2021.2) | | | |
| | | +------------------------------------------+ | | |
| | | Zynq UltraScale+ MPSoC ZCU102 Evaluation Kit | | |
| | +----------------------------------------------+ | |
| | QEMU | |
| +--------------------------------------------------+ |
| Ubuntu Server |
+------------------------------------------------------+
各ソフトウェアのバージョン
Ubuntu Server
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
QEMU
$ ./qemu-system-aarch64 --version
QEMU emulator version 5.1.0 (v2.6.0-35817-g303b509ec2-dirty)
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
- QEMUはPetaLinuxビルド時に生成されたqemu-system-aarch64コマンドを使用しました。
/home/petalinux/github/petalinux/build/tmp/work/x86_64-linux/qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin
前提条件
- repo init時に、GitHubのアカウントが必要になります。事前に作成しておいてください。
- 以降の作業は、自分で作成したpetalinuxというユーザを使用しました。petalinuxユーザにはsudo権限を付与しています。
- petalinuxユーザのホームディレクトリは/home/petalinuxです。以降の作業は/home/petalinux上で行いました。
必要なパッケージのインストール
- 以下のコマンドを実行し、必要なパッケージをインストールしてください。
sudo apt install -y gcc net-tools xterm autoconf libtool \ texinfo zlib1g-dev gcc-multilib build-essential ncurses-dev \ chrpath diffstat lz4
PetaLinuxリポジトリのクローン
-
curlコマンドでrepoコマンドを入手してください。
curl -k https://storage.googleapis.com/git-repo-downloads/repo > repo
-
repoコマンドに実行権限を付与してください。
chmod a+x repo
-
Proxyサーバがある場合、vimコマンドなどで、repoファイルを開き、以下を追記してください。
# (snip) import sys # 追加部分 os.environ['http_proxy'] = '<your proxy server name>:<port number>' os.environ['https_proxy'] = '<your proxy server name>:<port number>' # (snip)
-
repo initコマンドで初期化を行ってください。
repo init -u https://github.com/Xilinx/yocto-manifests -b rel-v2021.2
-
repo syncコマンドで、必要なファイルをダウンロードしてください。
repo sync
- 以下のような実行結果が出力されます。
$ repo sync Fetching: 100% (16/16), done in 20.536s Checking out: 93% (15/16), done in 0.818s repo sync has finished successfully.
- 以下のような実行結果が出力されます。
PetaLinuxのビルド
- 以下のコマンドを実行し、ビルドのために必要な環境変数を設定してください。
source setupsdk
- bitbakeコマンドでPetaLinuxをビルドしてください。
MACHINE=zcu102-zynqmp bitbake petalinux-image-minimal
pmu-rom.elfの入手
- 以下のWebページから、xilinx-zcu102-v2021.2-final.bspをダウンロードしてください。
-
https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools/archive.html
- Zynq UltraScale+ MPSoC Board Support Packages - 2021.2
- ZCU102 BSP
- Zynq UltraScale+ MPSoC Board Support Packages - 2021.2
- ダウンロードには、AMDのアカウント (無料で作成可能) が必要になります。
-
https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools/archive.html
- 作業用のディレクトリを作成してください。
mkdir /home/petalinux/petalinux-bsp
- xilinx-zcu102-v2021.2-final.bspを上記ディレクトリに保存してください。
- 以下のコマンドを実行してください。
cd /home/petalinux/petalinux-bsp
tar -O -xf xilinx-zcu102-v2021.2-final.bsp \ xilinx-zcu102-2021.3/pre-built/linux/images/pmu_rom_qemu_sha3.elf > pmu-rom.elf
- なお、上記手順は、PetaLinuxのリポジトリのクローン後作成される以下のファイル内にも記載されています。
- sources/meta-xilinx/meta-xilinx-bsp/README.qemu.md
- なお、上記手順は、PetaLinuxのリポジトリのクローン後作成される以下のファイル内にも記載されています。
- pmu-rom.elfファイルをPetaLinuxのイメージファイルがあるディレクトリにコピーしてください。
cp pmu-rom.elf /home/petalinux/github/petalinux/build/tmp/deploy/images/zcu102-zynqmp/
PetaLinuxの起動
- runqemuコマンドで、PetaLinuxをQEMUで起動してください。
MACHINE=zcu102-zynqmp runqemu petalinux-image-minimal nographic
(snip) Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034] [ 0.000000] Linux version 5.10.0-xilinx-v2021.2 (oe-user@oe-host) (aarch64-xilinx-linux-gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP Tue Oct 12 09:30:57 UTC 2021 [ 0.000000] Machine model: xlnx,zynqmp (snip)
- 起動後、rootユーザでログインした状態になります。
Starting internet superserver: inetd. Starting syslogd/klogd: done Starting tcf-agent: OK root@zcu102-zynqmp:~#
# uname -r 5.10.0-xilinx-v2021.2
さいごに
PetaLinux (rel-v2021.2) をビルドして、QEMUでエミュレートしたZynq UltraScale+ MPSoC ZCU102 Evaluation Kitで動かしてみました。