RISC_V交叉编译环境
cd $HOME
mkdir riscv
mkdir source-code
cd source-code
git clone https://gitee.com/lizeyujack/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain
rm -rf riscv-*
- 因为github 克隆之后,还需要更新子模块。所以可以通过镜像网站clone速度快一些。
sudo git clone https://gitee.com/mirrors/riscv-dejagnu.git
sudo git clone -b riscv-gcc-10.2.0 https://gitee.com/mirrors/riscv-gcc.git
sudo git clone -b riscv-glibc-2.29 https://gitee.com/mirrors/riscv-glibc.git
sudo git clone https://gitee.com/mirrors/riscv-newlib.git
sudo git clone -b riscv-binutils-2.35 https://gitee.com/mirrors/riscv-binutils-gdb.git riscv-binutils
sudo git clone -b fsf-gdb-10.1-with-sim https://gitee.com/mirrors/riscv-binutils-gdb.git riscv-gdb
- 下载依赖库
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
sudo apt-get install libnewlib-dev
下面的NUM_CPU=2
可以修改为自己的电脑的CPU数量
INSTALL_PATH='/opt/riscv'
NUM_CPU=2
export PATH=$PATH:$INSTALL_PATH/BIN
./configure --prefix=$INSTALL_PATH
sudo make -j$NUM_CPU
这一步需要好久,1个多小时,请耐心等待
https://zhuanlan.zhihu.com/p/72862396
https://blog.csdn.net/qq_40836704/article/details/120391584