nuttx/boards/risc-v/qemu-rv/rv-virt/README.txt

121 lines
3.9 KiB
Plaintext
Raw Normal View History

1. Download and install toolchain
$ curl https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz
2. Build and install qemu
$ git clone https://github.com/qemu/qemu
$ cd qemu
$ ./configure --target-list=riscv32-softmmu,riscv64-softmmu
$ make
$ sudo make install
3.1. Configure and build NuttX for BUILD_FLAT
$ mkdir ./nuttx; cd ./nuttx
$ git clone https://github.com/apache/nuttx.git nuttx
$ git clone https://github.com/apache/nuttx-apps.git apps
$ cd nuttx
$ make distclean
$ ./tools/configure.sh rv-virt:nsh
$ make V=1 -j7
2023-03-27 01:01:47 +02:00
3.2 Configure and build NuttX for BUILD_KERNEL, 64-bit or 32-bit
$ mkdir ./nuttx; cd ./nuttx
$ git clone https://github.com/apache/nuttx.git nuttx
$ git clone https://github.com/apache/nuttx-apps.git apps
$ cd nuttx
$ make distclean
2023-03-27 01:01:47 +02:00
$ # For 64-bit build.
$ ./tools/configure.sh rv-virt:knsh64
2023-03-27 01:01:47 +02:00
$ # For 32-bit build.
$ ./tools/configure.sh rv-virt:knsh32
$ make V=1 -j7
$ make export V=1
$ cd ../apps
$ ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
$ make import V=1
$ cd ../nuttx
4. Run the nuttx with qemu
$ qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 8 -bios none -kernel nuttx -nographic
or
$ qemu-system-riscv64 -semihosting -M virt,aclint=on -cpu rv64 -smp 8 -bios none -kernel nuttx -nographic
NuttShell (NSH) NuttX-10.3.0-RC1
nsh> mount -t hostfs -o fs=. /host
nsh> cat /host/AUTHORS
This is a list of all the contributors that have submitted ICLA, SGA
If you are not on this list and believe you should be, please inform us.
ICLA
====
...
nsh>
virtio: add virtio framework in NuttX 1. virtio devics/drivers match and probe/remote mechanism; 2. virtio mmio transport layer based on OpenAmp (Compatible with both virtio mmio version 1 and 2); 3. virtio-serial driver based on new virtio framework; 4. virtio-rng driver based on new virtio framework; 5. virtio-net driver based on new virtio framework (IOB Offload implementation); 6. virtio-blk driver based on new virtio framework; 7. Remove the old virtio mmio framework, the old framework only support mmio transport layer, and the new framwork support more transport layer and this commit has implemented all the old virtio drivers; 8. Refresh the the qemu-arm64 and qemu-riscv virtio related configs, and update its README.txt; New virtio-net driver has better performance Compared with previous virtio-mmio-net: | | master/-c | master/-s | this/-c | this/-s | | :--------------------: | :-------: | :-------: | :-----: | :-----: | | qemu-armv8a:netnsh | 539Mbps | 524Mbps | 906Mbps | 715Mbps | | qemu-armv8a:netnsh_smp | 401Mbps | 437Mbps | 583Mbps | 505Mbps | | rv-virt:netnsh | 487Mbps | 512Mbps | 760Mbps | 634Mbps | | rv-virt:netnsh_smp | 387Mbps | 455Mbps | 447Mbps | 502Mbps | | rv-virt:netnsh64 | 602Mbps | 595Mbps | 881Mbps | 769Mbps | | rv-virt:netnsh64_smp | 414Mbps | 515Mbps | 491Mbps | 525Mbps | | rv-virt:knetnsh64 | 515Mbps | 457Mbps | 606Mbps | 540Mbps | | rv-virt:knetnsh64_smp | 308Mbps | 389Mbps | 415Mbps | 474Mbps | Note: Both CONFIG_IOB_NBUFFERS=64, using iperf command, all in Mbits/sec Tested in QEMU 7.2.2 Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com> Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-03-22 04:49:43 +01:00
4. Run the virtio network, block, serial and rng driver with qemu
$ dd if=/dev/zero of=./mydisk-1gb.img bs=1M count=1024
$ qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 8 \
virtio: add virtio framework in NuttX 1. virtio devics/drivers match and probe/remote mechanism; 2. virtio mmio transport layer based on OpenAmp (Compatible with both virtio mmio version 1 and 2); 3. virtio-serial driver based on new virtio framework; 4. virtio-rng driver based on new virtio framework; 5. virtio-net driver based on new virtio framework (IOB Offload implementation); 6. virtio-blk driver based on new virtio framework; 7. Remove the old virtio mmio framework, the old framework only support mmio transport layer, and the new framwork support more transport layer and this commit has implemented all the old virtio drivers; 8. Refresh the the qemu-arm64 and qemu-riscv virtio related configs, and update its README.txt; New virtio-net driver has better performance Compared with previous virtio-mmio-net: | | master/-c | master/-s | this/-c | this/-s | | :--------------------: | :-------: | :-------: | :-----: | :-----: | | qemu-armv8a:netnsh | 539Mbps | 524Mbps | 906Mbps | 715Mbps | | qemu-armv8a:netnsh_smp | 401Mbps | 437Mbps | 583Mbps | 505Mbps | | rv-virt:netnsh | 487Mbps | 512Mbps | 760Mbps | 634Mbps | | rv-virt:netnsh_smp | 387Mbps | 455Mbps | 447Mbps | 502Mbps | | rv-virt:netnsh64 | 602Mbps | 595Mbps | 881Mbps | 769Mbps | | rv-virt:netnsh64_smp | 414Mbps | 515Mbps | 491Mbps | 525Mbps | | rv-virt:knetnsh64 | 515Mbps | 457Mbps | 606Mbps | 540Mbps | | rv-virt:knetnsh64_smp | 308Mbps | 389Mbps | 415Mbps | 474Mbps | Note: Both CONFIG_IOB_NBUFFERS=64, using iperf command, all in Mbits/sec Tested in QEMU 7.2.2 Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com> Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-03-22 04:49:43 +01:00
-global virtio-mmio.force-legacy=false \
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
-chardev socket,telnet=on,host=127.0.0.1,port=3450,server=on,wait=off,id=foo \
-device virtconsole,chardev=foo \
-device virtio-rng-device,bus=virtio-mmio-bus.1 \
-netdev user,id=u1,hostfwd=tcp:127.0.0.1:10023-10.0.2.15:23,hostfwd=tcp:127.0.0.1:15001-10.0.2.15:5001 \
-device virtio-net-device,netdev=u1,bus=virtio-mmio-bus.2 \
-drive file=./mydisk-1gb.img,if=none,format=raw,id=hd \
-device virtio-blk-device,bus=virtio-mmio-bus.3,drive=hd \
-bios none -kernel ./nuttx/nuttx -nographic
or
$ qemu-system-riscv64 -semihosting -M virt,aclint=on -cpu rv64 -smp 8 \
virtio: add virtio framework in NuttX 1. virtio devics/drivers match and probe/remote mechanism; 2. virtio mmio transport layer based on OpenAmp (Compatible with both virtio mmio version 1 and 2); 3. virtio-serial driver based on new virtio framework; 4. virtio-rng driver based on new virtio framework; 5. virtio-net driver based on new virtio framework (IOB Offload implementation); 6. virtio-blk driver based on new virtio framework; 7. Remove the old virtio mmio framework, the old framework only support mmio transport layer, and the new framwork support more transport layer and this commit has implemented all the old virtio drivers; 8. Refresh the the qemu-arm64 and qemu-riscv virtio related configs, and update its README.txt; New virtio-net driver has better performance Compared with previous virtio-mmio-net: | | master/-c | master/-s | this/-c | this/-s | | :--------------------: | :-------: | :-------: | :-----: | :-----: | | qemu-armv8a:netnsh | 539Mbps | 524Mbps | 906Mbps | 715Mbps | | qemu-armv8a:netnsh_smp | 401Mbps | 437Mbps | 583Mbps | 505Mbps | | rv-virt:netnsh | 487Mbps | 512Mbps | 760Mbps | 634Mbps | | rv-virt:netnsh_smp | 387Mbps | 455Mbps | 447Mbps | 502Mbps | | rv-virt:netnsh64 | 602Mbps | 595Mbps | 881Mbps | 769Mbps | | rv-virt:netnsh64_smp | 414Mbps | 515Mbps | 491Mbps | 525Mbps | | rv-virt:knetnsh64 | 515Mbps | 457Mbps | 606Mbps | 540Mbps | | rv-virt:knetnsh64_smp | 308Mbps | 389Mbps | 415Mbps | 474Mbps | Note: Both CONFIG_IOB_NBUFFERS=64, using iperf command, all in Mbits/sec Tested in QEMU 7.2.2 Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com> Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-03-22 04:49:43 +01:00
-global virtio-mmio.force-legacy=false \
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
-chardev socket,telnet=on,host=127.0.0.1,port=3450,server=on,wait=off,id=foo \
-device virtconsole,chardev=foo \
-device virtio-rng-device,bus=virtio-mmio-bus.1 \
-netdev user,id=u1,hostfwd=tcp:127.0.0.1:10023-10.0.2.15:23,hostfwd=tcp:127.0.0.1:15001-10.0.2.15:5001 \
-device virtio-net-device,netdev=u1,bus=virtio-mmio-bus.2 \
-drive file=./mydisk-1gb.img,if=none,format=raw,id=hd \
-device virtio-blk-device,bus=virtio-mmio-bus.3,drive=hd \
-bios none -kernel ./nuttx/nuttx -nographic
5. Run the virtio gpu driver with qemu and test fb demo
$ # For 32-bit build.
$ ./tools/configure.sh rv-virt:fb
$ make -j
$ qemu-system-riscv32 -semihosting -M virt -cpu rv32 -smp 8 \
-chardev stdio,id=con,mux=on \
-serial chardev:con \
-device virtio-gpu-device,xres=640,yres=480,bus=virtio-mmio-bus.0 \
-mon chardev=con,mode=readline \
-bios none -kernel nuttx
NuttShell (NSH) NuttX-10.4.0
nsh> fb
$ # For 64-bit build.
$ ./tools/configure.sh rv-virt:fb64
$ make -j
$ qemu-system-riscv64 -semihosting -M virt -cpu rv64 -smp 8 \
-chardev stdio,id=con,mux=on \
-serial chardev:con \
-device virtio-gpu-device,xres=640,yres=480,bus=virtio-mmio-bus.0 \
-mon chardev=con,mode=readline \
-bios none -kernel nuttx
NuttShell (NSH) NuttX-10.4.0
nsh> fb
6. TODO
Support FPU
Support RISC-V User mode