├── .gitignore ├── .gitmodules ├── env.sh ├── manifest.scm ├── README.md └── Makefile /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /toolchain 3 | /crates 4 | /files 5 | /profile* 6 | *.o 7 | *.a 8 | *.rlib 9 | *.ll 10 | *.s -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "binutils"] 2 | path = riscv-binutils-gdb 3 | url = https://github.com/riscv/riscv-binutils-gdb 4 | branch = riscv-binutils-2.29 5 | [submodule "openocd"] 6 | path = riscv-openocd 7 | url = https://github.com/riscv/riscv-openocd 8 | branch = riscv 9 | -------------------------------------------------------------------------------- /env.sh: -------------------------------------------------------------------------------- 1 | # Copy to project and change RISCV_RUST_TOOLCHAIN path 2 | export RISCV_RUST_TOOLCHAIN=$PWD 3 | 4 | export TOOLCHAIN=$RISCV_RUST_TOOLCHAIN/toolchain 5 | export PATH=/opt/rust/bin:$TOOLCHAIN/bin:$PATH 6 | export RUST_TARGET_PATH=$RISCV_RUST_TOOLCHAIN 7 | export CARGO_HOME=$RISCV_RUST_TOOLCHAIN/build/cargo 8 | export XARGO_HOME=$RISCV_RUST_TOOLCHAIN/build/xargo 9 | export XARGO_RUST_SRC=~/repos/rust/src 10 | -------------------------------------------------------------------------------- /manifest.scm: -------------------------------------------------------------------------------- 1 | (use-package-modules autotools base bash bison bootloaders cmake commencement 2 | compression curl documentation elf file flex gawk gcc 3 | libedit libusb multiprecision ninja ncurses pkg-config 4 | python shells ssh swig texinfo tls version-control xml) 5 | 6 | (packages->manifest 7 | (list autoconf 8 | automake 9 | bash 10 | bison 11 | cmake 12 | coreutils 13 | curl 14 | dtc 15 | diffutils 16 | doxygen 17 | expat 18 | file 19 | findutils 20 | flex-2.6.1 21 | gawk 22 | gcc-toolchain-6 (list gcc-6 "lib") 23 | git 24 | gmp 25 | gnu-make 26 | grep 27 | gzip 28 | libedit 29 | libssh2 30 | libtool 31 | libusb 32 | libxml2 33 | mpc 34 | mpfr 35 | ninja 36 | ncurses 37 | openssl 38 | patchelf 39 | pkg-config 40 | python-2 41 | sed 42 | swig 43 | tar 44 | texinfo 45 | which 46 | zlib 47 | zsh)) 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OBSOLETE 2 | 3 | This is no longer the recommended way to get a Rust toolchain for RISCV. 4 | Instead, you can clone the [riscv-rust/rust](https://github.com/riscv-rust/rust) 5 | fork of Rust and build it as normal: 6 | 7 | ./x.py build 8 | 9 | You can use 10 | 11 | make toolchain 12 | 13 | to build binutils and openocd for RISCV. 14 | 15 | # Rust Toolchain for RISCV 16 | ## Supported boards 17 | * hifive (RV32IMAC) 18 | 19 | ## Getting started 20 | 1. Get the source 21 | ```sh 22 | git clone --recursive https://github.com/riscv-rust/riscv-rust-toolchain 23 | cd riscv-rust-toolchain 24 | ``` 25 | 26 | 2. Install build dependencies 27 | See [manifest.scm](https://github.com/riscv-rust/riscv-rust-toolchain/blob/master/manifest.scm) 28 | for a list of the required build dependencies. 29 | 30 | 3. Build the toolchain 31 | A list of all set environment variables is in build-env.sh, adapt 32 | to your distro if necessary. 33 | 34 | ```sh 35 | # Builds llvm openocd binutils rust and xargo 36 | make toolchain 37 | ``` 38 | 39 | 4. Clone quickstart template 40 | ```sh 41 | git clone https://github.com/riscv-rust/riscv-rust-quickstart 42 | cd riscv-rust-quickstart 43 | ``` 44 | 45 | 5. Follow instructions in riscv-rust-quickstart's [README.md](https://github.com/riscv-rust/riscv-rust-quickstart/blob/master/README.md) 46 | 47 | ## RISCV crates 48 | * [riscv](https://github.com/riscv-rust/riscv) crate provides routines for riscv 49 | specific asm instructions and reading/writing csr's. 50 | 51 | * [riscv-rt](https://github.com/riscv-rust/riscv-rt) crate provides startup code, 52 | linker script and interrupt handling code. 53 | 54 | * [e310x](https://github.com/riscv-rust/e310x) crate is a svd2rust generated api 55 | to Freedom E310 MCU peripherals. 56 | 57 | * [hifive](https://github.com/riscv-rust/hifive) crate is a board support crate for 58 | the hifive board. 59 | 60 | ## License 61 | ISC License 62 | 63 | Copyright (c) 2017, David Craven 64 | 65 | Permission to use, copy, modify, and/or distribute this software for any 66 | purpose with or without fee is hereby granted, provided that the above 67 | copyright notice and this permission notice appear in all copies. 68 | 69 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 70 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 71 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 72 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 73 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 74 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 75 | PERFORMANCE OF THIS SOFTWARE. 76 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | root_dir := $(CURDIR) 2 | build_dir := $(root_dir)/build 3 | sysroot_dir := $(root_dir)/toolchain 4 | target := riscv32-unknown-elf 5 | nproc := 6 | makeflags := $(if $(nproc),-j$(nproc)) 7 | ccache := $(shell which ccache) 8 | 9 | 10 | all: toolchain 11 | 12 | clean: 13 | $(RM) -r build toolchain 14 | 15 | toolchain: openocd binutils 16 | @echo All Tools Installed 17 | 18 | 19 | # RUST + CARGO 20 | rust_src := $(root_dir)/rust 21 | rust_dest := $(sysroot_dir) 22 | cargo_build := $(build_dir)/cargo 23 | 24 | export RUST_TARGET_PATH=$(root_dir) 25 | export CARGO_HOME=$(cargo_build) 26 | 27 | $(sysroot_dir)/bin/cc: 28 | mkdir -p $(sysroot_dir)/bin 29 | ln -s $(shell which gcc) $(sysroot_dir)/bin/cc 30 | 31 | rust-build: $(sysroot_dir)/bin/cc 32 | python2 rust/x.py install 33 | $(rust_dest)/bin/rustc: rust-build 34 | rust: $(rust_dest)/bin/rustc 35 | 36 | # XARGO 37 | xargo_build := $(build_dir)/xargo 38 | export XARGO_HOME=$(xargo_build) 39 | export XARGO_RUST_SRC=$(rust_src)/src 40 | 41 | xargo-build: 42 | mkdir -p $(xargo_build) 43 | cargo install xargo --root=$(rust_dest) 44 | $(rust_dest)/bin/xargo: xargo-build 45 | xargo: $(rust_dest)/bin/xargo 46 | 47 | # OPENOCD 48 | openocd_src := $(root_dir)/riscv-openocd 49 | openocd_build := $(build_dir)/openocd 50 | openocd_dest := $(sysroot_dir) 51 | 52 | openocd-build: $(openocd_src) 53 | rm -rf $(openocd_build) 54 | mkdir -p $(openocd_build) 55 | cd $(openocd_src) && autoreconf -i 56 | cd $(openocd_build) && $