I have an application that runs on SAMS70. I just recently implemented a bootloader to support firmware update through UART connection to PC. The bootloader is based on the "SafeAndSecureBootloader" example from Atmel/Microchip, but uses the UART and custom messaging to update the firmware.
Now it seems like after introducing the bootloader the application usually crashes within minutes after startup - it ends up in the Dummy_handler() ISR but the stack frame looks quite strange and also seems different at each crash and I haven't been able to get anything useful from it (although I haven't spend much time on it). The only thing I could see was that Interrupt Program Status Register had value 3 which indicates "hard fault".
I have two concerns. First of all, the bootloader does of course initialize some peripherals (UART, timers, etc). How can I be sure that none of that causes problems in the main application? I want the peripherals to be more or less untouched after reset once the main application starts so I tried the following:
- when bootloader starts it checks for valid application in flash
- valid application found and no other flags indicate control should stay in bootloader it will try to invoke the main application
- to invoke the main application the bootloader first writes a special signature in SRAM and then initiates a watchdog reset
- after reset the bootloader checks for the signature and if set it skips most of the hardware initialization and jumps into main application
This way there is a minimum of hardware initialization done between watchdog reset and start of main application. But it seems it did not help in my case...
Second - how should I proceed with debugging? How can I trace back to where the fault occurred?