stm32h5: stop/standby mode reset_cause not reported
machine.reset_cause() reports 0 instead of 4 when system starts from stop or standby mode.
MicroPython v1.20.0-288-g3a153d92f-dirty on 2023-10-15; NUCLEO_H563ZI with STM32H563ZI
Type "help()" for more information.
The fix is to to add the following in void machine_init(void)
#elif defined(STM32H5)
if (PWR->PMSR & PWR_PMSR_STOPF || PWR->PMSR & PWR_PMSR_SBF) {
// came out of standby or stop mode
reset_cause = PYB_RESET_DEEPSLEEP;
PWR->PMCR |= PWR_PMCR_CSSF;
} else
A PR will follow in the next days.
`machine.reset_cause()` always returns 0 on Arduino Portenta H7
No matter what reset is actually done (I've tried soft, hard, and watchdog), machine.reset_cause() always returns 0. Reading stm.mem32[stm.RCC + stm.RCC_RSR] also returns 0, which I think is expected since modmachine.c tells this register to reset (via RCC->RCC_SR |= RCC_SR_RMVF;) but even if I comment out this line and recompile, the RCC_RSR register still always returns 0. Is it possible the bootloader or other core of the H747 is clearing this before micropython has a chance to?
Have tested on 1.19 and 1.20.