Skip to content

This Repo contains documentation to the HiFive1 Board along with some example programs.

Notifications You must be signed in to change notification settings

U2654/sifive-hifive1

 
 

Repository files navigation

How to build bare metal applications on HiFive1-Board

This Repository contains some software examples for use with the HiFive1-Board of SiFive and our binary-compatible Riscv-VP (repo). Here, an old version of the freedom-e-sdk of SiFive is pinned and used for buildin/uploading programs.

  1. Prerequisites on ubuntu (see https://github.com/sifive/freedom-e-sdk):

    sudo apt-get install autoconf automake libmpc-dev libmpfr-dev libgmp-dev gawk bison flex texinfo libtool libusb-1.0-0-dev make g++ pkg-config libexpat1-dev zlib1g-dev

  2. Clone and update the sifive--hifive1 repository:

    cd freedom-e-sdk
    git submodule update --init --recursive
  3. Build your own toolchain or download and unpack a pre-build riscv-multilib toolchain, e.g. available from:

    http://satisfy.informatik.uni-bremen.de/gnu-toolchain_riscv-multilib/latest-gnu-toolchain_riscv-multilib.tar.gz

    And make sure that the env variable RISCV_PATH is pointing to your toolchain-dir (without /bin)

    example: export RISCV_PATH="/opt/riscv"

  4. Build openocd (if you want to load a program on the board) in sifive--hifive1/freedom-e-sdk/:

    make openocd # need only to be done once

  5. Build and upload a program to the board:

    make upload-snake

    Optional: If you have the hifive-vp from the riscv-vp repository in your path, you may also start the simulation by typing

    make sim-snake
  6. Show program output:

    screen /dev/ttyUSB1 115200

In case screen does not work use (this may happen when running screen a second time):

`cat /dev/ttyUSB1	# NOTE: need to run screen once before this command works`

Press the reset button on the board to restart (and thus see output). NOTE: /dev/ttyUSB0 is the debug interface.

ZEPHYR OS

To use Zephyr, see zephyr/RREADME.rst. (Install OS Packages, pip packages) To build for HiFive1, use example zephyrrc file, modify for your paths, rename to ~/.zephyrrc and source it(?). Source zephyr-env.sh. Then build your project:

mkdir build && cmake .. -DBOARD=$BOARD
make -j6

Uploading Zephyr-Elfs to board

Basically the same procedure as freedom-e-sdk, but manual.

$ ${SDK_PATH}/work/build/openocd/prefix/bin/openocd -f ${SDK_PATH}/bsp/env/freedom-e300-hifive1/openocd.cfg &
$ riscv32-unknown-elf-gdb
 set remotetimeout 240
 target extended-remote localhost:3333
 monitor reset halt
 monitor flash protect 0 64 last off
 load zephyr/zephyr.elf
 monitor resume

Other Doc

FreeRTOS example uses 14.7kiB out of 16kiB RAM (with 2k stack):

size RISCV_HiFive1_GCC.elf -d
   text	   data	    bss	    dec	    hex	filename
  17079	   1076	  13953	  32108	   7d6c	RISCV_HiFive1_GCC.elf

Zephyr uses with the philosophers demo:

Memory region         Used Size  Region Size  %age Used
	         ROM:       22960 B        12 MB      0.18%
	         RAM:        9440 B        16 KB     57.62%
	    IDT_LIST:         553 B         2 KB     27.00%

Acknowledgements:

This work was supported in part by the German Federal Ministry of Education and Research (BMBF) within the project SATiSFy under contract no. 16KIS0821K.

About

This Repo contains documentation to the HiFive1 Board along with some example programs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.0%
  • Makefile 2.5%
  • Shell 0.5%