Replies: 2 comments 2 replies
-
When we enter a critical-section we clear MIE in MSTATUS and no interrupts will be served (pretty much what it should do) The only references to NMIs in the ESP32-C3 TRM I see are related to GPIO and it looks to me that those registers exist because the IP block is the same / similar to those used in the Xtensa based chips - but I don't really know t.b.h. The linked section in the RISC-V spec sounds to me like they are talking about exceptions there (Non-maskable interrupts (NMIs) are only used for hardware error conditions) and indeed exceptions will be handled no matter what. Maybe the watchdog in combination with DEBUG_ASSIST's PC logging feature could help a bit. The watchdog (if configured to reset) will reset the device even if the code got stuck inside a critical-section. Then on the next boot it is possible to get the PC at the time of the reset. But nothing else will be available - just the PC I think your best bet here would be to use JTAG debugging. On ESP32-C3 (starting at revision 3) you won't even need additional hardware for that. You can use OpenOCD + GDB or probe.rs for that. Halting the CPU via the debug interface will also work inside critical-sections and the additional benefits from using a debugger is probably worth the effort of setting up things |
Beta Was this translation helpful? Give feedback.
-
Your problem is most probably already solved - however leaving this here since it's quite useful: On ESP32-C3 (and I guess all chips with debug-assist) the ROM bootloader will always enable PC logging and print the last seen PC (e.g. The only important thing is you should use a TIMG watchdog since the RTC watchdog will also reset the logged PC |
Beta Was this translation helpful? Give feedback.
-
Hello! We (@dougli1sqrd & I) have gotten ourselves into trouble in the usual way with concurrency, and have introduced some kind of a deadlock or similar in our project. In an effort to provide ourselves tools to debug this, I've been working on a way to print out a backtrace on a GPIO trigger (i.e. when we push the
boot
button on the dev board). It works (well, not for nested interrupts, but that's a later project), but unsurprisingly not when the code is in acritical_section
(i.e. interrupts are disabled).I found a few references to "non-maskable interrupts" (NMIs) in both the code and the esp32c3 reference manual, which sure seemed like they might help "see" into a critical section. But, the my attempt at setting the NMI enabled bit and providing a
GPIO_NMI
handler yielded the same results as before: the interrupt doesn't fire until we leave thecritical_section
.So, some questions:
interrupt
(the various reset flavors seem like they'd clobber it), which would present the same "how to NMI" question? I suppose it might be possible to do something cute with the reset & the sleep/restore flow, maybe?Beta Was this translation helpful? Give feedback.
All reactions