kinetis bootloader and application startup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

kinetis bootloader and application startup

Jump to solution
1,501 Views
phantomgz
Contributor III

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

Labels (1)
1 Solution
753 Views
phantomgz
Contributor III

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

...

View solution in original post

2 Replies
754 Views
phantomgz
Contributor III

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

...

753 Views
Lorac
Contributor III

Your patch has solved my issue too. Thanks

CD

0 Kudos