LoginSignup
4
1

More than 3 years have passed since last update.

SafeG64をシミュレータで動かしてみよう

Last updated at Posted at 2020-08-25

はじめに

SafeG64は,ARM64でLinuxとRTOSを同時に実行することが出来るデュアルORモニタです.

Xilinxのツールを使用すると無償でシュミレータ上で実行出来ますので紹介します.

環境

  • Ubuntu 16.04 LTS(18.04は未確認)

ファイルのダウンロード

$ wget https://www.toppers.jp/download.cgi/safeg64-1.1.0.zip
$ unzip safeg64-1.1.0.zip

作業ディレクトリへの移動

以降でmakeを実行する場合は作業ディレクトリへの移動してから実行すること.

$ cd ./safeg64_1.1.0/target/zynqmp

PetaLinux環境の整備

パッケージのインストール

$ sudo make peta_apt

PetaLinuxのダウンロード

次のサイトから指定されたバージョンのPetaLinuxのInstallerをダウンロードする.XilinxへのユーザーIDの登録が必要である.

Petalinuxをインストールする.petalinuxをインストールしたフォルダを[PETADIR] とする.

$ petalinux-v2018.2-final-installer.run

Petalinuxの環境設定ファイルの読み込み

下記以降の実行手順やMakefileでは,PetaLinuxのコマンドを使用するため,
実行するコンソールで一度Petalinuxの環境設定ファイルを読み込むこと.

$ source <PETADIR>/settings.sh

ソースコードの用意

FMPカーネル・システムコンフィグレータの取得

$ make down_toppers

Petalinux BSPの取得

次のサイトから「ZCU102 BSP」をダウンロードする.

BSPプロジェクトの作成

safeg64-1.1.0と同じディレクトリにあるzynqmpに移動してBSPプロジェクトを作成する.

$ cd zynqmp
$ petalinux-create -t project -s xilinx-zcu102-v2018.2-final.bsp

以下のようにファイルが出来ていればOK

$ cd zynqmp
$ ls
fmp_1.4.0  xilinx-zcu102-2018.2

Linux/u-boot/ATFのソースコードの取得

$ make down_git

Linux/u-boot/ATFへパッチを適用

$ make peta_patch

ビルド

Petalinux BSPのビルド.それなりに時間がかかります.

$ make peta_build

ビルド終了後に設定ファイルを生成するためにQEMUが起動するので,Ctrl-a x を入力してQEMUを終了する

INFO: Copying Images from deploy to images
INFO: Creating images/linux directory
NOTE: Failed to copy built images to tftp dir:  /tftpboot
[INFO] successfully built project
INFO: No DTB has been specified, use the default one "/home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/system.dtb".
INFO: No DTB has been specified, use the default one "/home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/system.dtb".
INFO: Starting microblaze QEMU
INFO: Starting the above QEMU command in the background
INFO:  qemu-system-microblazeel -M microblaze-fdt   -display none -kernel /home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/pmu_rom_qemu_sha3.elf -device loader,file=/home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/pmufw.elf      -hw-dtb /home/honda/te/zynqmp/xilinx-zcu102-2018.2/images/linux/zynqmp-qemu-multiarch-pmu.dtb -machine-path /tmp/tmp.6cApAnuHAe -device loader,addr=0xfd1a0074,data=0x1011003,data-len=4 -device loader,addr=0xfd1a007C,data=0x1010f03,data-len=4 
qemu-system-microblazeel: Failed to connect socket /tmp/tmp.6cApAnuHAe/qemu-rport-_pmu@0: No such file or directory
qemu-system-microblazeel: info: QEMU waiting for connection on: disconnected:unix:/tmp/tmp.6cApAnuHAe/qemu-rport-_pmu@0,server
INFO: Set QEMU tftp to /home/honda/te/zynqmp/xilinx-zcu102-2018.2/images/linux 
INFO: TCP PORT is free 
INFO: Starting aarch64 QEMU
INFO:  qemu-system-aarch64 -M arm-generic-fdt   -serial mon:stdio -serial /dev/null -display none -device loader,file=/home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/bl31.elf,cpu-num=0 -device loader,file=/home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/Image,addr=0x00080000 -device loader,file=/home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/system.dtb,addr=0x1407f000 -device loader,file=/home/honda/te/zynqmp/xilinx-zcu102-2018.2/build/misc/linux-boot/linux-boot.elf -gdb tcp::9000 -dtb /home/honda/te/zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/system.dtb  -net nic -net nic -net nic -net nic,vlan=1 -net user,vlan=1,tftp=/home/honda/te/zynqmp/xilinx-zcu102-2018.2/images/linux    -hw-dtb /home/honda/te/zynqmp/xilinx-zcu102-2018.2/images/linux/zynqmp-qemu-multiarch-arm.dtb -machine-path /tmp/tmp.6cApAnuHAe -global xlnx,zynqmp-boot.cpu-num=0 -global xlnx,zynqmp-boot.use-pmufw=true  -m 4G
qemu-system-aarch64: -net nic,vlan=1: 'vlan' is deprecated. Please use 'netdev' instead.
audio: Could not init `oss' audio driver
qemu-system-aarch64: warning: vlan 0 is not connected to host network
PMU Firmware 2018.2     Jun 15 2018   04:19:50
PMU_ROM Version: xpbr-v8.1.0-0
NOTICE:  ATF running on XCZUUNKN/QEMU v1/RTL0.0 at 0xfffea000
NOTICE:  BL31: Secure code at 0x60000000
<- Ctrl-a x を入力

FMP及びアプリケーションのビルド

$ make build_comapp

#実行

ターミナルを3個開き,それぞれPetalinuxの環境設定ファイルを読み込んだ後,
./safeg64_1.1.0/target/zynqmpがあるフォルダに移動する.

$ source <PETADIR>/settings.sh
$ cd ./safeg64_1.1.0/target/zynqmp

ターミナル1でQEMUを実行する.
起動後にターミナル2からの接続待ちになる.

$ make runq

rm -rf /tmp/qemu
mkdir -p /tmp/qemu
/usr/local/Xilinx/SDK/2018.2/bin/qemu-system-microblazeel -M microblaze-fdt -display none \
        -kernel ../../../zynqmp/xilinx-zcu102-2018.2/pre-built/linux/images/pmu_rom_qemu_sha3.elf \
        -device loader,file=../../../zynqmp/xilinx-zcu102-2018.2/images/linux/pmufw.elf \
        -hw-dtb ../../../zynqmp/xilinx-zcu102-2018.2/images/linux/zynqmp-qemu-multiarch-pmu.dtb \
        -machine-path /tmp/qemu \
        -device loader,addr=0xfd1a0074,data=0x1011003,data-len=4 \
        -device loader,addr=0xfd1a007C,data=0x1010f03,data-len=4 &
/usr/local/Xilinx/SDK/2018.2/bin/qemu-system-aarch64  -M arm-generic-fdt \
        -serial mon:stdio \
        -serial telnet:localhost:1235,server \
        -display none \
        -device loader,file=../../../zynqmp/xilinx-zcu102-2018.2/images/linux/bl31.elf,cpu-num=0 \
        -device loader,file=../../../zynqmp/xilinx-zcu102-2018.2/images/linux/Image,addr=0x00080000 \
        -device loader,file=../../../zynqmp/xilinx-zcu102-2018.2/images/linux/system.dtb,addr=0x1407f000 \
        -device loader,file=../../../zynqmp/xilinx-zcu102-2018.2/build/misc/linux-boot/linux-boot.elf \
        -device loader,file=../../doscom/examples/zynqmp_smp/ca53_64_m_fmp/fmp.elf \
        -gdb tcp::9000 \
        -dtb ../../../zynqmp/xilinx-zcu102-2018.2/images/linux/system.dtb \
        -net nic -net nic -net nic -net nic,vlan=1 -net user,vlan=1,tftp=../../../zynqmp/xilinx-zcu102-2018.2/images/linux \
        -redir tcp:10022:10.0.2.15:22 \
        -hw-dtb ../../../zynqmp/xilinx-zcu102-2018.2/images/linux/zynqmp-qemu-multiarch-arm.dtb \
        -machine-path /tmp/qemu \
        -global xlnx,zynqmp-boot.cpu-num=0 \
        -global xlnx,zynqmp-boot.use-pmufw=true \
        -m 4G
qemu-system-aarch64: -redir tcp:10022:10.0.2.15:22: The -redir option is deprecated. Please use '-netdev user,hostfwd=...' instead.
qemu-system-aarch64: -net nic,vlan=1: 'vlan' is deprecated. Please use 'netdev' instead.
qemu-system-aarch64: -serial telnet:localhost:1235,server: info: QEMU waiting for connection on: disconnected:telnet:127.0.0.1:1235,server
qemu-system-microblazeel: Failed to connect socket /tmp/qemu/qemu-rport-_pmu@0: No such file or directory
qemu-system-microblazeel: info: QEMU waiting for connection on: disconnected:unix:/tmp/qemu/qemu-rport-_pmu@0,server

ターミナル1でコマンドを入力後,ターミナル2でtelnetでxuart1に接続する.
ターミナル2がRTOSのコンソールとなる.

$ make term

RTOS側のコンソール出力が出力され,ターミナル1側にLinuxの起動ログが出力される.

TOPPERS/FMP Kernel Release 1.4.0 for Xilinx ZynqMP A53(AArch64 ATF Secure EL1) (Aug 25 2020, 14:40:56)
Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
                            Toyohashi Univ. of Technology, JAPAN
Copyright (C) 2004-2015 by Embedded and Real-Time Systems Laboratory
            Graduate School of Information Science, Nagoya Univ., JAPAN

Processor 3 start.
Processor 4 start.
Processor 1 start.
Processor 2 start.
BTASK2: Starts
BTASK4: Starts
BTASK3: Starts
System logging task is started on port 1.
DOSCOM basic test program starts (exinf = 1).
Master doscom_init
BTASK1: Starts
BTASK1: Notify TOPPERS kernel initialize completion to ATF.
BTASK2: Notify TOPPERS kernel initialize completion to ATF.
BTASK3: Notify TOPPERS kernel initialize completion to ATF.
BTASK4: Notify TOPPERS kernel initialize completion to ATF.
Connection closed by foreign host.

ターミナル3でLinux側のアプリケーションをホストからQEMUの中で実行されているARMにコピーする.
パスワードはrootを指定する.

$ make scpq
scp  -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P 10022 ../../doscom/examples/zynqmp_smp/ca53_r_linux/basic.exe root@localhost:/home/root
Warning: Permanently added '[localhost]:10022' (RSA) to the list of known hosts.
root@localhost's password: <- root と入力
basic.exe                                          100%   50KB  49.5KB/s   00:00 

ターミナル1でQEMUの中のLinuxへログインする.
ユーザ名 : root
パスワード : root

PetaLinux 2018.2 xilinx-zcu102-2018_2 /dev/ttyPS0

xilinx-zcu102-2018_2 login: root
Password: <- root と入力
root@xilinx-zcu102-2018_2:~#

ターミナル1でDOSCOMのアプリケーションの実行

Linuxにログインしたら basic.exe を実行するとRTOS側との通信がはじまる.

root@xilinx-zcu102-2018_2:~# ls
basic.exe
root@xilinx-zcu102-2018_2:~# ./basic.exe 

終了する場合は,ターミナル1で Ctrl-A x を入力する.

変更履歴

  • 2020/08/25
    • 最初の投稿
4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1