基于 qemu 的 riscv64架构的 官方rt-thread 体验 教程

主机环境: ubuntu-20.04.3-desktop-amd64.iso
安装包 : sudo apt-get install net-tools openssh-server git vim make gcc gawk  bison flex  texinfo automake  libtool-bin cvs libncurses5-dev ninja-build libglib2.0-dev libpixman-1-dev help2man python3-dev

编译器 :
	sifive 提供的 
		riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14.tar.gz或
		riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
仿真器 :
	qemu-6.1.0 自己编译 出 qemu-system-riscv32
rt-thread代码:
	https://github.com/RT-Thread/rt-thread.git
1. 编译器准备
在 https://github.com/sifive/freedom-tools/releases 下载
riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz 或
riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14.tar.gz
2. 仿真器准备
// 配置
qemu-6.1.0$./configure --target-list=riscv32-softmmu,riscv64-softmmu --prefix=/home/pop/work/qemu/qemu-out   2>&1 | tee log_configure.txt
// 编译
make 2>&1 | tee log_build.txt
// 安装
make install 2>&1 | tee log_install.txt
// 测试

pop@ubuntu:~$ qemu-system-riscv32 -machine help
Supported machines are:
none                 empty machine
opentitan            RISC-V Board compatible with OpenTitan
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)
virt                 RISC-V VirtIO board
pop@ubuntu:~$ qemu-system-riscv64 -machine help  
Supported machines are:
microchip-icicle-kit Microchip PolarFire SoC Icicle Kit
none                 empty machine
shakti_c             RISC-V Board compatible with Shakti SDK
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)
virt                 RISC-V VirtIO board
3.代码准备并编译
git clone https://github.com/RT-Thread/rt-thread.git // 当前 commit id 为 3502a51cbfd955dea25568b09229cae4fcfbb654
cd rt-thread/bsp/qemu-riscv-virt64
// change rt-thread/bsp/qemu-riscv-virt64/rtconfig.py
// EXEC_PATH   = r'/home/pop/work/freertos-riscv/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin'
scons --target=makefile
make
编译成功,会生成 rt-thread/bsp/qemu-riscv-virt64/rtthread.bin
4. 仿真器加载 rtthread镜像
在 rt-thread/bsp/qemu-riscv-virt64 下
./qemu-nographic.sh // 即 qemu-system-riscv64 -nographic -machine virt -m 256M -bios rtthread.bin


打印如下
heap: [0x80032ca8 - 0x86432ca8]

 \ | /
- RT -     Thread Operating System
 / | \     4.0.4 build Sep  2 2021
 2006 - 2021 Copyright by rt-thread team
Hello RISC-V!
msh />

// 可键入 help 进行交互
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值