-
Notifications
You must be signed in to change notification settings - Fork 588
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
NaxRISCV Bare Metal Demo not working #2169
Comments
Ok I have figured it out. The NaxRISCV is booting into user mode, and for comparison, the VexRISCV is in machine mode. Mstatus for the NaxRISCV is 0x2000, i.e. MPP field which is bits 11,12 = 0x00 == User mode. Mstatus for the NaxRISCV is 0x1800, i.e. MPP field which is bits 11,12 = 0x11 == Machine mode. Just figuring out how to change this now :) EDIT: PrivilegedPlugin_logic_machine_mstatus_mpp <= 2'b11; But this didn't help! Then I found this in call plic_init // initialize external interrupt controller
li t0, 0x800 // external interrupt sources only (using LiteX timer);
// NOTE: must still enable mstatus.MIE!
csrw mie,t0 I change it to li t0, 0x808 And now all is working. Is this the appropriate method to do enable interrupts, or does |
Hi ^^
NaxRiscv boot in machine mode. If do baremetal stuff only, you never need to change the mpp value, because once the CPU enter an interrupt, the MPP field is changed to the privilege the CPU was in (machine).
This seems ok to me ^^ |
Ok I’ll check other CPUs for this same issue first and make a PR to fix this so the bare metal demo works. One question though, why is it halting on |
Fix for demo.py make routine and enjoy-digital#2169
It shouldn't, it is like, as you said, if NaxRiscv wasn't in machine mode anymore. |
I made a PR #2170 showing what I changed (a single character in
|
Thanks ^^
Hmm, so that is weird i can't reproduce the issue. I'm happy to take a look into your wave.fst ^^ |
Hi, thanks for that. I’ll check my repo is all updated and get you those waveforms tomorrow. Could you let me know what your Verilator version was too? |
Thanks ^^ I'm using : Verilator 4.218 2022-01-17 rev v4.218 |
So I installed fresh, and ran just the above 3 simulation commands Relevant dependencies are:
and... it worked! I honestly have no clue what has changed as I had encountered the error when installing Litex on a different machine. I did install with 2024.12 once, maybe that interfered. I have checked and the following likewise works:
Thank you for your time, I'm glad a simple reinstall fixed the issue. |
Hi,
I am experimenting with different cores and found that the bare metal demo does not work for NaxRISCV under simulation or FPGA.
I am able to boot, but only get the "Liftoff!" printout and nothing else once it jumps into the demo.bin. This is due to the processor stalling on the interrupt handling routines specified in demo's main.c:
Having spent a bit of time figuring out why, this seems related to #1754, #1584, #2023, where the processor did not have its interrupt handling defined.
I checked
/soc/cores/cpu/naxriscv/irq.h
and the interrupt handling is all there, which I assume is used to tell the core when I type into the terminal and press enter etc.I have found that the set global interrupts function,
irq_setie(1);
is causing the CPU to halt execution when it tries to enable the interrupst with the following:asm volatile ("csrrs x0, " "mstatus" ", %0" :: "i"(CSR_MSTATUS_MIE));
Which translates to
asm volatile ("csrrs x0, " "mstatus" ", %0" :: "i"(0x8));
I have tested and setting this
mstatus
register to0x0
doesn't halt the processor, as based off the instruction set, a value of 0x0 will not write to the register.Cheers.
The text was updated successfully, but these errors were encountered: