基于 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 进行交互

你可能感兴趣的:(riscv,rt-thread,riscv)