m_iidas’s blog

日々学習

PetaLinuxでLinuxイメージを作成する

環境

  • Ubuntu 18.04.3
  • PetaLinux 2019.2
  • ZYBO Z7-10

前提

  • PetaLinuxは/opt/pkg/petalinux/2019.2/にインストールされている
  • Vivadoでのプロジェクト名はzybo_basicとし、PSが配置されたハードウェアが作成されている

作成手順

環境設定
$ source /opt/pkg/petalinux/2019.2/settings.sh
PetaLinux environment set to '/opt/pkg/petalinux/2019.2'
WARNING: /bin/sh is not bash!
bash is PetaLinux recommended shell. Please set your default shell to bash.
INFO: Checking free disk space
INFO: Checking installed tools
INFO: Checking installed development libraries
INFO: Checking network and other services
WARNING: No tftp server found - please refer to "PetaLinux SDK Installation Guide" for its impact and solution
作業ディレクトリの作成

ディレクトリ作成後にHardwareディレクトリにVivadoのプロジェクトをコピーしておく。

$ mkdir PetaLinux
$ mkdir Projects
$ mkdir Hardware
プロジェクト作成
$ cd Projects/
$ petalinux-create --type project --template zynq --name zybo_basic_ps
INFO: Create project: zybo_basic_ps
INFO: New project successfully created in /home/user/PetaLinux/Projects/zybo_basic_ps
設定

実行するとTUIが表示されるので、必要ならば設定を行う。

$ cd zybo_basic_ps/
$ petalinux-config --get-hw-description=../../Hardware/zybo_basic/     INFO: Getting hardware description...
INFO: Rename zynq_1_wrapper.xsa to system.xsa
[INFO] generating Kconfig for project
[INFO] menuconfig project
configuration written to /home/user/PetaLinux/Projects/zybo_basic_ps/project-spec/configs/config

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

configuration written to /home/user/PetaLinux/Projects/zybo_basic_ps/project-spec/configs/config

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

[INFO] sourcing bitbake
[INFO] generating plnxtool conf
[INFO] generating meta-plnx-generated layer
[INFO] generating user layers
[INFO] generating workspace directory
[INFO] generating machine configuration
[INFO] generating bbappends for project . This may take time !
[INFO] generating u-boot configuration files
[INFO] generating kernel configuration files
[INFO] generating kconfig for Rootfs
[INFO] silentconfig rootfs
[INFO] generating petalinux-user-image.bb
ビルド
$ petalinux-build
[INFO] building project
[INFO] sourcing bitbake
[INFO] generating user layers
[INFO] generating workspace directory
INFO: bitbake petalinux-user-image
Loading cache: 100% |####################################################################################| Time: 0:00:01Loaded 3978 entries from dependency cache.
Parsing recipes: 100% |##################################################################################| Time: 0:00:05Parsing of 2893 .bb files complete (2885 cached, 8 parsed). 3980 targets, 169 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |###############################################################################| Time: 0:00:04Checking sstate mirror object availability: 100% |#######################################################| Time: 0:00:10Sstate summary: Wanted 887 Found 711 Missed 352 Current 0 (80% match, 0% complete)
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 3218 tasks of which 2362 didn't need to be rerun and all succeeded.
INFO: Copying Images from deploy to images
INFO: Creating /home/user/PetaLinux/Projects/zybo_basic_ps/images/linux directory
NOTE: Failed to copy built images to tftp dir: /tftpboot
[INFO] successfully built project
BOOT.BINの生成
$ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot
INFO: File in BOOT BIN: "/home/user/PetaLinux/Projects/zybo_basic_ps/images/linux/zynq_fsbl.elf"
INFO: File in BOOT BIN: "/home/user/PetaLinux/Projects/zybo_basic_ps/images/linux/system.bit"
INFO: File in BOOT BIN: "/home/user/PetaLinux/Projects/zybo_basic_ps/images/linux/u-boot.elf"
INFO: Generating Zynq binary package BOOT.BIN...


****** Xilinx Bootgen v2019.2
  **** Build date : Oct 23 2019-22:59:42
    ** Copyright 1986-2019 Xilinx, Inc. All Rights Reserved.

INFO: Binary is ready.
WARNING: Unable to access the TFTPBOOT folder /tftpboot!!!
WARNING: Skip file copy to TFTPBOOT folder!!!
成果物のコピー

以下画像に示すように、FAT32でフォーマットしたSDカードにimages/linux/にあるBOOT.BINとimage.ubをコピーする

f:id:m_iidas:20191230045431p:plain
SDカード

ジャンパピンの設定

ジャンパピンJP5を以下の画像のようにSDにセットする。

f:id:m_iidas:20191230044951p:plain
JP5をSDにセット

実行

PROG UARTにUSBケーブルを差し込み、PuTTY等でコンソールを開くと以下のように起動ログが表示される。 なお、ユーザー名、パスワードともにrootでログインできる。

参考

https://japan.xilinx.com/support/documentation/sw_manuals_j/xilinx2019_2/ug1144-petalinux-tools-reference-guide.pdf
https://qiita.com/iwatake2222/items/6e6915f7318689818368