mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-10-15 02:49:54 +00:00
hwinfo_get_reset_cause() reads a latched register. It was read inline in main_companion.cpp and cleared there, so the repeater, room server and observer never read it and never cleared it: their flags carried into the next boot, and whichever role read first defined what any later reader would see. helpers/boot_info.c reads it once in a SYS_INIT at POST_KERNEL, logs it, stores it and clears the register. That runs before main() on every role. zephcore_boot_reset_cause() hands out the stored copy and reports false where the platform has no support, which a caller can distinguish from a cause of 0. The clear's return is discarded deliberately: ESP32 has no hwinfo_clear_reset_cause() implementation, so the weak stub returns -ENOSYS. The capture is still correct there; only the next boot's reading is not. Logging in boot_info_init() rather than only in the consuming role matters because the clear now happens everywhere. Without it a repeater that rebooted on WATCHDOG or LOCKUP would have the evidence cleared and recorded nowhere, where before it survived in the register for whoever read it over SWD. main_companion.cpp reads the stored copy and renders through a table with one row per RESET_* bit, so a cause with no label is no longer logged as bare hex. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>