K64 Custom Bootloader not loading to user application every time.

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

K64 Custom Bootloader not loading to user application every time.

846 Views
aromal_pj
Contributor I

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).

Labels (1)
Tags (1)
0 Kudos
3 Replies

673 Views
scottm
Senior Contributor II

What happens if you try to step through it in the debugger?

0 Kudos

673 Views
aromal_pj
Contributor I

while debugging, bootloader works fine until the jump statement to 0x40000. Same issue there, not always loading the custom app from the address 0x40000.

0 Kudos

673 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Aromal PJ,

  Please download the app code to 0X40000 at first, then debug your bootloader code.

  Check the address 0X40000 data, whether it is the same data as the app.hex you downloaded, you must make sure your bootloader code size is smaller than 0x40000.

  Debug your bootloader, if it can't jump to the 0X40000, where it will jump ? Step the code, why it can't jump to 0X40000.

  Besides, you also can refer to KBOOT2.0 code for K64, that code works OK:

www.nxp.com/kboot


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos