This IOCTL returns the Fail Safe Boot status and the reset reason bits. This feature is available since Toradex WinCE BSP V3.6:
#define IOCTL_HAL_GETBOOTFLAGS CTL_CODE(FILE_DEVICE_HAL, 2123, METHOD_BUFFERED, FILE_ANY_ACCESS)
DWORD bootFlags; KernelIoControl(IOCTL_HAL_GETBOOTFLAGS, NULL, 0, &bootFlags, sizeof(DWORD), NULL); BootFlags format: // BootFlags States #define BF_BL (1<< 0) // Normal Bootloader boot (fail safe feature disabled) #define BF_FSBL_FIRST (1<< 1) // First failSafe Bootloader boot (this will never happen) #define BF_FSBL_FIRST_FAILSAFE (1<< 2) // First failSafe Bootloader booted because second FS bootloader failed #define BF_FSBL_SECOND (1<< 3) // Second failSafe Bootloader booted (normal behavior if fail safe feature enabled) // BootFlags Error Flags #define BF_BL_ERROR (1<< 4) // Normal Bootloader Error (fail safe feature disabled) #define BF_FSBL_FIRST_ERROR (1<< 5) // First failSafe Bootloader Error (this is a critical error) #define BF_FSBL_SECOND_ERROR (1<< 6) // Second failSafe Bootloader Error // Reset Reason Bits #define RR_POWERUP (1<< 16) // Boot due to Power-up or HW-Reset #define RR_WATCHDOG (1<< 17) // Boot due to Watchdog-Reset #define RR_LOWPWR_EXIT (1<< 18) // Boot due to Low-Power-Exit (this bit is not supported) #define RR_GPIO (1<< 19) // Boot due to GPIO-Reset