AnsweredAssumed Answered

Why is my application intermittently failing to start properly when being loaded by a bootloader?

Question asked by aaronledger on Jan 15, 2015
Latest reply on Feb 5, 2015 by Butcher

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:

 

    __disable_irq();

 

    uint32_t new_sp = IMAGE_ADDR[0];

    uint32_t new_pc = IMAGE_ADDR[1];

 

    SCB->VTOR = (uint32_t)BLOCK1_BASE;

 

    asm("mov LR, 0xFFFFFFFF");

    __set_MSP(new_sp);

    __set_PSP(new_sp);

 

    ((void(*)(void))new_pc)();

 

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.

Outcomes