1# README # 2 3This repository, maintained by SiFive, Inc, makes it easy to get started developing software for the Freedom E RISC-V platform. 4 5### Contents ### 6 7* RISC-V Software Toolchain 8* RISC-V Debugging Toolchain 9* Board Support Packages for FE310 and Development Kits 10* A Few Example Programs 11 12### Setting up the SDK ### 13 14First, clone this repository: 15 16``` 17git clone --recursive https://github.com/sifive/freedom-e-sdk.git 18``` 19 20To see Makefile options: 21 22``` 23cd freedom-e-sdk 24make help 25``` 26 27#### Building Tools from Source #### 28 29Ubuntu packages needed: 30 31 $ 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 32 33Next, build the tools: 34 35``` 36cd freedom-e-sdk 37make tools [BOARD=freedom-e300-hifive1] 38``` 39 40If your machine has enough resources, you can speed up the build process by adding `-j n` to `make`, where `n` is the number of processors of your build system. 41 42 43#### Using Pre-Built Binary Tools #### 44 45If you would like to avoid compiling the tools from source, they are 46available as pre-built binaries from 47 48https://sifive.com/products/tools 49 50For OpenOCD and/or RISC-V GNU Toolchain, 51download the .tar.gz for your platform, and unpack it to 52your desired location. Then, use the `RISC_PATH` and `RISCV_OPENOCD_PATH` 53variables when attempting to use the tools: 54 55``` 56cp openocd-<date>-<platform>.tar.gz /my/desired/location/ 57cp riscv64-unknown-elf-gcc-<date>-<platform>.tar.gz /my/desired/location 58cd /my/desired/location 59tar -xvf openocd-<date>-<platform>.tar.gz 60tar -xvf riscv64-unknown-elf-gcc-<date>-<platform>.tar.gz 61export RISCV_OPENOCD_PATH=/my/desired/location/openocd 62export RISCV_PATH=/my/desired/location/riscv64-unknown-elf-gcc-<date>-<version> 63``` 64 65### Updating your SDK ### 66 67If you'd like to update your SDK to the latest version: 68 69``` 70cd freedom-e-sdk 71git pull origin master 72git submodule update --init --recursive 73``` 74 75If you would like to recompile the entire toolchain after performing the above: 76 77``` 78make uninstall 79make tools 80``` 81### Using the Tools ### 82 83To compile a bare-metal RISC-V program: 84 85``` 86cd freedom-e-sdk 87make software [PROGRAM=demo_gpio] [BOARD=freedom-e300-hifive1] 88``` 89 90Run `make help` for more commands. 91 92### Benchmarking ### 93 94#### Dhrystone #### 95 96After setting up the software and debug toolchains, you can build and 97execute everyone's favorite benchmark as follows: 98 99- Compile the benchmark with the command `make software PROGRAM=dhrystone`. 100- Run on the HiFive1 board with the command `make upload PROGRAM=dhrystone`. 101 This will take a few minutes. Sample output is provided below. 102- Compute DMIPS by dividing the Dhrystones per Second result by 1757, which 103 was the VAX 11/780's performance. In the example below, 729927 / 1757 = 104 415 DMIPS. 105- Compute DMIPS/MHz by dividing by the clock rate: in the example below, 106 415 / 260 = 1.60 DMIPS/MHz. 107 108``` 109core freq at 259830579 Hz 110 111Dhrystone Benchmark, Version 2.1 (Language: C) 112 113<snip> 114 115Microseconds for one run through Dhrystone: 1.3 116Dhrystones per Second: 729927.0 117``` 118 119#### CoreMark #### 120 121We cannot distribute the CoreMark benchmark, but following are instructions 122to download and run the benchmark on the HiFive1 board: 123 124- Download CoreMark from EEMBC's web site and extract the archive from 125 http://www.eembc.org/coremark/download.php. 126- Copy the following files from the extracted archive into the 127 `software/coremark` directory in this repository: 128 - `core_list_join.c` 129 - `core_main.c` 130 - `coremark.h` 131 - `core_matrix.c` 132 - `core_state.c` 133 - `core_util.c` 134- Compile the benchmark with the command `make software PROGRAM=coremark`. 135- Run on the HiFive1 board with the command `make upload PROGRAM=coremark`. 136- Divide the reported Iterations/Sec by the reported core frequency in MHz to 137 obtain a CoreMarks/MHz value. 138 139### For More Information ### 140 141Documentation, Forums, and much more available at 142 143[dev.sifive.com](https://dev.sifive.com) 144