Virtual environnement

Note

This chapter is not mandatory.

If you want to install directly all the tools on your system you can also follow the instructions of this chapter.

The repository contains a directory called venv with everything you need to set up a virtual machine for the labs.

Prerequisites

If you want to start to build your environment from scratch you need the following software (Tested on Debian stable but it should work on other OS):

  • Virtualbox

  • Vagrant

How to build the development environment

Note

If you want to build your environnment by yourself followed the instruction below.

In the following we explain how the virtual environnement has been build.

Setup the virtual machine

$ vagrant -v
Vagrant 2.2.14
$ vboxmanage -v
6.1.32_Debianr149290

Start the virtual environment with Vagrant

$ vagrant init ubuntu/focal64
$ Vagrant up
$ Vagrant ssh

LiteX

With Litex_setup.py

$ pyhton3 -m venv pyenv
$ source pyenv/bin/activate
$ cd hands-on/third_party
$ wget https://raw.githubusercontent.com/enjoy-digital/litex/master/litex_setup.py
$ chmod +x litex_setup.py
$ ./litex_setup.py --tag=2022.04 --init --install --config=full
$ cd litex
$ pip3 install meson ninja
$ wget  https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz
$ gunzip riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz
$ tar xvf ...
$ add to path
$ sudo apt install libevent-dev libjson-c-dev verilator

Without Litex_setup.py

In the following we will install LiteX without using litex_setup.py. Indeed it is usefull in a project to add all the dependencies as Git submodule. So in your Git repository you can add LiteX and some usefull elements such as in our case:

$ cd hands-on/third_party
$ git submodule add https://github.com/m-labs/migen.git
$ git submodule add https://github.com/enjoy-digital/litex.git
$ cd litex
$ git checkout 2022.08
$ git submodule add https://github.com/litex-hub/litex-boards.git
$ git submodule add https://github.com/enjoy-digital/litedram.git
$ git submodule add https://github.com/enjoy-digital/liteeth.git
$ git submodule add https://github.com/enjoy-digital/litescope.git
$ git submodule add https://github.com/enjoy-digital/liteiclink.git
$ git submodule add https://github.com/litex-hub/pythondata-cpu-vexriscv.git
$ git submodule add https://github.com/litex-hub/pythondata-cpu-cv32e41p.git
$ git submodule add https://github.com/litex-hub/pythondata-software-picolibc.git
$ cd pythondata-software-picolibc
$ git submodule init
$ git submodule update
$ cd ..
$ git submodule add https://github.com/litex-hub/pythondata-software-compiler_rt.git
$ git submodule add https://github.com/litex-hub/pythondata-misc-tapcfg.git

Setup env in Python virtual environnemnt and install dependancies:

$ python3 -m venv venv/pyenv-litex
$ source venv/pyenv-litex/bin/activate
$ pip3 install -r hands-on/requirements.txt
$ deactivate

LiteX depends on other software for simulation and/or FPGA deployment. The following sections detail some of these dependencies.

Verilator

Only needed for simulation

$ sudo apt install libevent-dev libjson-c-dev
$ sudo apt get install verilator

OpenOCD

Only needed to load the bitstream to the FPGA.

$ sudo apt-get install openocd

Riscv toolchain

$ wget  https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz
$ gunzip riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz
$ tar xvf ...
$ add to path

Vivado v2019.1

The installation of Vivado is not detailed here. If you want to generate your own Bitstream you will have to install Vivado.

Make environment artifacts

Create a Vagrant box:

$ vagrant package --output=mic-sec-2022-litex.box
$ sha256sum mic-sec-2022-litex.box.tar.xz | tee mic-sec-2022-litex.box.tar.sha256sum
$ sha256sum --check mic-sec-2022-litex.box.sha256sum

Create a virtual machine:

$ vboxmanage export mic-sec-2022 -o mic-sec-2022-litex.ova
$ sha256sum mic-sec-2022-litex.ova | tee mic-sec-2022-litex.ova.sha256sum