Compilation and use of rocket-chip tool chain
[Copy link]
Compilation steps of rocket-chip toolchain:
1. Configure the Ubuntu environment first. The tutorials on GitHub are all based on Ubuntu. This is why Ubuntu is recommended for Linux systems. Install the following tools and make sure that the version of GCC is greater than or equal to 4.8.
$ sudo apt-get install autoconf automake autotools-dev curl device-tree-compiler libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat1-dev pkg-config
Copy code
2. Then enter the directory of riscv-tools to update the directory. Because riscv-tools has too much content, it needs to be updated twice. At the same time, you need to set environment variables, and the specific path should be configured according to your needs.
$ cd rocket-chip/riscv-tools
$ git submodule update --init --recursive
$ export RISCV=/path/to/install/riscv/toolchain
Copy code
3. The third step is to compile the cross toolchain. I usually use the build.sh script directly to compile all the tools. I generate a 32-bit cross toolchain.
$ ./build.sh
Copy code
4. The fourth step is a long wait. The longest compile time of the riscv-tools tool is riscv-gnu-toolchain. The compile time of other tools is not too bad. You need to wait until all tools are compiled successfully.
Problems you may encounter when compiling a cross-toolchain:
1. The problem of "c++11" appears:
This problem is caused by the gcc version being too low. The gcc version cannot be lower than 4.8. You can use gcc –version to view the gcc version.
2. The message "error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+" appears. This is because the version of gcc's dependent tools is not high enough. You can try the following operations:
cd <riscv-tools>/riscv-gnu-toolchain/riscv-gcc
contrib/download_prerequisites
sudo yum install gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel
Copy code
3. Don't be afraid of errors. Just search for corresponding keywords in Google/Baidu according to the error prompt to find the solution, because most errors are caused by the improper configuration of Ubuntu environment. As long as all the tools in the first step are installed successfully, the cross tool chain will be compiled successfully.
|