-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xv6 operating system hangs when running on FPGA #155
Comments
Nothing else after this... |
Tried making this run on only one thread to check for a deadlock. Still hangs... --- a/main.c
+++ b/main.c
@@ -29,7 +29,7 @@ main(void)
binit(); // buffer cache
fileinit(); // file table
bdev_init(); // disk
- startothers(); // start other processors
+// startothers(); // start other processors
kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers()
userinit(); // first user process
mpmain(); // finish this processor's setup |
Made a global variable 'count' and added the following to the top of trap():
I can see the LEDS counting off. So interrupts are enabled and it is receiving them. |
Added code to dump interrupt pending register. Only LED1 is lit (indicating it is taking timer interrupts):
|
Disabled the timer interrupt by commenting out the IRQ enable in mpmain:
A theory I had is that the interrupt is stuck, so eret immediately takes another interrupt. The interrupt LED no longer is lit, but the process still hangs in the same place, which disproves this theory. |
I can do ctrl-P in the terminal (process listing) and it prints the following: 1 run initcode ("run" corresponds to the state RUNNING). So userinit() has successfully completed and created an init process, which is supposedly running, but doesn't seem to have forked the shell. |
Added code to indicate if a syscall occurs. The LEDs do not turn on:
Almost the first thing initcode should do is execute a syscall to execute the real 'init' process: .globl _start
_start:
lea s0, init
lea s1, argv
syscall SYS_exec
init:
.string "/init\0"
argv:
.long init
.long 0 |
One issue I noticed is that the the system does not to an iinvalidate after copying the initcode into the first address space. This will probably still contain boot code. |
Tried to add some code to perform iinvalidate, but still hangs:
|
One difference between simulation and FPGA is that the former by default randomizes all flops and SRAM, where the FPGA clears it. I tried disabling this in the simulator by using the +randomize=0 parameter, but it still booted successfully.
This would be a lot easier to debug if I could reproduce it in simulation. |
Hi there, So I added the following command in uart.c. In the function void uartstart() ... And it worked! |
Interesting. It's been a long time since I looked at this problem and I don't remember much about it. 😄 But thanks for the suggestion! |
Interesting, I had also in mind to do something similar in the future. May I ask how did you deal with the MMU logic? I am currently studying the xv6 and for what I understood the MMU is simulated in software (vm.c, walk() function). Does it mean the risc-v core on my fpga does not need to know anything about pages? |
Hi Martin,
the CPU has to do MMU logic in hardware. When vma is activated, the cpu
does the "walk" in hardware to find the appropriate physical memory
location.
The walk function in vm.c is used by the kernel to calculate the right
physical position. This is done in software, but the CPU still has to
do it in hardware.
In my implementation I choose to do the pagetable walk in the simplest
way, by walking through the page tables on every single memory read. So
I did not implement TLB (look aside buffer).
Please, have a look on my repo:
https://gitlab.com/x653/xv6-riscv-fpga
You find the implementation of the virtual memory addresses in
fpga/vma.v
Best
Micha
Am Sonntag, dem 12.02.2023 um 08:06 -0800 schrieb Martin:
… Interesting, I had also in mind to do something similar in the
future. May I ask how did you deal with the MMU logic? I am currently
studying the xv6 and for what I understood the MMU is simulated in
software (vm.c, walk() function). Does it mean the risc-v core on my
fpga does not need to know anything about pages?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID:
***@***.***>
|
https://github.com/jbush001/xv6-nyuzi
This boots fine under the emulator and verilog simulation, but hangs before showing the shell prompt when run on the FPGA board. This could be an issue specific to the FPGA configuration, or it could be exposing a synthesis/simulation mismatch. Should track this down.
Debugging this might be easier if #153 were implemented.
The text was updated successfully, but these errors were encountered: