MK64F bootloader jump into Application Issue

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

MK64F bootloader jump into Application Issue

792 Views
chhsu0229
Contributor II

I try to write a code that bootloader jump to application. The code is as below.

void bootloader_run(void)

{

volatile uint32_t addr = 0x40000;  //Application Address

void (*entryPoint)(void);

uint32_t runBootloaderAddress ;

__DSB();
__ISB();

__set_MSP(*((volatile uint32_t *)addr));
__set_PSP(*((volatile uint32_t *)addr));

SCB->VTOR = (uint32_t)addr;

runBootloaderAddress = *((volatile uint32_t *)addr+4);

entryPoint = (void (*)(void))runBootloaderAddress;

entryPoint();

}

int main(void)

{

   /* Init board hardware. */
   BOARD_InitBootPins();
   BOARD_InitBootClocks();
   BOARD_InitBootPeripherals();

   bootloader_run();

   while(1)

   {

   }

   return 0;

}

----------------------------------------------------------------------------------------------------

My application code is from address 0x40000  ~ 0x7FFFF and is as below,

It sends message via UART0 to PC period 1 sec.

I have verified the application code is work before (start address is 0x00). 

uint8_t g_tipString[] = "RC-EDA example\r\n";

int main(void)

{

   BOARD_InitBootPins();
   BOARD_InitBootClocks();
   BOARD_InitBootPeripherals();

   while(1)

   {

      UART_SendEDMA_Data(UART0, g_tipString, (sizeof(g_tipString) - 1));

      Delay_MS(1000);

   }   

}

----------------------------------------------------------------------------------------------------

Flash:

0x0000    | bootloader |

                |                   |

0x40000  | application |

                |                   |

0x7FFFF  | end            |

It does not work and I do not know what is the issue? 

I research the paper about "jump bootloader application" in nxp community and try to google all of the topic.

0 Kudos
4 Replies

685 Views
nxf56274
NXP Employee
NXP Employee

Hi,

You do not set the SCB->VTOR before you set the msp.

Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

685 Views
chhsu0229
Contributor II

Hi Da Li,

I forget to list "SCB->VTOR = (uint32_t)addr;"

I also do that .

0 Kudos

685 Views
nxf56274
NXP Employee
NXP Employee

Hi,

You can refer this link.FRDMK64F SD Bootloader 

Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

685 Views
mjbcswitzerland
Specialist V
0 Kudos