@@ -186,10 +186,11 @@ fn main() -> ! {
186186 ) ;
187187 defmt:: info!( "boot reason: 0x{:04x}" , boot_reason) ;
188188 defmt:: info!(
189- "reset status: 0x{:02x} (external: {:?}, watchdog reset: {:?})" ,
189+ "reset status: 0x{:02x} (external: {:?}, watchdog reset: {:?}, power-on: {:?} )" ,
190190 reset_status. 0 ,
191191 reset_status. is_external( ) ,
192- reset_status. is_independent_watchdog( )
192+ reset_status. is_independent_watchdog( ) ,
193+ reset_status. is_power_on( ) ,
193194 ) ;
194195 defmt:: info!( "" ) ;
195196
@@ -244,17 +245,17 @@ fn main() -> ! {
244245 watchdog:: pet ( ) ;
245246 let bl_board = board_init == BoardInitResult :: StartBootloader ;
246247 let bl_program = program. is_err ( ) ;
247- let bl_boot_reason = boot_reason == BootReason :: InvalidUserProgram as _
248+ let mut bl_boot_reason = boot_reason == BootReason :: InvalidUserProgram as _
248249 || boot_reason == BootReason :: SurpriseInUser as _
249250 || boot_reason == BootReason :: SurpriseInBootloader as _
250251 || boot_reason == BootReason :: StartBootloader as _
251252 || boot_reason == BootReason :: FactoryReset as _ ;
252- let bl_reset_cause = ( reset_status. is_external ( ) && ThisBoard :: PIN_RESET_PREVENTS_AUTORUN )
253+ let mut bl_reset_cause = ( reset_status. is_external ( ) && ThisBoard :: PIN_RESET_PREVENTS_AUTORUN )
253254 || reset_status. is_independent_watchdog ( )
254255 || reset_status. is_window_watchdog ( ) ;
255- watchdog:: pet ( ) ;
256256
257257 // Print status.
258+ watchdog:: pet ( ) ;
258259 defmt:: info!( "" ) ;
259260 defmt:: info!( "enter bootloader due to" ) ;
260261 defmt:: info!( " board: {:?}" , bl_board) ;
@@ -263,6 +264,17 @@ fn main() -> ! {
263264 defmt:: info!( " reset cause: {:?}" , bl_reset_cause) ;
264265 defmt:: info!( "" ) ;
265266
267+ if reset_status. is_power_on ( )
268+ && ( boot_reason == BootReason :: SurpriseInUser as _
269+ || boot_reason == BootReason :: SurpriseInBootloader as _ )
270+ {
271+ defmt:: info!(
272+ "ignoring bootloader entry reasons \" boot reason\" and \" reset cause\" due to power-on reset"
273+ ) ;
274+ bl_boot_reason = false ;
275+ bl_reset_cause = false ;
276+ }
277+
266278 // Enter bootloader if required.
267279 let mut bootloader_result = None ;
268280 let mut powered_on = false ;
0 commit comments