Mimas Artix 7 FPGA Development Board

How to Boot Linux on Mimas A7 using LiteX and RISC-V

969 views November 26, 2021 admin 1

Introduction

FPGAs are best known for their flexibility and versatility. Such flexibility allows FPGAs not only to be used for custom logic circuits but also to implement a processor on it and even run Linux (or other Operating Systems) on the processor. You might have got a Linux kernel running in your FPGA board with a MicroBlaze-based design. In this article, we will get Linux boot on the board using LiteX and Migen, and see how it simplifies FPGA designs! The TimVideos projects have LiteX Build Environment for building LiteX and Migen based FPGA designs. We will use LiteX Build Environment to boot Linux on Mimas Artix 7 FPGA Development Board by implementing a RISC-V-based soft CPU on the Artix 7 FPGA. Let’s dive right in.

Prerequisites

  1. Mimas A7 FPGA Development board
  2. Linux system (Ubuntu) with Xilinx Vivado toolchain installed
  3. USB A to USB B cable
  4. Cat 6 Ethernet cable

Let’s get started

The following steps are to be executed in Linux. Open Linux Terminal and follow the steps given below.

Step 1: Download LiteX Build Environment

Download the TimVideos LiteX Build Environment from here to a suitable location in your system. Then in the terminal, change the directory to the litex-buildenv repository. The author has downloaded the litex-buildenv repository into the Home directory. So, the command is as shown below.

cd litex-buildenv

To install the dependency packages required for the Build Environment, run the “download-env.sh” script file.

./scripts/download-env.sh

Step 2: Enter the environment

Before running any of the build steps, you must enter the development environment. This step should be done whenever you select a new terminal window.

First set up the build targets by running the following command.

export PLATFORM=mimas_a7 CPU=vexriscv TARGET=net CPU_VARIANT=linux

The litex-buildenv repository has Mimas A7 platform support, so we can directly set Mimas A7 as the platform. We are going to deploy LiteX SoC with VexRiscv CPU on Mimas A7, so choose “CPU” as vexriscv and “CPU_VARIANT” as linux to enable features such as MMU that are required to get Linux booting.

To set up the environment for the above build targets, run the following command:

source scripts/enter-env.sh

If your environment is set up correctly, your terminal should show something like this:

LX P=mimas_a7 T=net C=vexriscv.linux

Step 3: Build the gateware

Once you have entered the environment, you can build the gateware for the build targets. To build the gateware, run:

make gateware

Building this gateware might take a few minutes. If this command runs successfully, in the end, your terminal window should look similar to the image shown below.

Step 4: Building the kernel

The LiteX Build Environment has a Linux script file for building the kernel. Before running the script, run the following command:

export FIRMWARE=linux

Your terminal should show something like this:

LX P=mimas_a7 T=net C=vexriscv.linux F=linux

Now you can run the following command to build the kernel:

./scripts/build-linux.sh

If the command was successful, you will see the firmware in "build/mimas_a7_net_vexriscv.linux/software/linux/arch/riscv/boot/Image" as in the image below.

Step 5: Get TFTP boot Linux on the Mimas A7

Connect Mimas A7 to your PC using USB A to USB B cable. Also, connect an ethernet cable to the board and its other end to the PC Ethernet port. Setup your Ethernet card to “Address” 192.168.100.100 and “Netmask” 255.255.255.0 as shown in the image below.

Open the Terminal and enter the environment as described in step 2. Run the following command to make sure that you don’t have a TFTP server already running.

make tftpd_stop

Now, start the TFTP server by executing the following command:

make tftpd_start

The output for these commands will be similar to the following image.

Now enter the Linux firmware environment by running the following command:

export FIRMWARE=linux

As described before, your terminal should show something like this:

LX P=mimas_a7 T=net C=vexriscv.linux F=linux #

Let’s now build TFTP firmware by running the following command:

make tftp

If the build was successful, you will get the following output in your terminal window.

Now, run the following command to load the firmware:

make firmware-connect

You will see flterm tool “Starting” that connects to Mimas A7 using /dev/ttyUSB as in the image below.

In the terminal, go to File -> New Window. In the new window, enter the Build Environment as described in step 2 and then run the following command to load the gateware containing the soft CPU onto the FPGA.

make gateware-load

The Done LED on the Mimas A7 should glow when you run this command. It indicates that the gateware is loading onto the board. Once the gateware is loaded, you will see TFTP booting Linux on the soft CPU which is implemented on the FPGA. This is shown in the following images.

At the Buildroot login prompt, you can use root with no password to log in. Now you have a successfully running Linux kernel in your Mimas Artix 7 FPGA Development Board. Congratulations!

Was this helpful?

Leave A Comment
*
*