What happens
machine.reset_cause() is absent from src/pymcu_micropython/machine.py. The module
already has the reset-cause constants (PWRON_RESET, HARD_RESET, WDT_RESET,
DEEPSLEEP_RESET, SOFT_RESET), and soft_reset() (a watchdog-triggered restart) is now
implemented -- this issue is left tracking only reset_cause().
The ATmega328P's MCUSR register records the previous reset's cause: PORF (power-on),
EXTRF (external/reset pin), BORF (brown-out) and WDRF (watchdog) bits. The compiler's
AVR startup stub does not currently touch MCUSR at all, so nothing captures it before
avrdude's bootloader (where one is in the flashing path) or any later code can clear it, and
the register is not spelled the same way across every AVR part in this HAL (some older parts
call it MCUCSR, not MCUSR).
What I'd expect
machine.reset_cause() reading a value the startup stub captured from MCUSR/MCUCSR
before anything else can touch it, with the right register name and address picked per chip
the way pymcu.hal.avr.watchdog already dispatches per chip.
Repo choice
The startup-stub capture and per-chip register naming belong in PyMCU's AVR HAL/runtime;
src/pymcu_micropython/machine.py only needs to read back whatever the HAL exposes.
What happens
machine.reset_cause()is absent fromsrc/pymcu_micropython/machine.py. The modulealready has the reset-cause constants (
PWRON_RESET,HARD_RESET,WDT_RESET,DEEPSLEEP_RESET,SOFT_RESET), andsoft_reset()(a watchdog-triggered restart) is nowimplemented -- this issue is left tracking only
reset_cause().The ATmega328P's
MCUSRregister records the previous reset's cause:PORF(power-on),EXTRF(external/reset pin),BORF(brown-out) andWDRF(watchdog) bits. The compiler'sAVR startup stub does not currently touch
MCUSRat all, so nothing captures it beforeavrdude's bootloader (where one is in the flashing path) or any later code can clear it, and
the register is not spelled the same way across every AVR part in this HAL (some older parts
call it
MCUCSR, notMCUSR).What I'd expect
machine.reset_cause()reading a value the startup stub captured fromMCUSR/MCUCSRbefore anything else can touch it, with the right register name and address picked per chip
the way
pymcu.hal.avr.watchdogalready dispatches per chip.Repo choice
The startup-stub capture and per-chip register naming belong in
PyMCU's AVR HAL/runtime;src/pymcu_micropython/machine.pyonly needs to read back whatever the HAL exposes.