Step 1:安装一些编译riscv需要的库:

  

  1. 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

  但是如果遇到了install失败的时候,可以选择使用其他的镜像:

  进入 https://mirrors.ustc.edu.cn/repogen/ 选择自己的linux版本,比如说Ubuntu的apt/sources.list右击Download复制连接地址;

  1. touch sources.list-backup
    rm sources.list
    wget https://mirrors.ustc.edu.cn/repogen/conf/ubuntu-https-4-kinetic
    apt-get update
    apt-get upgrad

  之后应该就可以安装成功了

Step 2:安装工具riscv-tool和riscv-gnu-tools

   因为都是比较大的,所以我选择先git然后对子目录进行--recursive

  1. git clone https://github.com/riscv/riscv-gnu-toolchain
  2. cd riscv-gnu-toolchain
  3. git clone --recursive https://github.com/riscv/riscv-qemu.git
  4. git clone --recursive https://github.com/riscv/riscv-newlib.git
  5. git clone --recursive https://github.com/riscv/riscv-binutils-gdb.git
  6. git clone --recursive https://github.com/riscv/riscv-dejagnu.git
  7. git clone --recursive https://github.com/riscv/riscv-glibc.git
  8. git clone --recursive https://github.com/riscv/riscv-gcc.git 
  1. git clone https://github.com/riscv/riscv-tools.git
  2. cd riscv-tool
  3. git clone --recursive https://github.com/riscv/riscv-isa-sim.git
  4. git clone --recursive https://github.com/riscv/riscv-opcodes.git
  5. git clone --recursive https://github.com/riscv/riscv-pk.git
  6. git clone --recursive https://github.com/riscv/riscv-tests.git

Step 3: 编译工具链

  1. vi ~/.bashrc
  2. # 添加:
  3. exprort RISCV="~/riscv_related/riscv-gnu-toolchain"
  4. export PATH=$PATH:$RISCV/bin
  5. # 退出执行
  6. source ~/.bashrc
  7. mkdir riscv-gnu-toolchain-build
  8. cd riscv-gnu-toolchain-build
  9. ../riscv-gnu-toolchain/configure --prefix=$RISCV
  10. make linux

  这里configure和make的选项有很多 

  如果希望是搭建linux上的话环境需要make linux;否则到时候会提示找不到elf文件等

  过程中可能会提示已经 directory not empty:

  可以进入相应的文件夹中:

  1. rm -rf riscv-binutils
  2. rm -rf riscv-gdb
  3. cd riscv-binutils-gdb
  4. cp -a * ../riscv-binutils
  5. cp -a * ../riscv-dbd

Step 4:编译工具riscv-tool

  1. cd riscv-tools
  2. ./build.sh
  3. # 问题1 :undefined macro AC_DEFINED
  4. apt-get install libsys-dev
  5. apt-get install pkg-config
  6. # 问题2:No rule to make target all
  7. apt-get install fesvr
  8. # 问题3:runtimeerror is not a member of std
  9. vi fesvr/dtm.cd
  10. #include<stdexcept>

Step 5:安装qemu:

  1. # 首先git安装qemu
  2. # 我的提示没有python
  3. apt-get install python-is-python3
  4. # 查看版本
  5. whereis python
  6. # 安装glib,gthread:
  7. apt-get install libglib2.0-dev
  8. apt-get install libpixman-1-dev
  9. ./configure -disable-werror
  10. make
  11. make install

Step 6: 安装busybear

  1. mkdir linux
  2. git clone https://github.com/michaeljclark/busybear-linux.git
  3. cd busybear-linux
  4. make
  5. # 问题1: stime有问题 --> 好像已经被废弃了
  6. # 暴力解决方法:更换版本:但是不能直接将新的替换
  7. # 查勘Makefile会发现每次都是会重新下载busybox的
  8. cd conf
  9. vi busybear.config
  10. BUSYBOX_VERSION = 1.34.0
    # 问题2:multiple definition of yylloc
    # 是gcc版本太高的原因:
    cd riscv-gnu-toolchain
    cd riscv-gcc
    cd gcc
    vi BASE-VER
    # 修改为9.5.0(小于10就可以)

Step 7:下载RISCV-Linux

  1. cd linux
  2. git clone https://github.com/riscv/riscv-linux.git
  3. cd riscv-linux
  4. git checkout riscv-linux-4.14
  5. cp ../busybear-linux/conf/linux.config .config
  6. make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- olddefconfig
  7. make ARCH=riscv vmlinux

Step 8:安装BBL

  1. git clone https://github.com/riscv/riscv-pk.git
  2. cd riscv-pk
  3. mkdir build
  4. cd build
  5. ../configure --enable-logo --host=riscv64-unknown-linux-gnu- --with-payload=../../riscv-linux/vmlinux

Step 9:使用二进制文件:

  1. mkdir release
  2. cd release
  3. wget https://github.com/michaeljclark/busybear-linux/releases/download/v1.0/bbl.bz2
  4. wget https://github.com/michaeljclark/busybear-linux/releases/download/v1.0/busybear.bin.bz2
  5. bzip2 -d *.bz2

Step 9 :登录:

  1. sudo qemu-system-riscv64 -nographic -machine virt -kernel bbl -append "root=/dev/vda ro console=ttyS0" -drive file=busybear.bin,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -device virtio-net-device,netdev=net0

登录用户名:root

登录密码:busybear

然后就可以运行啦

  1. # 测试命令
  2. uname -a
  3. # 结束退出
  4. halt

VirtualBox上使用qemu和busybear搭建RISCV环境的更多相关文章

  1. 搭建riscv环境

    1.第一步 clone 需要的源文件(sudo apt install git   如果你没有git)  以下都是给予ubuntu18.04 $ git clone --recursive https ...

  2. Docker搭建disconf环境,三部曲之二:本地快速构建disconf镜像

    Docker下的disconf实战全文链接 <Docker搭建disconf环境,三部曲之一:极速搭建disconf>: <Docker搭建disconf环境,三部曲之二:本地快速构 ...

  3. MIT6.828准备:MacOS下搭建xv6和risc-v环境

    本文介绍在MacOS下搭建Mit6.828/6.S081 fall2019实验环境的详细过程,包括riscv工具链.qemu和xv6,对于Linux系统同样可以参考. 介绍 只有了解底层原理才能写好上 ...

  4. 史上最全Windows版本搭建安装React Native环境配置

    史上最全Windows版本搭建安装React Native环境配置 配置过React Native 环境的都知道,在Windows React Native环境配置有很多坑要跳,为了帮助新手快速无误的 ...

  5. win7上搭建Android环境及调试

    工欲善其事必先利其器,好记性不如烂笔头.要学习一门新的语言,首先必须得先搭环境,否则没法实践.如果之前按照网上的提示,搭建过环境,而且环境比较复杂的话,我相信隔很长一段时间后,就会忘记,到真正用的时候 ...

  6. WIN10 vagrant和virtualbox虚拟机和一键搭建lnmp环境配置thinkphp虚拟主机

    版本:win10系统 virtualbox:5.1.26 vagrant :1.9.7 centos 7.0 xshell/git 首先下载好对应版本的软件 配置vagrant和virtualbox ...

  7. virtualBox上虚拟机和主机互联{}

    VirtualBox实现内外网络互访问的配置   环境: 宿主机操作系统            Windows XP sp3 虚拟机软件                       VirtualBo ...

  8. [dpdk] 熟悉SDK与初步使用 (一)(qemu搭建实验环境)

    搭建实验环境: troubleshoot 第一步加载驱动 第二步切换驱动 使用了所有qemu支持的卡 [tong@T7:~/VM/dpdk] % cat start.sh sudo qemu-syst ...

  9. 在ubuntu上搭建开发环境4---ubuntu简单的搭建LAMP环境和配置

    最近重新安装了Ubuntu,但是之前的LAMP环境自然也就没有了,实在是不想再去编译搭建LAMP环境(这种方法实在是太费时间,而且太容易遇到各种不知道为什么的错误),所以,就去查查有没有什么简单的搭建 ...

  10. 在ubuntu上搭建开发环境3---解决Y470一键系统重装之后恢复ubuntu引导启动的方法

    2015/08/18 将知识.常用的操作整理出来一定要完整,注意细节. 就像下面是再2015.04.27时候整理的,当时确实实验成功了,但是可能忘记记下具体的细节,尤其是3.4.5.6步骤中的关于盘符 ...

随机推荐

  1. Array list练习

    Array list练习 数据添加到集合 生成6个1~33之间的随机整数,添加到集合,并遍历 public class Test01ArrayList { public static void mai ...

  2. STL序列式容器使用注意、概念总结

    引入 最近看了<STL源码剖析>的第 4 章和第 5 章,介绍了 C++ STL 中的序列式容器和关联式容器,本文将总结序列式容器的基础概念,不会详细它们的实现原理(想知道自个儿看书吧,我 ...

  3. saas解决redis数据库分离的一种方案

    package com.xf.config; import java.util.HashMap; import java.util.Map; import java.util.Set; import ...

  4. vue + video.js/videojs-contrib-hls 实现hls拉流播放

    当时接手拉流播放时使用的是西瓜播放器插件,神奇的是 安卓手机显示正常,但是苹果一直显示加载,pc端使用https格式不能播放,但是去掉s改为http即可进行播放 后面查看大佬文章后总算解决了这一需求 ...

  5. Ubuntu/linux下最强大的下载工具-aria2

    aria2 是 Linux 下一个不错的高速下载工具 .由于它具有分段下载引擎,所以支持从多个地址或者从一个地址的多个连接来下载同一个文件.这样自然就大大加快了文件的下载速 度.aria2 也具有断点 ...

  6. JZOJ 7377.欢乐豆

    \(\text{Problem}\) 有一个有向完全图,所有的 \(u\) 到 \(v\) 的边权为 \(a_u\) 修改 \(m\) 此有向边边权,求最终图上两两点对的最短路之和 \(1\le n ...

  7. JZOJ 6801. NOIP2020.9.19模拟patrick

    题目大意 动态维护数列中大于等于某个数的极长连续段的个数. 思路 我们考虑每段的开头,记为 \(i\),高度为 \(a_i\) 那么此时水淹的高度必然满足 \(a_{i-1} < x \leq ...

  8. 两个集合之间数据过滤linq

    //以下为前台多字段循环匹配if (!input.Filter.IsNullOrEmpty()) { var keysList = input.Filter.Split(" ".T ...

  9. label勾选问题,checkbox

    <input id="overck_21" data-role="none" name="check" class="reg ...

  10. CSS3移动动画

    transition: .3s all ease; .tmall .tmall-tabbodys { width: 100%; position: absolute; left: 0px; trans ...