0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PYNQ の PL Server を systemd から起動する

Last updated at Posted at 2017-02-20

はじめに

本記事では、 pynq.io から PYNQ-Z1 ボード向けに提供されている PYNQ イメージにおいて、 PL Server を systemd 経由で管理するように変更する例を示します。

PL Server は bitstream をロードした際に、同時に handoff 用 tcl ファイルを読み込んで、各種ブロックの MMIO アドレスを保持するために使われています。ただ、私の手元では度々 PL Server がクラッシュなどして居なくなってしまい、手動で立ち上げなおしていました。

systemd によるプロセス管理のメリット

今回は、 PL Server を systemd 経由で起動するようにイメージを修正し、下記のメリットを得ることを目標としています。

  • PL Server がクラッシュした場合に自動的に再起動させる

    ※ ロード済みの IP のレジスタマップが復元されるわけではない
  • systemd のユニットとして管理する他のプロセスが PL Server のユニットの起動後に起動するよう、順序を制御できる

PL Server の起動方法を変更するだけですので、基本的にはオリジナルの PYNQ イメージと同等に利用でき、特に不自由はないはずです。

設定方法

/etc/rc.local からの PL Server 起動をやめる

PYNQ では PL Server を /etc/rc.local から起動していますが、これを無効化します。

# !/bin/sh -e
#
# (snip)

# Adding Jupyter scripts to bring up network and start Jupyter server
/root/0_resizefs.sh
/root/1_network.sh >/dev/null 2>&1 &
/root/2_jupyter_server.sh
# /root/3_pl_server.sh    # この行をコメントアウトもしくは削除
/root/4_boot_leds.sh

exit 0

/usr/local/sbin/pl_server.sh を作成する

PL Server をフォアグラウンドで実行する下記スクリプトを作成します。

# !/bin/bash

/bin/rm -rf /home/xilinx/pynq/bitstream/.log
exec /usr/bin/python3 /home/xilinx/scripts/start_pl_server.py

本スクリプトには実行可能なようパーミッションを設定しておきます。(例: rwxr-xr-x )

$ sudo chmod 755 /usr/local/sbin/pl_server.sh

/etc/systemd/system/pl_server.service ファイルを作成する

systemd 用 unit ファイルを作成します。

[Unit]
Description = PL Server

[Service]
ExecStart = /usr/local/sbin/pl_server.sh
Restart = always
Type = simple

[Install]
WantedBy = multi-user.target

pl_server ユニットを起動、有効化する

ここまでの作業で PL Server を自動起動する準備はできています。続いて systemd を介して下記のとおり操作します。

$ sudo systemctl start pl_server      # とりあえず起動してみる
$ sudo systemctl status pl_server     # 起動後問題がないか確認
$ sudo systemctl enable pl_server     # 問題なければ次回以降、システム起動時に自動起動
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?