2021/05/10

PetaLinux 2020.2のDockerイメージを作成する

概要

私はPetaLinuxをDocker上で使用しています.ググると同じように環境構築されている方も多いようですね. GitHubで必要なファイル一式を公開していますので,ここにDockerイメージの作成方法をメモしておきます. 私はチュートリアルに毛が生えた程度しかPetaLinuxを触りませんので,もし不具合がありましたらissueでお知らせいただけると助かります. 私は,Dockerホスト環境としてUbuntu 16.04とUbuntu 20.04を使用しています.

準備

SSDまたはHDDの空き容量を15GB程度は準備しておいてください.作成するDockerイメージは10GB程度のサイズになります. 予め,XilinxのWebサイトからPetaLinuxのインストーラをダウンロードしておきます. ここではダウンロードディレクトリを/data1/Software/Xilinxとし,PetaLinux 2020.2をインストールすることにします.

ダウンロードしたファイルは下記のパスとします.

  • /data1/Software/Xilinx/petalinux-v2020.2-final-installer.run

GitHubからファイル一式を取得します. ここではgit clone先のディレクトリ名をpetalinux-baseとしていますが,未指定で既定のままでも問題ありません.

git cloneしたディレクトリに移動します.

docker build

PetaLinuxをインストールするベースとなるDockerイメージ,keitetsu/petalinux:ubuntu16.04-baseをビルドします.

PetaLinuxのインストール

ビルドしたDockerイメージを起動し,手動でPetaLinuxをインストールします. テキストエディタでrun_base.shを開き,--volumeオプションの/data1/Software/Xilinxの部分をpetalinux-v2020.2-final-installer.runを格納したディレクトリに書き換えます. このディレクトリは,Dockerコンテナ上では/dataとしてマウントされます.

PetaLinuxはrootではなく一般ユーザでインストールする必要があります. このため,Dockerホスト上のユーザのUIDとGIDを使ってDockerコンテナ起動時にユーザが作成されます. 任意のUIDとGIDを使用したい場合は,run_base.shで指定してください. これらの処理は,entrypoint.shに記載しています.

run_base.shを実行します.

通常通りPetaLinuxのインストールを進めてください.ただし,インストールディレクトリは/opt/Xilinx/PetaLinuxとしてください. このディレクトリはDockerイメージ上に予め用意されています.

インストーラを実行すると,ライセンスに同意するかどうかの入力が求められます. ライセンス文書が表示されたら'q'キーで閉じ,'y'を入力して同意します.3項目に同意が必要です.

インストールが完了してプロンプトが返ってきたら,Dockerホスト側で,今までDockerコンテナを操作していたものとは別の端末を開きます. docker psコマンドで,keitetsu/petalinux:ubuntu16.04-baseのコンテナIDを確認します.

DockerコンテナをDockerイメージとして保存します.${CONTAINER_ID}には,先ほど確認したコンテナIDを入れてください.

これでDockerイメージを作成できました. PetaLinuxをインストールするために起動したDockerコンテナはexitで終了してください.

使用方法

作成したDockerイメージを起動するためのシェルスクリプトは,run_base.shを改変して作成します.ここではrun.shとして保存します. /workspaceには,Dockerホスト上のPetaLinuxプロジェクトを格納するディレクトリを指定してください.

run.shを起動すると,下記のようにDockerコンテナが起動してPetaLinuxでの開発準備が整います.

Vitis, VivadoのDockerイメージ

VitisとVivadoの開発環境も同様にDocker上に作成することができます.私のファイル一式は上記です. こちらはまだ手順を書くことができていないのですが,PetaLinuxと同様に,下記の要領で作成します.また手順を書きたいと思います.

  1. ベースのDockerイメージをbuild/build.shでビルド
  2. run_base/run_base.shでDockerコンテナを起動
  3. install/installを参考にVitisをバッチモードでインストール
  4. install_xrt_bdf/build.shでXRTとサードパーティのbdfをインストール
  5. docker commit
  6. run/run.shでDockerコンテナを起動
2021/04/27

How to dump device tree from NAND flash to get dts (Zynq-7000)

In this article, I will dump the original device tree of the Zynq EBAZ4205 Board.

Since the Zynq EBAZ4205 Board is not a development board, the design information is not provided by the manufacturer. You need to get the necessary information yourself.

From the device tree source text (dts) file converted from the dumped device tree blob (dtb) file, you can get reference information when developing a custom Linux image using Vivado and PetaLinux.

Prepare

Insert the microSD card into the Zynq EBAZ4205 Board. This microSD card is used to transfer the dumped dtb file to the PC.

If you can use Ethernet, you can transfer the file by other methods.

Dump

Boot original Linux from the NAND flash on the Zynq EBAZ4205 Board.

Make sure the microSD card is mounted.

Execute the following command to dump the device tree from the NAND flash and save it as dtb file on the microSD card.

Convert

Copy the dtb file from the microSD card to your PC.

Convert dtb file to dts file. Use the device tree compiler (dtc) command for this conversion.

For Ubuntu, you can install it with the following command.

Execute the dtc command.

Now you have a dts file.

Tips

One of the information that can be obtained from the dts file is the NAND flash timing parameters and existing partition information.

For example, in the dts file, it was described as follows.

For the timing parameters nand-cycle-t0 to nand-cycle-t6, refer to the Xilinx Wiki.

If you are developing a custom Linux image using Vivado and PetaLinux, set these parameters in Vivado. At this time, you should also check the NAND flash data sheet.

Note: The parameters in the screenshot are examples and have not been tested.

Partition information can be set in PetaLinux.

This information is reflected in the device tree automatically generated by PetaLinux. The device tree is generated in the following directory when you run the petalinux-build command.

  • /components/plnx_workspace/device-tree/device-tree

My Vivado design and PetaLinux project are available on GitHub.

If there are any mistakes in the description, please let me know.

2021/04/23

Solves the warning when loading the U-Boot environment (Zynq-7000, PetaLinux 2020.2)

I have built a boot image for the Zynq EBAZ4205 Board with Xilinx PetaLinux 2020.2. Linux was able to boot normally, but the following warning was displayed when U-Boot was booted.

The Zynq EBAZ4205 Board does not have SPI Flash. In order to solve this warning, it was necessary to change the U-Boot configurations.

Open the U-Boot configuration with the following command.

Enable "Environment is not stored".

Environment-> Environment is not stored

Disable "Environment is in SPI flash".

Environment-> Environment is in SPI flash

Exit from the U-Boot configuration and rebuild the U-Boot.

The following 2 lines are added to the U-Boot settings.

An example of the PetaLinux project can be found below.

2021/04/21

忍者ホームページではGoogle Adsenseの新規利用開始は不可能な場合がある

要約
メモ

しばらくホームページやこのブログを放置していたので,その間にGoogle Adsenseの資格要件も変わったみたいですね. この記事の内容をひとまとめに把握するのに役立ったのは,下記のGoogle Adsenseコミュニティのスレッドです.他は上記の要約のリンク先を参照してください.