Skip to content

Bytemem Blog

  • Home
  • Kernel Developers
  • Contact
  • About

Bytemem Blog

Stuffs about linux

在QEMU上运行RISCV平台Linux

02/05/2020 by changbin

QEMU支持如下RISC-V平台:

  • Spike是官方的RISC-V模拟平台。
  • SiFive的E和U系列。
  • Virt是通用的虚拟化RISC-V平台,支持VirtIO设备。
$ qemu-system-riscv64 -M ?
Supported machines are:
none                 empty machine
sifive_e             RISC-V Board compatible with SiFive E SDK
sifive_u             RISC-V Board compatible with SiFive U SDK
spike                RISC-V Spike Board (default)
spike_v1.10          RISC-V Spike Board (Privileged ISA v1.10)
spike_v1.9.1         RISC-V Spike Board (Privileged ISA v1.9.1)
virt                 RISC-V VirtIO board

QEMU RISC-V模拟了如下硬件特性:

  • HTIF Console (Host Target Interface) for Spike emulation
  • SiFive CLINT (Core Local Interruptor) for Timer interrupts and IPIs
  • SiFive PLIC (Platform Level Interrupt Controller) for multi-core interrupts
  • SiFive Test (Test Finisher) for exiting simulations in tests
  • SiFive UART for console on the SiFive U series and E series devices
  • SiFive PRCI, AON, PWM, QSPI mocks for SiFive E series devices
  • VirtIO MMIO for network and block device support
  • Generic 16550A UART emulation on the ‘virt’ board
  • SMP and MTTCG support for multi-core emulation

编译Linux内核:

make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- defconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- menuconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- Image -j8

获取rootfs:busybox是一个用busybox制作的微型rootfs。

https://github.com/michaeljclark/busybear-linux/releases

安装opensbi固件:

sudo apt install opensbi

在qemu中用opensbi固件启动Linux内核:

qemu-system-riscv64 -nographic -machine virt -serial mon:stdio \
-bios /usr/lib/riscv64-linux-gnu/opensbi/qemu/virt/fw_jump.elf \
-kernel arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" \
-drive file=../images/busybear.img,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0
Post Views: 1,020

Post navigation

Previous Post:

aarch64-notes

Next Post:

使用yocto构建riscv linux项目

发表评论 取消回复

电子邮件地址不会被公开。

近期文章

  • 关于编程语言的思考
  • Rust语言学习材料
  • GCC目标三元组(Target Triplet)
  • 什么是匿名内存
  • 操作系统架构概述

近期评论

  • 12 USA America Proud Rubber Bracelets July 4th Red White Blue Patriotic Girl发表在《什么是匿名内存》
  • generic cialis no prescription发表在《Ubuntu各版本国内阿里云源列表》
  • buy cialis online us发表在《Ubuntu各版本国内阿里云源列表》

文章归档

  • 2020年八月
  • 2020年七月
  • 2020年六月
  • 2020年五月
  • 2020年二月
  • 2019年七月
  • 2019年六月
  • 2019年五月

分类目录

  • DevTools
  • Linux Kernel
  • 未分类

标签

ftrace gdb NMI中断 PCIe rust Ubuntu X86 内核 阿里云

功能

  • 登录
  • 文章RSS
  • 评论RSS
  • WordPress.org
© 2021 Bytemem Blog | WordPress Theme by Superbthemes