Hello,
I have success built and run demo project from Kinetis_Bootloader_2_0_0, the bootloader + led_demo. after that I build another application project from KSDK2.0 like "freertos_tickless", after some modify of KSDK link file, bootloader can jump into KDSK project's main() function.
but KSDK project stuck in call BOARD_BootClockRUN ( a common system clock initialize routine), after some search, I know before bootloader jump in application, it would set clock system back to FEI mode, if from this mode transfer to PEE mode, I need jump into FBE first. so I add CLOCK_SetFbeMode() function call before CLOCK_BootToPeeMode(), but the CLOCK_SetFbeMode() stuck in waiting IREFST :
while (kMCG_FllSrcExternal != MCG_S_IREFST_VAL) { }
In function CLOCK_SetFbeMode() I saw the code have been do some work to wordaround for "Errata: ERR00799", but the issue still exist, sometime can walk through the while() statement, but sometime can't .
I have making those testing in FRDM-K64F and FRDM-K22F, same issue happen.
Cai
Solved! Go to Solution.
after looking for Adapting KDS project for KBOOT flash resident bootloader
I found this issue is come from kboot, but kboot 2.0.0 have same problem. so, I modified the "clock_config_K22F512.c" file to:
else if (expectedMode == kClockMode_FEI)
{
MCG->C1 |= MCG_C1_IREFS_MASK; // Switch to internal reference clock.
while (!(MCG->S & MCG_S_IREFST_MASK))
; // Wait until internal reference clock is ready.
#if 1 // by Cai
int dummy_var = 0;
for(int i = 0; i < 10000; i++)
{
dummy_var = MCG->S;
}
(void)dummy_var; // disable compiler warning
// This is required due to ERR007993
MCG->C4 &= ~MCG_C4_DMX32_MASK ;
#endif
...
after looking for Adapting KDS project for KBOOT flash resident bootloader
I found this issue is come from kboot, but kboot 2.0.0 have same problem. so, I modified the "clock_config_K22F512.c" file to:
else if (expectedMode == kClockMode_FEI)
{
MCG->C1 |= MCG_C1_IREFS_MASK; // Switch to internal reference clock.
while (!(MCG->S & MCG_S_IREFST_MASK))
; // Wait until internal reference clock is ready.
#if 1 // by Cai
int dummy_var = 0;
for(int i = 0; i < 10000; i++)
{
dummy_var = MCG->S;
}
(void)dummy_var; // disable compiler warning
// This is required due to ERR007993
MCG->C4 &= ~MCG_C4_DMX32_MASK ;
#endif
...
Your patch has solved my issue too. Thanks
CD