前后共需安装哪些工具
RISCV-GNU-Toolchain, riscv-isa-sim(即Spike, 它现在是riscv-tools的一部分,我是单独下载的), riscv-pk(也在riscv-tools中)
RISCV-GNU-Toolchain
我之前是安装了nuclei的工具链,本来以为就不用安装了,后来发现编译riscv-tools的工具必须有gnu工具链的支持。
#安装依赖
sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain
mkdir build
cd build
../configure --prefix=$RISCV --enable-multilib
sudo make -j6 #可以根据自己的电脑调整,我已开始没有开并行编译了好久没编译完
$RISCV是自己export的一个环境变量
这个下载的时间还挺长的,要注意网络畅通
riscv-isa-sim(Spike)
以前还需要安装riscv-fesvr, 现在已经包含在riscv-isa-sim中了
git clone https://github.com/riscv-software-src/riscv-isa-sim.git
mkdir build
cd build
../configure --prefix=$RISCV --host=riscv64-unknown-elf #其实我这里安装的时候没有配置host,但最后也成功运行了,官方说明是需要的
make
make install
riscv-pk
如果安装好spike并运行时弹出error
terminate called after throwing an instance of 'std::runtime_error’
what(): could not open pk (did you misspell it? If VCS, did you forget +permissive/+permissive-off?)
说明没有spike没有发现pk,pk(proxy kernel)包含了一个boot loader和一个能处理系统调用的代理内核。
git clone https://github.com/riscv-software-src/riscv-pk.git
mkdir build
cd build
../configure --prefix=$RISCV --host=riscv64-unknown-elf
make
make install
hello world 成功