I made custom boards and I see some units failing the bootloader integrity check and gets stuck in a fault state. The only way to recover is to do a hardware reset. This failure only occurs intermittently. How is it possible to fail intermittently when I am not changing any flash contents? It should fail always or never unless there is some problem with the flash. When it fails, is it possible to perform a reset instead of being stuck in fault? It is difficult to detect the failure and perform a hardware reset in the end product.
You can use Watch dog timer (WDT) to cause device reset during malfunction or when the program is out-of-control due to unexpected inputs or conditions.
Can you please share the call stack details, when its getting stuck.
I can't add anything to debug. My bootloader code never runs. I set a GPIO high as first line in main() and it never reaches it. If I do a hardware reset it will work again and start running the application. If I don't program the bootloader and just program my application, I don't see this problem.