My bootloader works correct. The application to be bootloaded works correct on it's own when is it programmed directly onto the micro. When I bootload the application with the bootloader and jump direct to the application from the bootloader I have the following problem:
The application starts up, I enter the same run mode as in the bootloader:
MC_ME_SetPowerMode(MC_ME,POWER_MANAGER_DRUN); //this works correct.
//Then I initialize all the clocks:
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);//this works correct
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);//this function does not work
The above mentioned function calls:
CLOCK_DRV_Init(config);
//This function calls:
CLOCK_SYS_Reset();
//which calls:
MC_ME_ResetClockSourcesConfiguration(MC_ME);
//and
MC_ME_ResetPeripheralsConfiguration(MC_ME,(uint32_t)MC_ME_PERIPH_CONFIG_COUNT);
//and
MC_ME_ChangeMode(MC_ME);
//to enable mode transition
//The code then gets stuck in this loop:
for (i= 0U; i < MC_ME_COMPLETE_TRANSITION_TIMEOUT; i++)
{
/* Check whether transition completed */
if (MC_ME_GetTransitionStatus(MC_ME))
{
retValue = STATUS_SUCCESS;
break;
}
}
//The S_MTRANS bit in the MC_ME->GS register remains set indicating that mode transition is ongoing and never gets cleared.
Why is this happening? The clock settings in the bootloader and application code is exactly the same.
As an experiment I call the CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
function twice in the application, and that works.
I also made sure the SRAM, FLASH and local data memory does not overlap as specified in the linker files for both applications.
Regards,
Pierre