查看: 2252|回复: 0
收起左侧

开启你RISC-V的开发之旅--RISC-V的linux模拟环境搭建整理和总结

[复制链接]

  离线 

  • TA的每日心情
    奋斗
    2021-3-3 12:32
  • 签到天数: 10 天

    [LV.3]

    发表于 2021-3-4 18:51:23 | 显示全部楼层 |阅读模式

    有人预言,RISC-V或将是继Intel和Arm之后的第三大主流处理器体系。欢迎访问全球首家只专注于RISC-V单片机行业应用的中文网站

    您需要 登录 才可以下载或查看,没有帐号?立即注册

    x
    本帖最后由 皋陶 于 2021-3-4 18:49 编辑

    1. 有关RISC V的开源代码,可以从改网站的连接进入,该网站归纳整理了有关RISC V的多方面资料: https://cnrv.io/resource

    2. 自己的虚拟机或linux系统事先安装好

    3,装好git工具,因为riscv很多开源的东西需要从git上checkout,这样会方便不少

    4. 首先安装开源程序版本管理工具:

    (linux)Fedora/Centos系统上用 yum 安装,

    Debian系统上用apt-get 安装(先安装curl、zlib、openssl、expat、libiconv等库,再从git官网上下载最新版本源代码编译安装);

    windows系统上安装msysGit。

    具体安装说明:http://blog.jobbole.com/25775/

    5. RISC-V工具链

    l  riscv-tools(https://github.com/riscv/riscv-tools) - 基本上所有RISC-V相关工具链、仿真器、测试的宏项目,包含以下的项目
    n  riscv-gnu-toolchain(https://github.com/riscv/riscv-gnu-toolchain) - GNU工具链
    u  riscv-gcc(https://github.com/riscv/riscv-gcc) - GCC 编译器
    u  riscv-binutils-gdb(https://github.com/riscv/riscv-binutils-gdb) - 二进制工具(链接器,汇编器等·)、GDB 调试工具
    u  riscv-glibc(https://github.com/riscv/riscv-glibc) - GNU C标准库实现
    n  riscv-isa-sim(https://github.com/riscv/riscv-isa-sim) - Spike周期精确指令集模拟器
    n  riscv-llvm(https://github.com/riscv/riscv-llvm) -LLVM编译器框架
    u  riscv-clang(https://github.com/riscv/riscv-clang) - 基于LLVM框架的C编译器
    n  riscv-opcodes(https://github.com/riscv/riscv-opcodes) - RISC-V操作码信息和转换脚本
    n  riscv-tests(https://github.com/riscv/riscv-tests) - RISC-V指令集测试用例
    n  riscv-fesvr(https://github.com/riscv/riscv-fesvr) - 用于实现在上位机和CPU之间通信机制的库
    n  riscv-pk(https://github.com/riscv/riscv-pk) - 提供一个运行RISC-V可执行文件运行的最简的程序运行环境,同时提供一个最简单的bootloader
    n  riscv-qemu(https://github.com/riscv/riscv-qemu) - 一个支持RISC-V的CPU和系统模拟器
    gcc configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
    ubuntu自身带有gcc,直接apt-get install gcc(或gc++)安装或更新。

    没有安装的linux系统可从svn checkout svn://gcc.gnu.org/svn/gcc/trunk拿最新的gcc代码。

    即便如此,在执行riscv-tools下的build.sh脚本时,依然会报如下error:

    configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
    Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
    their locations.  Source code for these libraries can be found at
    their respective hosting sites as well as at
    ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
    http://gcc.gnu.org/install/prerequisites.html for additional info.  If
    you obtained GMP, MPFR and/or MPC from a vendor distribution package,
    make sure that you have installed both the libraries and the header
    files.  They may be located in separate packages.
    make: *** [stamps/build-gcc-newlib] 错误 1

    所以在网上搜到了如下解决方法:
        http://www.multiprecision.org/mpc/   下载最新mpc压缩包
        ftp://ftp.gnu.org/gnu/gmp/          下载最新gmp压缩包
        http://ftp.gnu.org/gnu/mpfr/         下载最新mpfr压缩包

    1. 先安装GMP
    解压GMP的压缩包后,得到源代码目录gmp-6.1.2。在该目录的同级目录下建立一个临时的编译目录如temp。进入temp目录,配置安装选项,输入以下命令进行配置:
    1. ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2
    2. make
    3. sudo make install
    复制代码

    2. 先安装mpfr
    解压mpfr的压缩包,得到源代码目录mpfr-3.1.6。进入temp目录,配置安装选项,输入以下命令进行配置:
    1. ../mpfr-3.1.6/configure --prefix=/usr/local/mpfr-3.1.6
    2. ../mpfr-3.1.6/configure --prefix=/usr/local/mpfr-3.1.6 --with-gmp=/usr/local/gmp-6.1.2
    3. make
    4. sudo make install
    复制代码

    3. 先安装mpc
    解压mpc的压缩包,得到源代码目录mpc-1.0.3。进入temp目录,配置安装选项,输入以下命令进行配置:
    1. ../mpc-1.0.3/configure --prefix=/usr/local/mpc-1.0.3
    2. ../mpc-1.0.3/configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-3.1.6
    3. make
    4. sudo make install
    复制代码

    安装/更新gcc:链接的时需要上述3个lib。

    1. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-6.1.2/lib:/usr/local/mpfr-3.1.6/lib 
    2. ../trunk/configure --prefix=/usr/local/gcc-4.8 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-3.1.6 --with-mpc=/usr/local/mpc-1.0.3
    3. make
    4. make check(可选)
    5. sudo make install
    复制代码

    。。。。。。等待。。。。。。

    查看当前gcc版本:
    1. /usr/local/gcc-4.8/bin/g++ -v
    复制代码

    使用内建 specs
    1. COLLECT_GCC=/usr/local/gcc-4.8/bin/g++
    2. COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.4/lto-wrapper
    复制代码

    目标:x86_64-unknown-linux-gnu
    配置为:
    1. ../trunk/configure --prefix=/usr/local/gcc-4.8 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-3.1.6 --with-mpc=/usr/local/mpc-1.0.3
    复制代码

    Boom环境搭建

    1. 从github上克隆boom仿真器:
    1. $ git clone https://github.com/ucb-bar/rocket-chip.git
    2.    $ cd rocket-chip
    3.    $ git checkout boom
    4.    $ git submodule update --init
    5.    $ cd emulator; make run CONFIG=BOOMConfig
    复制代码

    2. RISC-V Toolchain安装
    1. $ export RISCV=/path/to/install/riscv/toolchain   
    2.    $ export PATH="${PATH}RISCV/bin"
    3.    $ git clone https://github.com/ucb-bar/rocket-chip.git
    4.    $ cd rocket-chip
    5.    $ git checkout boom
    6.    $ git submodule update --init
    7.    $ cd riscv-tools
    8.    $ git submodule update --init --recursive
    9.    $ ./build.sh    //安装
    10.    $ cd ../emulator; make run CONFIG=BOOMConfig     //配置为boom模式
    复制代码





    上一篇:RISCV的linux模拟环境搭建整理和总结
    下一篇:E203 itcm
    RISCV作者优文
    全球首家只专注于RISC-V单片机行业应用的中文网站
    回复

    使用道具 举报

    高级模式
    B Color Image Link Quote Code Smilies

    本版积分规则

    关闭

    RISC-V单片机中文网上一条 /2 下一条



    版权及免责声明|RISC-V单片机中文网 |网站地图

    GMT+8, 2024-4-17 02:50 , Processed in 0.864035 second(s), 45 queries .

    快速回复 返回顶部 返回列表