Skip to content

lthw148/RustOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

FlexPRET & RustOS Setup Guide

Contributors: William Brunton - Wbru608@aucklanduni.ac.nz Luce Thwaites - lthw148@aucklanduni.ac.nz

This guide provides step-by-step instructions to set up the FlexPRET processor, RustOS operating system, and Python GUI environment on Windows using WSL (Windows Subsystem for Linux). Refer to the markdown file API.md in the RustOS sub folder for a full list of API functions

About the Components:

  • FlexPRET: A fine-grained multithreaded RISC-V processor designed for mixed-criticality systems
  • RustOS: A hard real-time operating system written in Rust, specifically targeted for the FlexPRET processor
  • Python GUI: A PyQt5-based graphical interface for development and testing

Prerequisites

  • Windows 10/11 with WSL support
  • Administrator access

Part 1: Set Up WSL

Open PowerShell as Administrator and install Ubuntu:

wsl --install -d Ubuntu

After installation, open your Ubuntu terminal and install Git:

sudo apt update
sudo apt install git

Part 2: Set Up FlexPRET

Clone the FlexPRET Repository

git clone https://github.com/pretis/flexpret.git
cd flexpret/

Install RISC-V Toolchain

sudo wget -q --show-progress https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v14.2.0-2/xpack-riscv-none-elf-gcc-14.2.0-2-linux-x64.tar.gz -O gcc.tar.gz
sudo tar xvf gcc.tar.gz --directory=/opt
ls -l /opt/xpack-riscv-none-elf-gcc-14.2.0-2

Install Verilator

sudo apt install verilator
verilator --version

Install Build Dependencies

git submodule update --init --recursive
sudo apt install cmake make gcc g++ openjdk-11-jdk

Install Scala/SBT

sudo apt-get update
sudo apt-get install apt-transport-https curl gnupg -yqq
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo -H gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
sudo chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
sudo apt-get update
sudo apt-get install sbt

Configure Environment

echo 'export RISCV_TOOL_PATH_PREFIX=/opt/xpack-riscv-none-elf-gcc-14.2.0-2' >> ~/.bashrc
source ~/.bashrc

Create Symbolic Links

sudo ln -s /opt/xpack-riscv-none-elf-gcc-14.2.0-2/bin/riscv-none-elf-objdump /bin/riscv-none-elf-objdump
sudo ln -s /opt/xpack-riscv-none-elf-gcc-14.2.0-2/bin/riscv-none-elf-objcopy /bin/riscv-none-elf-objcopy
sudo ln -s /opt/xpack-riscv-none-elf-gcc-14.2.0-2/bin/riscv-none-elf-gcc /bin/riscv-none-elf-gcc

Build FlexPRET

source env.bash
cmake -B build && cd build
make all install

Build and Test SDK

cd ../sdk
cmake -B build && cd build
make && ctest

Part 3: Set Up RustOS

Clone RustOS Repository

cd ../../../
git clone https://github.com/lthw148/RustOS.git
cd RustOS/rust_no_std

Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sudo apt install rustup
rustup target add riscv32i-unknown-none-elf

Install Python and Development Tools

sudo apt install python3 python3-pip python3-venv xxd llvm

Set Up Python Virtual Environment

python3 -m venv venv_pyqt
source venv_pyqt/bin/activate
pip install PyQt5

Install X11 Dependencies

sudo apt-get update
sudo apt-get install -y \
    libxcb-xinerama0 \
    libxcb-xinerama0-dev \
    libxkbcommon-x11-0 \
    libxcb1 \
    libx11-xcb1

sudo apt install libxcb* libx11-xcb* libxkbcommon-x11-0

Part 4: Windows-Specific Setup

Required Windows Applications

Download and install the following executables on your Windows host:

  1. ActiveTCL 8.6

  2. VcXsrv - X Server for Windows

Configure VcXsrv

Start VcXsrv with the following settings:

  • Display number: 0
  • Enable "Multiple Windows"
  • Start "no client"
  • Disable access control (important for WSL connectivity)

Configure WSL Display

echo 'export DISPLAY=:0' >> ~/.bashrc && source ~/.bashrc

After completing all steps, you should be able to run the script file ./compile_gui to run the python GUI. Copying the contents from the test.rs into main allows to do array summation testing.


Additional Resources

About

Part 4 project - Project #134: RustOS: A real-time Rust operating system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •