Skip to content

Commit c5ad340

Browse files
committed
boot: zephyr: Fix IO-based entrance method
If a device uses RESETINFO, than there are some bits set in the resetinfo, even for reboots that should allow to interpret and enter the device recovery. That way it is possible to recover a device through serial recovery if the main application resets due to i.e. watchdog. Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent c9464c9 commit c5ad340

File tree

1 file changed

+39
-0
lines changed
  • boot/zephyr/include/io

1 file changed

+39
-0
lines changed

boot/zephyr/include/io/io.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,45 @@ static inline bool io_boot_skip_serial_recovery()
6767
{
6868
uint32_t rr = nrfx_reset_reason_get();
6969

70+
#ifdef NRF_RESETINFO
71+
/* The following reset reasons should allow to enter firmware recovery or
72+
* loader through an IO state.
73+
*/
74+
const uint32_t allowed_reset_reasons = (
75+
/* Reset from power on reset (reset reason POR or BOR). */
76+
NRFX_RESET_REASON_POR_MASK
77+
#ifdef RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk
78+
/* Reset from power on reset (reset reason other than POR or BOR). */
79+
| RESETINFO_RESETREAS_GLOBAL_RESETPOR_Msk
80+
#endif
81+
/* Reset from pin reset is not masked: it always enables the io-based recovery. */
82+
/* Reset from the watchdog timer. */
83+
| NRFX_RESET_REASON_DOG_MASK
84+
/* Reset from CTRL-AP. */
85+
| NRFX_RESET_REASON_CTRLAP_MASK
86+
/* Reset due to secure domain system reset request. */
87+
| NRFX_RESET_REASON_SREQ_MASK
88+
/* Reset due to secure domain watchdog 0 timer. */
89+
| NRFX_RESET_REASON_SECWDT0_MASK
90+
/* Reset due to secure domain watchdog 1 timer. */
91+
| NRFX_RESET_REASON_SECWDT1_MASK
92+
/* Reset due to secure domain lockup. */
93+
| NRFX_RESET_REASON_LOCKUP_MASK
94+
#if NRF_RESETINFO_HAS_LOCAL_WDT
95+
/* Reset from the local watchdog timer 0. */
96+
| NRFX_RESET_REASON_LOCAL_DOG0_MASK
97+
/* Reset from the local watchdog timer 1. */
98+
| NRFX_RESET_REASON_LOCAL_DOG1_MASK
99+
#endif
100+
/* Reset from the local soft reset request. */
101+
| NRFX_RESET_REASON_LOCAL_SREQ_MASK
102+
/* Reset from local CPU lockup. */
103+
| NRFX_RESET_REASON_LOCAL_LOCKUP_MASK
104+
);
105+
106+
rr &= ~allowed_reset_reasons;
107+
#endif /* NRF_RESETINFO */
108+
70109
return !(rr == 0 || (rr & NRFX_RESET_REASON_RESETPIN_MASK));
71110
}
72111
#else

0 commit comments

Comments
 (0)