enjoy-digital / litex

Build your hardware, easily!
Other
2.77k stars 538 forks source link

Console Freezing Issue with CVA5 CPU #1981

Open Liamfeng opened 1 month ago

Liamfeng commented 1 month ago

Hello,

I am experiencing an issue when running the console with the CVA5 CPU using the script ./litex_sim.py --cpu-type cva5 --with-sdram. The console consistently freezes after typing just a few characters, without even pressing enter. On rare occasions, I can enter a full command, but this is uncommon.

I have isolated the problem to the litex_getc(FILE *file)function located in litex/litex/soc/software/libc/stdio.c. The program appears to get trapped in an infinite while loop within this function, preventing it from progressing.

Screenshot from 2024-06-04 16-58-23

In an effort to resolve this, I replaced the while loop with a for loop that iterates 1000 times, hoping that breaking out of the loop would stop the freezing. Unfortunately, the console still freezes after a few characters.

The screenshot below shows my console in a frozen state when running on the CVA5 CPU:

image

I also tested the script with the vexriscv_smp and vexriscv CPUs. Although the issue persists, I am able to type a lot more characters before the console freezes:

image

Could anyone help me resolve this issue or provide insight into what might be happening? Any assistance would be greatly appreciated. Thank you!

Environment: CPU: CVA5 (also tested with vexriscv_smp and vexriscv) Script: ./litex_sim.py --cpu-type cva5 --with-sdram File: litex/litex/soc/software/libc/stdio.c Function: litex_getc(FILE *file)

enjoy-digital commented 3 weeks ago

Hi @Liamfeng,

I haven't used personally CVA5 yet but if you want more visibility, in simulation it's possible to enable tracing signals to a waveform with--trace , this could allow you to better understand what the CPU is doing through the memory/peripheral accesses.