-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Describe the bug
I ran zephyr OS on a RISC-V based board, and had already enabled CONFIG_CPU_HAS_FPU, CONFIG_FPU, CONFIG_FPU_SHARING, CONFIG_FLOAT_HARD.
But unfortunately, our system was hanging when some device drivers using float in their driver init function.
After I traced code, I found that system will create bg_thread_main thread with K_ESSENTIAL but K_FP_REGS in init.c.
And RISC-V arch will not set FS filed in mstatus csr if we don't give K_FP_REGS option when creating thread.
After that, bg_thread_main will init device driver with FPU disabled, at the same time system might got stuck if some driver using float hw instruction.
To Reproduce
Enable CONFIG_CPU_HAS_FPU, CONFIG_FPU, CONFIG_FPU_SHARING, CONFIG_FLOAT_HARD.
Add float operation in hello_world sample.
Build hello_world sample and run on a RISC-V arch based board.
Expected behavior
System got stuck.
Impact
We have to limit drivers not to use float when initializing. And we must create another thread with float ability for using float operation.
Logs and console output
(z_swap_irqlock 161)mstatus:0x80007800
(bg_thread_main)mstatus:0x88
***** delaying boot 1ms (per build configuration) *****
*** Booting Zephyr OS version 2.3.0-rc1 (delayed boot 1ms) ***
[z_sched_lock] scheduler locked (0x800095a0:255)
[k_sched_unlock] scheduler unlocked (0x800095a0:0)
FS field didn't be set when entering main function but indeed be set when system init.
Environment (please complete the following information):
- OS: Zephyr 2.3.0
- Toolchain: Zephyr-sdk-0.11.3
- Commit SHA or Version used
Zephyr 2.3.0
Additional context
Add any other context about the problem here.