Xilinx Vivado自動インストールスクリプト

## 目的

Xilinx社FPGA開発ツールであるVivadoをコマンドラインで自動インストールしたい。

## 実験環境

ホストOS：　Ubuntu 20.04
ホストCPU：　INTEL
ホストメモリ：　32GB
ホストDISK：　512GB

## 前準備

１．Ubuntu DT 20.04をminimalでインストールしておく。

２．Vivadoインストーラをご自身のXilinxアカウントを使ってダウンロードしておく。
Xilinx_Vivado_SDK_2015.1_0428_1.tar.gz

今回はArtix-7を使いたいのでちょっと古いが以下のバージョンにした。
また、あるバージョンでWebインストーラ版を試したら「既に廃止された」とのメッセージが出たので今後は使えない？と思い、サイズ大きいがフルインストーラの方をダウンロードしておく。

## スクリプトのポイント

・GUIでインストール時、「generating installed device list」というフェーズで10h待っても進まない症状に対処した。

・コマンドラインインストール時に出る以下エラーに対処した。
application-specific initialization failed: couldn't load file "librdi_commontasks.so": libncurses.so.5: cannot open shared object file: No such file or directory

・Vivadoインストール時のコンフィグファイルは事前に./xsetup -b ConfigGenを実行して生成されたものをスクリプトへコピーしてます。バージョンによって多少文法が変わるみたいなので、他のバージョンで試す際は、自分で./xsetup -b ConfigGenを実行して以下に生成されるコンフィグファイル内容をスクリプトへ反映させれば同様に出来るはず。
/root/.Xilinx/install_config.txt

## スクリプトを使ってVivadoを自動インストールしてみる

以下をコピーして、rootで実行するだけ。
（危険とは思いつつ、安易にrootで作業してしまってます。もちろんsudoでスクリプト書き直す等して安全に使って頂いた方が良いです。）

また、2015.1の方で実際に試しましたが、2016.4の方は試してないので、もしインストール失敗したらごめんなさい。

``` bat.ubuntu.install.vivado.cmdline.bash
#!/bin/bash

#VIVADO_VER=Xilinx_Vivado_SDK_2016.4_0124_1
VIVADO_VER=Xilinx_Vivado_SDK_2015.1_0428_1
CONFIG_FILE=vivado_install_config.txt

  echo "INFO : update                    ---------------------------"; apt -y update
  # to prevent for stacking at generating installed device list
  # https://www.mimoex.net/ubuntu2104-vivado/
  echo "INFO : install ocl-icd-libopencl1---------------------------"; apt -y install ocl-icd-libopencl1
  echo "INFO : install opencl-headers    ---------------------------"; apt -y install opencl-headers
  echo "INFO : install ocl-icd-opencl-dev---------------------------"; apt -y install ocl-icd-opencl-dev
  echo "INFO : install git               ---------------------------"; apt -y install git

  # to prevent for error at vivado launch
  # https://support.xilinx.com/s/article/76585?language=en_US
  echo "INFO : install libtinfo-dev      ---------------------------"; apt -y install libtinfo-dev
  echo "INFO : ln -s l libtinfo.so.6     ---------------------------"; ln -s /lib/x86_64-linux-gnu/libtinfo.so.6 /lib/x86_64-linux-gnu/libtinfo.so.5
  # for ubuntu 20.04
  echo "INFO : install libtinfo5         ---------------------------"; apt -y install libtinfo5

  # to prevent from error at bat.ubuntu.install.vivado.workaround.bash
  # application-specific initialization failed: couldn't load file "librdi_commontasks.so": libncurses.so.5: cannot open shared object file: No such file or directory
  # https://support.xilinx.com/s/question/0D52E00006iHjaASAS/ise-147-installation-error-while-loading-shared-libraries-libncursesso5?language=en_US
  echo "INFO : install libncursesso5     ---------------------------"; apt -y install libncurses5

  echo "INFO : \rm   vivado installer dir---------------------------"; \rm -rf  $VIVADO_VER
  echo "INFO : untar vivado tar.gz       ---------------------------"; tar zxvf $VIVADO_VER.tar.gz
  echo "INFO : cd    vivado installer dir---------------------------"; cd       $VIVADO_VER

  # Below is the config file generated by ./xsetup -b ConfigGen
  if [[ $VIVADO_VER =~ 2016 ]]; then
      echo "INFO : create vivado install config ------------------------"; echo "#### Vivado HL WebPACK Install Configuration ####"                                                                                    > $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "Edition=Vivado HL WebPACK"                                                                                                           >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Path where Xilinx software will be installed."                                                                                     >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "Destination=/opt/Xilinx"                                                                                                             >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose the Products/Devices the you would like to install."                                                                        >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "Modules=Software Development Kit (SDK):0,Kintex UltraScale:1,Zynq-7000:1,System Generator for DSP:0,Artix-7:1,Kintex-7:1"            >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose the post install scripts you'd like to run as part of the finalization step."                                               >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Please note that some of these scripts may require user interaction during runtime."                                               >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "InstallOptions=Acquire or Manage a License Key:0,Enable WebTalk for SDK to send usage statistics to Xilinx:0"                        >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "## Shortcuts and File associations ##"                                                                                               >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether Start menu/Application menu shortcuts will be created or not."                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateProgramGroupShortcuts=1"                                                                                                       >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose the name of the Start menu/Application menu shortcut. This setting will be ignored if you choose NOT to create shortcuts."  >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "ProgramGroupFolder=Xilinx Design Tools"                                                                                              >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether shortcuts will be created for All users or just the Current user."                                                  >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Shortcuts can be created for all users only if you run the installer as administrator."                                            >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateShortcutsForAllUsers=0"                                                                                                        >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether shortcuts will be created on the desktop or not."                                                                   >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateDesktopShortcuts=1"                                                                                                            >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether file associations will be created or not."                                                                          >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateFileAssociation=1"                                                                                                             >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                    >> $CONFIG_FILE
  else
      echo "INFO : create vivado install config ------------------------"; echo "#### Vivado WebPACK Install Configuration ####"                                                                                        >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "Edition=Vivado WebPACK"                                                                                                                >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Path where Xilinx software will be installed."                                                                                       >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "Destination=/opt/Xilinx"                                                                                                               >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose the Products/Devices the you would like to install."                                                                          >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "Modules=Artix-7:1,Vivado High Level Synthesis:0,DocNav:1,Software Development Kit:0,Zynq-7000:1,System Generator for DSP:0,Kintex-7:1" >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose the post install scripts you'd like to run as part of the finalization step."                                                 >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Please note that some of these scripts may require user interaction during runtime."                                                 >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "InstallOptions=Enable WebTalk for SDK to send usage statistics to Xilinx:0,Acquire or Manage a License Key:0"                          >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "## Shortcuts and File associations ##"                                                                                                 >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether Start menu/Application menu shortcuts will be created or not."                                                        >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateProgramGroupShortcuts=1"                                                                                                         >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose the name of the Start menu/Application menu shortcut. This setting will be ignored if you choose NOT to create shortcuts."    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "ProgramGroupFolder=Xilinx Design Tools"                                                                                                >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether shortcuts will be created for All users or just the Current user."                                                    >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Shortcuts can be created for all users only if you run the installer as administrator."                                              >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateShortcutsForAllUsers=0"                                                                                                          >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether shortcuts will be created on the desktop or not."                                                                     >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateDesktopShortcuts=1"                                                                                                              >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "# Choose whether file associations will be created or not."                                                                            >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo "CreateFileAssociation=1"                                                                                                               >> $CONFIG_FILE
      echo "INFO : create vivado install config ------------------------"; echo ""                                                                                                                                      >> $CONFIG_FILE
  fi

  echo "INFO : install vivado batch mode    ------------------------"; ./xsetup --agree XilinxEULA,3rdPartyEULA,WebTalkTerms --batch Install --config $CONFIG_FILE

```

## スクリプト実行ログ

最初の方は省略してるが、以下のようになり、インストール成功した。
上記で示した途中で止まる不具合に対処しているとスクリプト全体で数分で終わった。

```
：
INFO : create vivado install config ------------------------
INFO : install vivado batch mode    ------------------------
Running in batch mode...
Copyright (c) 1986-2023 Xilinx, Inc.  All rights reserved.
INFO: Log file location : /root/.Xilinx/xinstall/xinstall_1697283260417.log

INFO : Edition Selected to be installed: Vivado WebPACK
WARN : The value specified in the configuration file for InstallOptions (Enable WebTalk for SDK to send usage statistics to Xilinx) is missing or invalid.
INFO : Installing Edition: Vivado WebPACK
INFO : Installation directory is /opt/Xilinx
.
INFO : Installing............................................................................................
INFO : Running post-install tasks...............
INFO : Installation completed successfully.

INFO:Log file is copied to : /opt/Xilinx/.xinstall/Vivado_2015.1/xinstall.log
```

## インストール後、Vivadoを起動してみる

環境変数などの設定ファイルをsourceした後、vivadoコマンドでGUIが起動した。

```
root@b460m:~# source /opt/Xilinx/Vivado/2015.1/settings64.sh
root@b460m:~# vivado
```