I am using the K22FN1M0 part and having an issue where a small number of processors seem to be affected. The problem is that sometimes, the main application seems to fail to run properly intermittently. The same exact code will run on other parts seemingly just fine. When I say fails to run properly, I mean we get behavior as if it were some unhandled exception. If the code is slightly altered and recompiled, the processors that were failing may behave as expected. I'm looking for some ideas about how to troubleshoot this further.
I am using a custom bootloader that essentially does the following:
uint32_t new_sp = IMAGE_ADDR;
uint32_t new_pc = IMAGE_ADDR;
SCB->VTOR = (uint32_t)BLOCK1_BASE;
asm("mov LR, 0xFFFFFFFF");
In this case, IMAGE_ADDR is the 2nd flash block (also BLOCK1_BASE) where the main application is located. Note that the processor startup code is shared in both main application and bootloader. Before utilizing a bootloader, this type of issue was not observed. I have altered the main application to not run some of the startup code that is already run by the bootloader, but it had no affect on the issue. Are there certain items in startup that if run a second time could result in some behavior like this? Any insight is appreciated.