nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

`ostest` in `rv-virt:fb` got illegal instruction exception

Open yf13 opened this issue 2 years ago • 6 comments

When trying the ostest within the rv-virt:fb configuration, I got illegal instructions exceptions like below:

user_main: FPU test
Starting task FPU#1
fpu_test: Started task FPU#1 at PID=6
[    9.170000] riscv_exception: EXCEPTION: Illegal instruction. MCAUSE: 00000002, EPC: 80022086, MTVAL: 00000000
[    9.170000] riscv_exception: PANIC!!! Exception = 00000002
[    9.170000] _assert: Current Version: NuttX  0.0.0 95ac627d59-dirty Dec  4 2023 09:41:38 risc-v
[    9.170000] _assert: Assertion failed panic: at file: :0 task: FPU#1 process: FPU#1 0x80021ff4
[    9.170000] up_dump_register: EPC: 80022086
[    9.170000] up_dump_register: A0: 00000000 A1: 80179f18 A2: 80179f18 A3: 00000002
[    9.170000] up_dump_register: A4: 8003ce8c A5: 80032000 A6: 00000000 A7: 00000000
[    9.170000] up_dump_register: T0: 00000000 T1: 00000000 T2: 00000000 T3: 00000000
[    9.170000] up_dump_register: T4: 00000000 T5: 00000000 T6: 00000000
[    9.170000] up_dump_register: S0: 00000000 S1: 00000001 S2: 00000000 S3: 00000000
[    9.170000] up_dump_register: S4: 00000000 S5: 8003ce8c S6: 00000000 S7: 00000000
[    9.170000] up_dump_register: S8: 00000000 S9: 00000000 S10: 00000000 S11: 00000000
[    9.170000] up_dump_register: SP: 8017a660 FP: 00000000 TP: 00000000 RA: 8002203a
[    9.170000] dump_stack: User Stack:
[    9.170000] dump_stack:   base: 0x80179f28
[    9.170000] dump_stack:   size: 00002008
[    9.170000] dump_stack:     sp: 0x8017a660
[    9.170000] stack_dump: 0x8017a660: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    9.170000] stack_dump: 0x8017a680: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    9.170000] stack_dump: 0x8017a6a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    9.170000] stack_dump: 0x8017a6c0: 00000000 00000000 80021ff4 800061cc 00000000 00000000 80179f18 00000001
[    9.170000] stack_dump: 0x8017a6e0: 00000000 00000000 00000000 80001962 00000000 00000000 00000000 00000000
[    9.170000] dump_tasks:    PID GROUP PRI POLICY   TYPE    NPX STATE   EVENT      SIGMASK          STACKBASE  STACKSIZE      USED   FILLED    COMMAND
[    9.170000] dump_tasks:   ----   --- --- -------- ------- --- ------- ---------- ---------------- 0x800321a0      2048       716    34.9%    irq
[    9.170000] dump_task:       0     0   0 FIFO     Kthread - Ready              0000000000000000 0x8003d68c      2032       644    31.6%    Idle_Task
[    9.170000] dump_task:       1     1 224 RR       Kthread - Waiting Semaphore  0000000000000000 0x8003f0b0      1984       540    27.2%    hpwork 0x80032e04 0x80032e18
[    9.170000] dump_task:       2     2 100 RR       Kthread - Waiting Semaphore  0000000000000000 0x8003fcb8      1976       540    27.3%    lpwork 0x80032ddc 0x80032df0
[    9.170000] dump_task:       3     3 100 RR       Task    - Waiting Signal     0000000000000000 0x800408e8      3016      1404    46.5%    nsh_main
[    9.170000] dump_task:       4     4 100 RR       Task    - Waiting Signal     0000000000000000 0x80177038      2008       956    47.6%    ostest
[    9.170000] dump_task:       5     5 100 RR       Task    - Waiting Signal     0000000000000000 0x80177b78      8104       764     9.4%    ostest Arg1 Arg2 Arg3 Arg4
[    9.170000] dump_task:       6     6 100 RR       Task    - Running            0000000000000000 0x80179f28      2008       556    27.6%    FPU#1

The fb sample runs well. I am using a recent version from master branch. The ostest in rv-virt:fb64 runs well.

yf13 avatar Dec 04 '23 01:12 yf13

@masayuki2009 any idea about this issue?

acassis avatar Dec 04 '23 19:12 acassis

@masayuki2009 any idea about this issue?

@yf13 I have no idea but please provide the following information when you report a bug.

Host OS name and CPU type. Toolchain version. QEMU version and runtime options. NuttX code base (branch name and the commit id)

masayuki2009 avatar Dec 05 '23 03:12 masayuki2009

@masayuki2009, thanks for your attention.

Host info: Ubuntu 22.04 Jammy on AMD64 PC Toolchain info: xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz QEMU info: qemu-system-riscv32 from zephyr-sdk-0.16.4, version 7.0.0 (v7.0.0-6-g2cc2e86de6-dirty). Also happens with stock QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.11) on Ubuntu. QEMU command line to run NuttX:

$ qemu-system-riscv32 -semihosting -M virt -smp 2 -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
VNC server running on 127.0.0.1:5900

NuttShell (NSH) NuttX-12.3.0
nsh> uname -a
NuttX 12.3.0 95ac627d59-dirty Dec  5 2023 14:31:50 risc-v rv-virt

Nuttx codebase: master branch from upstream with commit id 95ac627d59

yf13 avatar Dec 05 '23 06:12 yf13

@yf13

Thanks for the information. Though I tried the same settings, I was not able to reproduce the crash.

As for the nuttx code base, you wrote

Nuttx codebase: master branch from upstream with commit id https://github.com/apache/nuttx/commit/95ac627d590e5825ac9f8c969e87694ad5e5afd3

However, uname -a shows 95ac627d59-dirty which means you modified the source code. Please confirm both nuttx and apps directory and where you modified the source code.

masayuki2009 avatar Dec 05 '23 21:12 masayuki2009

@masayuki2009, thanks for the information.

Here my modification are for download URLs in openamp/open-amp.defs and openamp/libmetal.defs to avoid unstable Github connections here.

$ git status -s
 M openamp/libmetal.defs
 M openamp/open-amp.defs

$ git diff openamp/libmetal.defs
diff --git a/openamp/libmetal.defs b/openamp/libmetal.defs
index b3369496ab..1b0cf8bbd1 100644
--- a/openamp/libmetal.defs
+++ b/openamp/libmetal.defs
@@ -74,7 +74,7 @@ LIBMETAL_HDRS_SEDEXP := \
 ifeq ($(wildcard libmetal/.git),)
 libmetal.zip:
 # Download and unpack tarball if no git repo found
-       $(call DOWNLOAD,https://github.com/OpenAMP/libmetal/archive,v$(VERSION).zip,libmetal.zip)
+       $(call DOWNLOAD,file:///srv/pkgs,libmetal-v$(VERSION).zip,libmetal.zip)
        $(Q) unzip -o libmetal.zip
        $(Q) mv libmetal-$(VERSION) libmetal
        $(Q) patch -p0 < 0001-libmetal-add-metal_list_for_each_safe-support.patch

$ git diff openamp/open-amp.defs
diff --git a/openamp/open-amp.defs b/openamp/open-amp.defs
index 3bc27629ef..3819533124 100644
--- a/openamp/open-amp.defs
+++ b/openamp/open-amp.defs
@@ -44,7 +44,7 @@ CSRCS += open-amp/lib/virtio/virtqueue.c
 # Download and unpack tarball if no git repo found
 ifeq ($(wildcard open-amp/.git),)
 open-amp.zip:
-       $(call DOWNLOAD,https://github.com/OpenAMP/open-amp/archive,v$(VERSION).zip,open-amp.zip)
+       $(call DOWNLOAD,file:///srv/pkgs,libopen-amp-v$(VERSION).zip,open-amp.zip)
        $(Q) unzip -o open-amp.zip
        $(Q) mv open-amp-$(VERSION) open-amp

Here is a copy of the nuttx I built. I hope it helps.

yf13 avatar Dec 06 '23 01:12 yf13

@acassis As I commented above, I was not able to reproduce the issue. Could you try the latest nuttx with your PC to check if the issue is happening?

masayuki2009 avatar Dec 06 '23 03:12 masayuki2009

Checked with recent build and it passed:

nsh> cat /proc/version
NuttX version 12.4.0 639c053289 May  3 2024 07:26:03 rv-virt/fb-dirty
nsk> free
                 total       used       free    maxused    maxfree  nused  nfree
      Umem:   33298060    1282804   32015256    2586604   31994992     55      6
nsh> ostest
...
Final memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     1fc168c  1fc168c
ordblks         2        4
mxordblk  1e85d18  1e83470
uordblks   13b8fc   13c9cc
fordblks  1e85d90  1e84cc0
user_main: Exiting
ostest_main: Exiting with status 0
nsh>

We can close this for now.

yf13 avatar May 02 '24 23:05 yf13