• RISCV学习1 RISCV模拟器


    最近有个项目需要用到RISCV开发板,没拿到开发板之前,先尝试配置一个虚拟机环境
    1、配置riscv-toolchain

    git clone https://github.com/riscv/riscv-gnu-toolchain 
    Cloning into 'riscv-gnu-toolchain'...
    remote: Enumerating objects: 8045, done.
    remote: Counting objects: 100% (504/504), done.
    remote: Compressing objects: 100% (377/377), done.
    remote: Total 8045 (delta 137), reused 448 (delta 124), pack-reused 7541
    Receiving objects: 100% (8045/8045), 5.56 MiB | 55.00 KiB/s, done.
    Resolving deltas: 100% (3859/3859), done.
    

    2、保依赖库都已经安装

    sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
    

    3、进入riscv-gnu-toolchain目录,编译(需要2个多小时)

    ./configure --prefix=/opt/riscv --enable-multilib
    ./make
    ./make linux
    

    如果后续步骤有问题,分别编译下面
    riscv64-unknown-elf-gcc

    ./configure --prefix=/opt/riscv
    make
    

    riscv64-unknown-linux-gnu-gcc

    ./configure --prefix=/opt/riscv --enable-multilib
    make linux
    

    5、下载riscv-tools

    git clone https://github.com/riscv-software-src/riscv-tools
    cd ./riscv-tools
    

    6、安装依赖包

    sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev
    

    7、运行

    git submodule update --init --recursive
    export RISCV=/opt/riscv
    ./build.sh
    
    

    5分钟左右,安装成功提示
    RISC-V Toolchain installation completed!

    8、创建一个代码hello.c

    #include <stdio.h>
    int main(){
        printf("hello world!\n");
        return 0;
    }
    

    9、编译

    /opt/riscv/bin/riscv64-unknown-elf-gcc -o hello hello.c
    

    10、执行
    /opt/riscv/bin/spike pk ./hello
    image
    增加-m128参数,执行成功
    /opt/riscv/bin/spike -m128 pk ./hello
    image

    参考:
    https://blog.csdn.net/popebl/article/details/123829110
    https://blog.csdn.net/nijino/article/details/119273504

  • 相关阅读:
    Linux防火墙--iptables学习
    LVS持久化
    LVS管理工具--ipvsadm
    Linux负载均衡--LVS(IPVS)
    一步步学习python
    驱动工程师需要的技能
    红外图像盲元补偿matlab实现源码与效果验证
    红外图像非均匀矫正——两点矫正
    夏日炎炎 python写个天气预报
    解决OV系列摄像头寄存器读数据无法收到的问题
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/16536003.html
Copyright © 2020-2023  润新知