LoginSignup
0
0

More than 1 year has passed since last update.

RHEL8でChipyardを扱う

Last updated at Posted at 2022-01-04

RHEL8でChipyardを扱うメモです。Centos8でも同じかもしれません。開発マシンがRHEL8でもChipyardを使ったRISC-Vの開発は大丈夫そうです。基本的には Chipyardの公式ドキュメント ( https://chipyard.readthedocs.io/en/latest/index.html )を参照していただくとして、ここには変更点と、最低限の作業、及びコメントを記載します。

環境

事前準備:必要なパッケージの準備

こちらにCentOSの例があります。RHELだとcentos-release-scl、devtoolset-8-make が不要で、glibc-static libstdc++-static 必要な模様。

#!/bin/bash

set -ex

sudo yum groupinstall -y "Development tools"
sudo yum install -y gmp-devel mpfr-devel libmpc-devel zlib-devel vim git java java-devel

# Install SBT https://www.scala-sbt.org/release/docs/Installing-sbt-on-Linux.html#Red+Hat+Enterprise+Linux+and+other+RPM-based+distributions
# sudo rm -f /etc/yum.repos.d/bintray-rpm.repo
# Use rm above if sbt installed from bintray before.
curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo
sudo mv sbt-rpm.repo /etc/yum.repos.d/

sudo yum install -y sbt texinfo gengetopt
sudo yum install -y expat-devel libusb1-devel ncurses-devel cmake "perl(ExtUtils::MakeMaker)"
# deps for poky
sudo yum install -y python38 patch diffstat texi2html texinfo subversion chrpath git wget
# deps for qemu
sudo yum install -y gtk3-devel
# deps for firemarshal
sudo yum install -y python38-pip python38-devel rsync libguestfs-tools makeinfo expat ctags
# Install GNU make 4.x (needed to cross-compile glibc 2.28+)
#sudo yum install -y centos-release-scl
#sudo yum install -y devtoolset-8-make

# for RHEL8
sudo yum install -y glibc-static libstdc++-static

# install DTC
sudo yum install -y dtc
#sudo yum install -y python

事前準備:Verilator のセットアップ

RHEL8.5 の VerilatorはV4.028のようです。少し古いので最新版をBuildしてInstallします。

# install verilator
git clone http://git.veripool.org/git/verilator
cd verilator
autoconf && ./configure && make -j$(nproc) && sudo make install

Chipyardのセットアップ

公式ガイドはこちら

GithubがらCloneして、Submoduleを取得。これは数分で終わります。

git clone https://github.com/ucb-bar/chipyard.git
cd chipyard
git checkout 1.7.1
time ./scripts/init-submodules-no-riscv-tools.sh

Toolchain のビルド

これは1時間近くかかると思います。CPUがたくさんあるマシンだと速いはず。

export MAKEFLAGS=-j8
time ./scripts/build-toolchains.sh riscv-tools
source env.sh

動作確認:Verilator

公式ガイドはこちら

初回のBuildは色々DLするので1時間程度がかかります。
次回以降のBuildはすぐに終わります。

cd sims/verilator
time make

実行テスト、ここまででエラーが出なければひとまずChiselからVerilogの生成はOKな模様。

$ ./simulator-chipyard-RocketConfig $RISCV/riscv64-unknown-elf/share/riscv-tests/isa/rv64ui-p-simple
This emulator compiled with JTAG Remote Bitbang client. To enable, use +jtag_rbb_enable=1.
Listening on port 41435
[UART] UART0 is here (stdin/stdout).

事前準備:Vivado 2022.1 のセットアップ

FPGAを扱うにはXilinxのVivadoを導入しておく必要があります。最新は 2021.2です。Vivadoを導入自体に特に問題はないと思いますので、ここでは省略します。Chipyardで用いるボードファイルを追加する必要があります。2022.1には board_files フォルダが無いのですが、作れば従来どおりに動く模様。

ArtyのboardファイルをCopy

wget https://github.com/Digilent/vivado-boards/archive/master.zip
unzip master.zip
cp -ar vivado-boards-master/new/board_files /opt/Xilinx/Vivado/2022.1/data/boards/

VCU118のboardファイルをCopy

git clone https://github.com/Xilinx/XilinxBoardStore.git
cd XilinxBoardStore
git checkout 2022.1
cp -ar boards/Xilinx/vcu118 /opt/Xilinx/Vivado/2022.1/data/boards/board_files/

Vivadoの環境変数セットしておきます。

source /opt/Xilinx/Vivado/2022.1/settings64.sh
which vivado

動作確認:FPGA

FPGAのBitファイルを生成します。まずFPGA用のSubmodule取得。

time ./scripts/init-fpga.sh
cd fpga

最初はArty向けの32bitコア。10分程度。(無償版でOK)

time make SUB_PROJECT=arty bitstream

Verilog RTL生成であれば、下記でOK(Vivadoは不要)

time make SUB_PROJECT=arty verilog

次にはVCU118向けの64bitコア。1時間程度。(有償ライセンスが必要です)

time make SUB_PROJECT=vcu118 bitstream

以上、問題なく実行できれば、基本的なChipyardの開発環境のセットアップは終了。あとは煮るなり焼くなり。

  • Toolchain のビルドで libstdc++ や libgcc_s が見つからないとERRORが出る場合。
    以前にセットした env.sh が悪さしているかもしれないので環境変数を確認します。
    PATHになにか残骸が残ってたら、古いToolchainへのパスを消すか、新しいShellで実行すれば解決するはず。(これに気がつくまでに時間がかかった)
  • SiFiveのPreBuildイメージは2018で古くてfesvrがない模様(=使えない)
  • ブランチ名がmasterからmainに代わり、古いForkがSyncできなくなった。
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