Skip to content

dwt/fpga-riscv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Was wollen wir erreichen?

  • RiscV Prozessor auf Orangecrab synthetisieren
  • Linux darauf booten
  • MicroPython darauf booten

Neues Board OrangeCrab

  • Wir haben: orange_crab 85F
  • dfu modus um bitstream zu patchen: button gedrückt halten auf dem orangecrab board bis die LEDs nicht mehr flashen, sondern pulsieren -> dann dfu ready, je nach geladener executable muss man das während dem anstecken machen
  • exit dfu mode: dfu-util --alt 0 --detach
  • das board hat 2 DFU-Interfaces:
    • ALT 0: BITSTREAM # hier kann man riscv code aufspielen
    • ALT 1: RISC-V FIRMWARE # das ist der FPGA bitstream

Docs

Micropython on bare metal (LiteX VexRiscV) bauen TODO

TODO

  • modify build scripts to place build folder in top level instead of in in linox-on-litex folder
    • probably we don't need it anymore? cold be that we need something like micropython-on-litex?
    • wir brauchen aber auch irgendwelche hardwareinformationen aus dem litex projekt
  • Vermutung die nix toolchain hardcoded die libc aus dem nix store, anstatt die aus dem litex projekt gebaute libc zu verwenden

Versuch bare bones Beispiele auf VexRiscV zum laufen zu kriegen

Was haben wir gemacht

31-load-bare-boanes-blinker.sh

Versuch micropython für VexRicsV auf LiteX und Zephyr zum laufen zu kriegen

Versuch linux-on-litex-vexriscv zum laufen zu kriegen

Diesen Build Anweisungen folgen wir

  • siehe Scripte 21-29

  • Welche scripte haben wir ausgeführt

    • bin/install-litex.sh
    • bin/build-bitstream-for-orangecrab.sh
    • bin/load-bitstream-for-orangecrab.sh
    • missing: compile-linux-for-orangecrab

    • bin/load-linux-for-orangecrab.sh

Damit haben wir ein Linux (pre-compiled downlaoded from bug...) gestartet und kriegen eine shell auf dem gerät.

Nächste Experimente:

  • können wir die gebaute orangecrab.dtb statt der downloaded rv32.dtb verwenden? Oder die gebaute rv32.dtb?
  • können wir ein neueres (downloaded from somewhere) Image und rootfs.cpio verwenden?

Zephyr bauen

Vermutlich kommen wir weiter wenn wir der ci von zepyhr-on-litex folgen

hat nicht funktioniert

Versuch OSS-CAD-Suite zu verwenden

  • Installation OSS-CAD-Suite
  • [Installation litex] git clone git@github.com:enjoy-digital/litex.git
    • Virtualenv aktivieren, init + install
  • brew install riscv64-elf-binutils brew install riscv64-elf-gcc

Resultat: Alles schit, die distribution ist kacke, ab in Docker damit.

Links

What we did

  • Checkout f4pga-examples

    git clone https://github.com/chipsalliance/f4pga-examples
    cd f4pga-examples
  • Start toolchain with docker

    docker run --rm -it \
        -v /$(pwd)://wrk \
        -w //wrk \
        gcr.io/hdl-containers/conda/f4pga/xc7/a50t

Build picosec demo

  • Run the toolchain in the container to generate the designs

    TARGET="arty_35" make -C xc7/picosoc_demo
  • Install the openFPGALoader via homebrew and then run that on the host

    TARGET="arty_35" make -C xc7/picosoc_demo download

Build VexRiscV CPU with old version of example code

  • Install cross compilation toolchain (TODO check if this is really required fro this):

    apt update
    apt install gcc-riscv64-linux-gnu
    
  • Build CPU

    # normaler build, kein ethernet, 32k rom
    ./src/litex/litex/boards/targets/arty.py --toolchain=symbiflow --cpu-type=vexriscv --sys-clk-freq 80e6 --output-dir build/vexriscv/arty_35 --variant a7-35 --build
    # ethernet, 64kb rom (32 lief über)
    ./src/litex/litex/boards/targets/arty.py --toolchain=symbiflow --cpu-type=vexriscv --sys-clk-freq 80e6 --output-dir build/vexriscv/arty_35 --variant a7-35 --build --with-ethernet --integrated-rom-size 65536
    
  • Deploy

    openFPGALoader -b arty_a7_100t ./xc7/litex_demo/build/vexriscv/arty_35/gateware/arty.bit
    
  • Connect via Serial: baud: 115200, data bits: 8, parity: none, stop bits: 1, path: /dev/cu.usbserial-210319B580D41 (serial port 2)

Build VexRiscV CPU with current CPU Definitions via Zephyr Project

git clone --recursive https://github.com/litex-hub/zephyr-on-litex-vexriscv.git

cd zephyr-on-litex-vexriscv

# compilation needs to happen in container (slow, so make a checkpoint at some point after the build to speed up future builds)
docker run --rm -it \
      -v /$(pwd)://wrk \
      -w //wrk \
      gcr.io/hdl-containers/conda/f4pga/xc7/a50t

apt update
apt install gcc-riscv64-linux-gnu cmake
pip install requests packaging west

conda config --system --set always_yes yes
conda install -c timvideos gcc-riscv64-elf-nostdc openocd meson

source init

./make.py --board=arty --variant=a7-35 --build --toolchain=symbiflow --sys-clk-freq=80e6

now we can connect via serial (port 2!!) on the host

openFPGALoader -b arty_a7_100t zephyr-on-litex-vexriscv/build/digilent_arty/gateware/digilent_arty.bit

Back in the container:

This is problematic, we want a newer version of python for the current dependencies, but the image has python3.7. The images theoretically could build with newer debian versions, but thats currently broken.

What can we do?

  • Debug the github actions and understand why they don't work
  • Go back to an older version of zephyr.
  • Look for packaged toolchains in some linux distributions

The last option is probably much easier for now.

conda deactivate
mkdir west
cd west
python3.11 -m venv venv
source venv/bin/activate
pip install west
apt install git
west init . && \
west update && \
west zephyr-export && \
pip install -r zephyr/scripts/requirements.txt

Was ging nicht

  • in dem docker container zephyr bauen ist explodiet. Ausgerechnet tar…

Was ging

Wir haben auf macos den zephyr sdk native installiert https://docs.zephyrproject.org/latest/develop/getting_started/index.html#install-zephyr-sdk

https://github.com/zephyrproject-rtos/sdk-ng/releases/

In $HOME/.local/opt

brew install cmake ninja meson

pipx install west
mkdir west
cd west
west init .
west update
west zephyr-export
mkvirtualenv west
pip install -r zephyr/scripts/requirements.txt

cd zephyr
west build -p always -b litex_vexriscv samples/hello_world

bash
cd zephyr-on-litex-vexriscv
source init
litex_term.py  /dev/tty.usbserial-210319B580D41 --speed 115200 --kernel ../west/zephyr/build/zephyr/zephyr.bin

Serial Connection

Nächste Schritte

Links to base images

Wir brauchen einen neuen Ansatz

Die alten Docker images sind… 💩 Alles mögliche ist in dem Virtualenv installiert was da nicht reingehört. (Das liegt vielleicht an Conda?).

Inzwischen scheint die Packetierung der Tools viel besser geworden zu sein, vielleicht kann man inzwischen sogar nativ installieren? -> homebrew, nix.

Ein nix flake angeben zu können für: Damit kann man das ausprobieren in einer nix-shell wäre schon fein.

Einige Links um zu starten:

About

Trying to get the build chain working to use open source tools to synthesize a riscv chip and run software on it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors