Soft panic for RTIO PLL reasons #199
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/artiq-zynq#199
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mwojcik/artiq-zynq:pll_error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #198 #200
Making it a soft panic makes it more involved with a bit of code duplication - setting up mgmt requires setting up the interface and sockets. Maybe can be done a bit cleaner.
Isn't there a way to put this into the actual panic handler? (With correct handling of recursive panic, i.e. fall back on a simple panic that writes an error message to the UART and stops the CPU)
It would be a lot more general and useful then.
Hm, doesn't seem like multiple layers of panicking is supported in Rust.
At best probably the soft_panic function could be separated further - that is, not require anything besides maybe error message - it get the config, timer itself. That could be implemented within Ok/Err checks manually, or with a checking macro to keep things simpler (but not as simple as
)?;
). There's also the issue of checking if mgmt was started yet or not and acting accordingly.What happens if you panic in the panic handler?
Can recursive panic be detected with something as simple as
static mut HAS_PANICKED = false; ...
?...yeah of course, runtime has its own panic handler too (https://git.m-labs.hk/M-Labs/artiq-zynq/src/branch/master/src/runtime/src/panic.rs) and it already implements nested panic protection (in the same way you mentioned). I can piggyback on that, extend its behavior, but I found a rather concerning issue, it itself causes another panic before printing "End backtrace". I'll look into that a bit deeper.
Now it's mixed in panic handler code.
coremgt:
excerpt from UART:
No backtrace (as mentioned in #200 it causes a nested panic). However if the soft panic panics, backtrace would be ran (and possibly cause a nested panic again).
I'm thinking I also could bring back the previous rtio_clocking, with one adjustment of panicking when RTIO PLL doesn't lock.
@ -493,0 +542,4 @@
mgmt::start(cfg);
//getting eth settings disables the LED - need enable it here
Why does it disable the LED?
getting eth settings sets up I2C to communicate with the ethernet controller;
I2C setup also resets GPIO:
https://git.m-labs.hk/M-Labs/zynq-rs/src/branch/master/libboard_zynq/src/i2c/mod.rs#L57
and I2C GPIO (MIO 33, 50, 51) is in the same bank as the error led (MIO 37); so resetting the entire port again causes the LED to go off.
Okay I see. Maybe make the comment a bit more clear (e.g. "we reinitialized the GPIO controller, so only now can we turn on the error LED")
Also, the non-mgmt panic handler should also turn on the LED to make sure.
I don't understand why getting the backtrace would cause another panic - could you elaborate?
@ -84,6 +86,7 @@ enum Reply {
static CACHE_STORE: Mutex<BTreeMap<String, Vec<i32>>> = Mutex::new(BTreeMap::new());
static DMA_RECORD_STORE: Mutex<BTreeMap<String, (Vec<u8>, i64)>> = Mutex::new(BTreeMap::new());
static mut MGMT_STARTED: bool = false;
Where is this used?
Backtrace calls libunwind and it arrives here: https://git.m-labs.hk/M-Labs/artiq-zynq/src/branch/master/src/runtime/src/kernel/core1.rs#L227
If there's no kernel loaded (and the kernel is not the cause of panic), it panics here again.
@ -39,1 +56,4 @@
}
fn soft_panic(info: &core::panic::PanicInfo) -> ! {
// log panic info to log (prints not visible in coremgmt logs)
Had to read that twice...
Maybe reformulate along the lines:
"Write panic info to the log, so that coremgmt can see it"
Why would it take the second branch of the
if
in this case? It should only unwind in thetext
section, so the condition&__text_start as *const u32 <= pc && pc < &__text_end as *const u32
should be true, isn't it?7323c1508a
toc6d173a5c5