nuttx/boards/risc-v/qemu-rv/rv-virt
Masayuki Ishikawa 8bbe7a8825 boards: Enable virtio-blk and FAT for virt configurations
Summary:
- I noticed that virtio-blk and FAT are not enabled for some
  virt configurations.
- This commit enables them for testing.

Impact:
- None

Testing:
- Tested with qemu-7.1
- NOTE: file copy with rv-virt:knetnsh64 is sometimes unstable.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-07-01 13:10:40 +08:00
..
configs boards: Enable virtio-blk and FAT for virt configurations 2023-07-01 13:10:40 +08:00
include arch: Change the linker generated symbols from uint32_t to uint8_t * 2022-09-24 21:26:56 +02:00
scripts risc-v: SV32 MMU support for qemu-rv. 2023-03-29 22:15:19 +09:00
src boards/sim: support rc.sysinit 2022-04-21 12:54:53 +03:00
Kconfig
README.txt boards: Add virtio blk driver to qemu-arm8a and rv-virt 2023-05-13 13:58:09 +08:00

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

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
  $ # For 64-bit build.
  $ ./tools/configure.sh rv-virt:knsh64 
  $ # 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>

4. Run the virtio network and block 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 \
  -global virtio-mmio.force-legacy=false \
  -drive file=./mydisk-1gb.img,if=none,format=raw,id=hd -device virtio-blk-device,drive=hd \
  -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.0 \
  -bios none -kernel nuttx -nographic

  or

  $ qemu-system-riscv64 -semihosting -M virt,aclint=on -cpu rv64 -smp 8 \
  -global virtio-mmio.force-legacy=false \
  -drive file=./mydisk-1gb.img,if=none,format=raw,id=hd -device virtio-blk-device,drive=hd \
  -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.0 \
  -bios none -kernel nuttx -nographic

5. TODO

  Support FPU
  Support RISC-V User mode