nuttx: regression of `rv-virt` kernel builds
On Ubuntu 22.04 with qemu-system-riscv64/32 (version: 6.2+dfsg-2ubuntu6.16) targets and gcc-riscv64-unknown-elf toolchain (GCC 10.2) and latest master branch.
- The build from
rv-virt/nshandrv-virt/nsh64can boot. - The build from both
rv-virt/knsh32andrv-virt/knsh64can’t boot. TheABCstring is invibsile from console.
The command line to run nuttx qemu-system-riscv64 -M virt,aclint=on -semihosting -nographic -bios nuttx and it has been working well until I pulled latest master. Looks like this booting mode no longer works after patch #12178.
By using qemu-system-riscv64 -M virt,aclint=on -semihosting -nographic -kernel nuttx to run nuttx with default OpenSBI (v0.9) for rv64, got the exception riscv_exception: EXCEPTION: Illegal instruction. MCAUSE: 0000000000000002, EPC: 000000008020902c, MTVAL: 0000000014d79073.
The call stack looks like:
(gdb) bt
#0 0x000000008020902c in riscv_write_stime (value=18446744073709551615) at /home/yf/Projects/Nuttx/nuttx/arch/risc-v/src/common/riscv_mtimer.c:135
#1 riscv_mtimer_set_mtimecmp (value=18446744073709551615, priv=0x804072c0) at /home/yf/Projects/Nuttx/nuttx/arch/risc-v/src/common/riscv_mtimer.c:156
#2 riscv_mtimer_initialize (mtime=mtime@entry=33603576, mtimecmp=mtimecmp@entry=33570816, irq=irq@entry=21, freq=freq@entry=10000000) at /home/yf/Projects/Nuttx/nuttx/arch/risc-v/src/common/riscv_mtimer.c:349
#3 0x0000000080208a3e in up_timer_initialize () at /home/yf/Projects/Nuttx/nuttx/arch/risc-v/src/qemu-rv/qemu_rv_timerisr.c:67
#4 0x0000000080204670 in clock_initialize () at /home/yf/Projects/Nuttx/nuttx/sched/clock/clock_initialize.c:212
#5 0x00000000802049d8 in nx_start () at /home/yf/Projects/Nuttx/nuttx/sched/init/nx_start.c:671
#6 0x00000000802006e6 in qemu_rv_start (mhartid=<optimized out>, dtb=<optimized out>) at /home/yf/Projects/Nuttx/nuttx/arch/risc-v/src/qemu-rv/qemu_rv_start.c:180
#7 0x000000008020004a in _stext () at /home/yf/Projects/Nuttx/nuttx/arch/risc-v/src/qemu-rv/qemu_rv_head.S:74
maybe the RV_SSTC extension is unavailable in QEMU 6.2 shipped with Ubuntu 22.04?
Haven’t tried -kernel nuttx for rv32 as the default firmware seems lacking in qemu-system-data package on Ubuntu 22.04.
About this issue
- Original URL
- State: closed
- Created 2 months ago
- Reactions: 1
- Comments: 22 (22 by maintainers)
Commits related to this issue
- riscv/rv-virt: fix knsh64 booting issue This fixes `rv-virt/knsh64` booting issue #12275. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com> — committed to yf13/nuttx by yf13 2 months ago
- riscv/rv-virt: fix knsh64 booting issue This patch can boot `rv-virt/knsh64` reported in issue #12275 with qemu 6.2 target in Ubuntu 22.04. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com> — committed to yf13/nuttx by yf13 2 months ago
- riscv/rv-virt: fix kernel build booting issue This patch can boot `rv-virt/knsh64` and `rv-virt/knsh32` reported in issue #12275 with qemu 6.2 target and OpenSBI v1.0 firmware on Ubuntu 22.04 host. ... — committed to yf13/nuttx by yf13 2 months ago
- riscv/rv-virt: fix kernel build booting issue This patch can boot `rv-virt/knsh64` and `rv-virt/knsh32` reported in issue #12275 with qemu 6.2 target and OpenSBI v1.0 firmware on Ubuntu 22.04 host. ... — committed to apache/nuttx by yf13 2 months ago
@lupyuen and @inochisa, I checked with QEMU 6.2 and OpenSBI
v1.0-3ubuntu1here, it works well. So saying v1.0 in docs should be fine.@lupyuen and @inochisa thanks for all the information!
Here I tried
opensbi 1.3-1ubuntu0.22.04.2got viaapt instalal opensbiwith QEMU 6.2 on Ubuntu 22.04, usleep works now with patch #12279. I don’t have other opensbi versions at hand to try but it looks like QEMU 6.2 is fine now.So it is good that we finally can support the Ubuntu stock QEMU v6.2 this way:
qemu-system-riscv64 -M virt,aclint=on -semihosting -kernel nuttx -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.bin@inochisa Sorry I goofed.
@yf13
usleepworks OK withARCH_RV_EXT_SSTC=N,rv-virt:knsh64, QEMU 7.0.0 and OpenSBI v1.0.Could you update to OpenSBI v1.0? I have a hunch that OpenSBI v0.9 might be buggy, we probably shouldn’t use it? Thanks!
https://gist.github.com/lupyuen/da195386a4873c572aa26961e4c81d79
I think you disable CONFIG_ARCH_USE_S_MODE by mistake…
grep should give
Yes.
This worth a try. Thanks.
Good, In addition, I will add some comments for users want to use its own OpenSBI.