0% found this document useful (0 votes)
109 views2 pages

RUST Procedure PDF

The document provides steps to set up a Rust development environment for RISC-V using the riscv-tools toolchain and QEMU emulator. It involves cloning riscv-tools from a Git repository and configuring it to build the riscv32-unknown-linux-gcc cross compiler. Next, it guides setting up Rust with rustup and adding the RISC-V target. QEMU is then cloned and built to enable emulation. Finally, a Rust hello world project is run under QEMU emulation after setting the CC environment variable.

Uploaded by

mjsraman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views2 pages

RUST Procedure PDF

The document provides steps to set up a Rust development environment for RISC-V using the riscv-tools toolchain and QEMU emulator. It involves cloning riscv-tools from a Git repository and configuring it to build the riscv32-unknown-linux-gcc cross compiler. Next, it guides setting up Rust with rustup and adding the RISC-V target. QEMU is then cloned and built to enable emulation. Finally, a Rust hello world project is run under QEMU emulation after setting the CC environment variable.

Uploaded by

mjsraman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

RUST PROCEDURE

● For the riscv tool chain go to “https://gitlab.com/shaktiproject/software/riscv-


tools” and follow all the steps:-
○ git clone “https://gitlab.com/shaktiproject/software/riscv-tools.git”
○ cd riscv-tools
○ git submodule update --init --recursive
○ export SHAKTITOOLS=<give the path to install riscv toolchain>
○ SHAKTITOOLS=/PATH/OF/TOOL
○ export PATH=$PATH:$SHAKTITOOLS/bin
○ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SHAKTITOOLS/lib
○ export PATH=$PATH:$SHAKTITOOLS/riscv64-unknown-elf/bin
○ export PATH=$PATH:$SHAKTITOOLS/riscv32-unknown-elf/bin
● For running we need riscv32-unknown-linux-gcc so, just follow
○ Go inside of the riscv-tools then riscv-gnu-toolchain i.e,
cd riscv-tools/riscv-gnu-toolchain
○ To build the linux cross compiler, pick an install path say choose /opt/riscv
Type: ./configure --prefix=/opt/riscv
make linux
○ After compilation of above steps:
Type: ./configure --prefix=/opt/risccT --with-arch=rT2ggc --with-abi=ilp2gd
make linux
● After completing the above steps riscv32-unknown-linux-gcc will come if its not come
just export the path i.e, export PATH=$PATH:/opt/riscv/bin and test again.
● Now set up RUST environment:
○ Type: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh (Just install
default version i.e, by pressing 1)
○ Now after completing these steps export the PATH i.e,
export PATH=$PATH:/home/<user>/.cargo/bin
Now all the commands of rust are available i.e, rustc; rustup; cargo\
● To run the above code we need riscv32imac-unknown-none-elf
○ Type: rustup target add riscv32imac-unknown-none-elf
○ Just for checking, Type: rustup target list it will write installed by the side of it.
● Now the final steps we have to install QEMU, Follow the steps below,
○ git clone git://git.qemu.org/qemu.git
○ cd qemu
○ git checkout stable-2.9
○ git submodule init
○ git submodule update --recursive
○ git submodule status --recursive
○ mkdir build ( QEMU is installed in a directory named build which is a sub
directory of the directory that contains your local copy of the QEMU source
code repository. Your command line environment should currently be inside
this build directory. )
○ sudo apt-get install build-essential zlib1g-dev pkg-config libglib2.0-dev

1
binutils-dev libboost-all-dev autoconf libtool libssl-dev libpixman-1-dev
libpython-dev python-pip python-capstone virtualenv
○ cd build
○ ../configure
○ make
● Git Clone: “https://github.com/tomoyuki-nakabayashi/riscv-rust-hello”
○ cd riscv-rust-hello
○ env CC=riscv32-unknown-linux-gnu-gcc cargo run

After this Hello from Rust! is there on the console…

You might also like