参加几次 WHLUG (Wuhan Linux User Group)观察羊和我进行 RISC-V 相关分享的观众反响进行了新的分享预案。

构建使用 spike

git clone https://github.com/riscv-software-src/riscv-isa-sim.git
cd riscv-isa-sim
export RISCV=/opt/riscv (路径自行选择,此处我选的是/opt/riscv)
mkdir build;cd build
../configure –prefix=$RISCV
make -j $(nproc)
sudo make install
git clone https://github.com/riscv-software-src/riscv-pk.git
cd riscv-pk
mkdir build;cd build
../configure --prefix=$RISCV --host=riscv64-unknown-elf
make -j $(nproc)
sudo make install

构建使用 riscv-gnu-toolchain

sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip python3-tomli libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev

./configure --prefix=$RISCV --with-arch=rv64gc
make -j $(nproc) 2&>1 | tee build.log
./configure --prefix=$RISCV --with-arch=rv64gc
make linux -j $(nproc) 2&>1 | tee build-linux.log
./configure --prefix=$RISCV --enable-llvm --with-arch=rv64gc
make -j $(nproc) 2&>1 | tee build-llvm.log
$RISCV/bin/riscv64-unknown-elf-gcc hello.c -o hello
make build-qemu
$RISCV/bin/qemu-riscv64 hello
$RISCV/bin/spike pk hello