XV6-RISCV操作系统环境搭建流程(ubuntu-18)

安装RISC-V工具链

参考https://blog.youkuaiyun.com/zhayujie5200/article/details/106374189/?ops_request_misc=&request_id=&biz_id=102&utm_term=xv6%E5%AE%9E%E9%AA%8CMac&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduweb~default-1-106374189.142v47pc_rank_34_default_3,201v2control&spm=1018.2226.3001.4187

  • 下载riscv-gnu-toolchain安装包(百度网盘https://pan.baidu.com/s/1104aCZiIUAEcHONKcI8GKw,ui4j)
  • 解压
  • 完成之后,输入如下
$ cd riscv-gnu-toolchain

$ sudo  ./configure --prefix=/usr/local

$ sudo make

$ cd ..

#如果make错误,可能有依赖的软件包没安装,输入
$ sudo apt-get install libglib2.0-dev
$ sudo apt-get install libpixman-1-dev
  • 验证安装
$  riscv64-unknown-elf-gcc --version

#有如下提示:

riscv64-unknown-elf-gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#安装成功

qemu模拟器安装

  • 下载模拟器
$ wget https://download.qemu.org/qemu-5.0.0.tar.xz
$ tar xvJf qemu-5.0.0.tar.xz
  • 编译
$ cd qemu-5.0.0
$ ./configure --target-list=riscv64-softmmu,riscv64-linux-user --prefix=/usr/local
$ make
$ sudo make install
  • 验证安装
$  qemu-system-riscv64 --version

#有如下提示:

QEMU emulator version 5.0.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

#安装成功

编译xv6-riscv源码

  • 获取
$ git clone https://github.com/mit-pdos/xv6-riscv.git
  • 编译
$ cd xv6-riscv/
$ make clean
$ make
  • 运行
$ make qemu

# 出现以下情况,代表运行成功
qemu-system-riscv64 -machine virt -bios none -kernel kernel/kernel -m 128M -smp 3 -nographic -global virtio-mmio.force-legacy=false -drive file=fs.img,if=none,format=raw,id=x0 -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0

xv6 kernel is booting

hart 2 starting
hart 1 starting
init: starting sh
$ 


# 退出qemu:ctrl+a x
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值