CS378H: Concurrency: Honors: Lab #5: FPGAs: Cascade Environment Instructions

This document provides instructions for bringing up the Cascade Lab Development environment on a Windows, MacOS, or Linux machine. These instructions are certified to work with Windows 10, macOS Mojave, and Ubuntu 16.04, 18.04, and 18.10.

Linux is the preferred environment for running Cascade and interfacing with the DE10-Nano. Cascade cannot currently be compiled on Windows and macOS lacks the drivers necessary for interfacing with the DE-10 boards. Therefore, you will need to install Linux in order to access all the features of Cascade needed for this lab. For most students, this will involve running Linux from within a VirtualBox VM. While it is also possible to install Linux natively or with commercial VM software, you do so at your own risk. If you already have admin privileges on a native Linux installation, you can skip the appropriate sections.

Installing VirtualBox

Installing VirtualBox is fairly straightforward. You will want to visit the VirtualBox downloads page (virtualbox.org/wiki/Downloads) and grab the latest copy of VirtualBox for Windows or OS X as well as the corresponding version of the VirtualBox Extension Pack. The Extension Pack enables better USB and graphics support that you will likely want to take advantage of.

To install VirtualBox on Windows, simply run VirtualBox-*-Win.exe. On macOS, open VirtualBox-*-OSX.dmg and run VirtualBox.pkg from the newly-mounted disk image. The installer is pretty straightforward, just follow the directions and opt to install USB drivers if prompted. After VirtualBox is installed, open it and install the Extension Pack. VirtualBox may prompt to do this automatically or you may have to do so manually via the Extensions pane in the Settings / Preferences dialog.

Creating a Linux VM

Once you have Virtualox set up, you'll need to set up a Linux VM. If you would like to get started as soon as possible, we've prepared a VM with all the necessary software that you can import and start using right away. However, if you already have a Linux VM, would like to customize your installation, or want to learn more about installing Linux, Cascade, and Quartus, we also have instructions for setting up your own VM.

Importing an Existing VM

First, start by downloading our prebuilt VM: Cascade.ova. This will take a while as the VM is several GB in size. Once that's done, import the VM with File→Import Appliance. Select Cascade.ova and wait for the import to complete. You may want to tweak a few VM settings, like reducing the RAM allocation if your computer has 8 or less GB of RAM.

To verify everything worked, launch the VM. The default username is "cascade" and the default password is "password". You should see a few folders on the desktop: cascade, containting a ready-to-run copy of the Cascade repo; intelFPGA_lite, containing an installation of Intel's Quartus FPGA software; and cascade.zip, containing a ZIPed copy of a clean version of the Cascade repo. You may want to install updates, pull the latest copy of Cascade, and do a clean build to make sure you have the latest bug fixes.

Creating a New VM

If you would like to create a VM from scratch, the following instructions should work for Ubuntu or other Debian-based distributions. We recommend Ubuntu 18.04 and 18.10 as we know Cascade works well with these releases.

Installing Cascade and Quartus on Linux

Note: Cascade should already be installed if you're using the prebuilt VM: Cascade.ova. However, if there are changes or bug fixes (god forbid), you may need to update it on the VM with a git pull; make clean; make

Once your Linux installation is working, you'll need to install Cascade on it. If you want to use Cascade's JIT functionality, you'll also need to install Intel's FPGA compiler, Quartus, as well.

Setting up Cascade on the DE10-Nano

NOTE: some set up of Cascade on the DE10 is required whether you use our pre-built VM or not. The simplest way is to use the microSD card image below. Alternatively, you can ssh into the DE10 and build cascade from the command line.

Once you've got your Linux installation working, you will be able to use all the Verilog capabilities necessary to write your code for the lab. However, since the hardware you describe with your code is being simulated in software, you may find it runs slower than desired. For this purpose, Cascade can take advantage of the FPGA on the DE10-Nano to run your hardware as intended. This required getting Linux working on the DE10 (to run Cascade), configuring your VM to be able to connect to the DE10, and configuring Linux on your VM to do the JIT compliation to convert your Verilog to an actual hardware configuration.

Due to the complexity of getting Cascade running on a DE10-Nano, we have compiled a microSD card image that contains everything you need to get Cascade running on the DE10. Before proceeding make sure you have:

Initialize the microSD Card

First, pass through the SD card reader to the virtual machine. In VirtualBox, go to Devices→USB in the menu, and select your SD card reader. It will probably contain the name Card Reader or similar.

Next, determine which device Linux has assigned to your SD card reader. It is extremely important that you get this right as overwriting the wrong device can cause you to lose all the files in your VM and make it unusable. Open the Disks utility and select the entry on the right corresponding to your microSD reader. On the right window, look for Device /dev/sdX# and note the letter corresponding to the microSD reader. We will assume it will be Device /dev/sdb in these instructions, but be sure to change the device name if it's different for you.

Once you've identified the microSD device name, open a terminal and navigate to the directory you downloaded the image to. We will use the dd utility to update the image. The next steps will overwrite the microSD card, so make sure you don't have any files you want to keep on it!

First, make sure all partitions on the SD card are unmounted. Run: sudo umount /dev/sdb*

Then, we'll use the dd utility to copy the image over, 4 megabytes at a time, decompressing the image as we go:

tar xzOf cs378h.tar.gz | sudo dd of=/dev/sdb bs=4M

When dd is done, it will output something similar to:

463+1 records in
463+1 records out
1945317376 bytes (1.9 GB, 1.8 GiB) copied, 55.269 s, 35.2 MB/s

The microSD card is now initialized with Linux and ready to go. Insert it into the slot on the underside of the DE10 with the pins facing toward the board.

Connecting to the DE-10

First, start by connecting the USB cables according to the following image. Make sure the Mini-USB cable is connected to the JTAG programming port (see DE-10 documentation, it should be opposite the Ethernet jack and not next to where the smaller Micro-USB cable connects, which is the UART port). Make sure to give the device some time to boot before connecting the cables to your computer. The Ethernet cable here is optional and does not need to be connected.

In order to access the DE-10 from your VM, you'll want to configure device filters under the the VM's settings→Ports→USB pane. You can add a filter by clicking the plus button and selecting a currently-detected USB device to capture. The Micro-USB cable should show up as Linux 4... or as Netchip RNDIS/Ethernet. It is important to add a filter for this device now because your OS may prevent you from passing it through if it's not captured as soon as it's attached. After you've started your VM, reconnect this cable and check the Devices→USB menu to look for a check mark to make sure it was captured properly. If it wasn't, you may need to reconnect the cable until it is.

The Mini-USB cable should show up as Altera DE-SoC, but may only show up as Altera until after the VM starts or after reconnecting the cable a couple times. If you're seeing the Altera device, don't bother adding a filter for it because VirtualBox treats it differently from the Altera DE-SoC. Note that this cable can be attached to the VM after it's plugged in, so adding a device filter is merely a matter of convenience in this case.

In the virtual machine, you should be able to now SSH into the Ubuntu 18.04 installation running on the ARM cores of the DE10. The username and password are both set to fpga, and the IP address will be 192.168.7.1. In a terminal, connect using:

ssh fpga@192.168.7.1

Type yes to trust the device if prompted, and enter the password.

Connecting the DE-10 to the Internet

Without a network cable connected, the DE10 will have no access to the network. Given that you may not have an Ethernet cable, the most straightforward way to connect the DE10 to the internet is via the very USB cable that connects your VM to it. The following instructions will walk you through how to share your VM's internet connection over USB by setting up IP forwarding.

In the VM (not in a SSH session to the FPGA) type:

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null
sudo iptables -P FORWARD ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24

This will enable network address translation and forward packets coming from 192.168.7.*, which includes the FPGA. From an SSH session with the FPGA you can verify network connectivity by running something like the following command and looking for responses to your packets:

ping google.com

To turn off forwarding, you can type:

echo 0 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null
sudo iptables -t nat -F POSTROUTING
If you want to use a traditional Ethernet connection, connecting the DE10 to a router via an Ethernet cable works as well. However, if you are doing this from within the CS building, you will have to authenticate before being allowed to connect. This can be done by running the following command after inserting your UTCS username and password into the appropriate slots:
curl -d "username=XX&password=YY" https://horatio.cs.utexas.edu/login.cgi

Configuring your VM as a JIT Compiler

In order for Cascade to be able to reprogram the DE10's FPGA, your Mini-USB cable needs to be connected properly. To verify this, run sudo ./bin/jtagconfig from your quartus install directory (e.g. "~/Desktop/intelFPGA_lite/18.1/quartus/") and look to see if a DE-SoC device was detected. See the JIT Backend section of the Cascade README for more information. If the device isn't detected, double-check your VM device filters, and try disconnecting the JTAG cable, running sudo killall jtagd, and reconnecting the cable. Note that when running quartus_server, your quartus path should look something like the one given above (possibly including the quotes). You will likely have to run quartus_server as sudo to ensure it can access the JTAG device.

Finally, you should be able to run Cascade using the de10_jit backend from the DE-10 itself using 192.168.7.2 or 192.168.7.5 as the Linux IP parameter. You may also need to use quartus_host instead of quartus_server to specify the destination IP address. If you get a connection error, you may need to restart the quartus_server application on your Linux VM.

Acknowledgements

Thanks to Eric Schkufza and Michael Wei of VMware Research Group for supporting this lab. Thanks to our department head Don Fussell for supporting the project by helping find funds to enable us to loan DE10 hardware to every student.