I have designed a custom bootloader for Freedom K64F board (MCU Expresso, FreeRTOS)with following components.
1. USB Mass Storage Support
2. GPIO for turning Off and On Leds
3. Flash Support
4. Console Support (UART0)
5. Hardware Timer
The code for jumping user app ,
void LaunchAppFirmware()
{
uint8_t ucIndex = 0;
void (*FwCodeEntry)(void);
uint8_t ucSerRoutineAddr;
uint32_t *pulStartFlashPointer = NULL;
USB_OsaEnterCritical(&ucSerRoutineAddr);
SCB->VTOR = MAIN_FW_IMAGE_BASE;
pulStartFlashPointer = (uint32_t *)(MAIN_FW_IMAGE_BASE + 4);
FwCodeEntry = (void *) *pulStartFlashPointer;
ClearLed(); // Stopping Timer and Clear GPIO Bit
USB_HostDeinit(g_HostHandle);
DbgConsole_Deinit();
//Clear Enabled IRQs
for(ucIndex = 0 ; ucIndex < 16; ucIndex++)
{
NVIC->ICER[ucIndex] = 0xFFFFFFFF;
}
//Clear All Pending Interrupts
for(ucIndex = 0 ; ucIndex < 16; ucIndex++)
{
NVIC->ICPR[ucIndex] = 0xFFFFFFFF;
}
SYSTICK_CM4_CSR_REG &= (~1);
// Jump to user application
FwCodeEntry();
return;
}
I am jumping to my custom application (FreeRTOS, KDS IDE) in 0x40000
The problem i am facing is bootloader cannot jump to the custom application every time.
If I manually press reset button couple of times, it will jump and work the custom application from (0x40000).