Hi,SDK
I am developing a bootloader program for S32K146.
Now I am able to write my application code to the flash memory
but the boot loader is not jumping to the application code.
/*linker of bootloader*/
/* Specify the memory areas */
MEMORY
{
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x000DABF0
/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00008000
/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x0000F000
}
/*linker of application code*/
/* Specify the memory areas */
MEMORY
{
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00025000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00025400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00025410, LENGTH = 0x000DABF0
/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x0000F000
}
#define APP_ENRTY_POINT_FLASH_ADDR (0x025000UL)
static void EnterAppPro(void)
{
/*延时*/
TimeDelay(2000);
WDOG_disable();
BSP_DISABLE_IRQ();
/* 初始化中断向量表地址 */
/* Check if a valid application is loaded and jump to it */
JumpToUserApplication(*((uint32_t*)APP_ENRTY_POINT_FLASH_ADDR), * ((uint32_t*) (APP_ENRTY_POINT_FLASH_ADDR + 4)));
}
/**
* Used to jump to the entry point of the user application
* The Vector table of the user application must be located at 0x1000
*
* */
void JumpToUserApplication( unsigned int userSP, unsigned int userStartup)
{
/* Check if Entry address is erased and return if erased */
if(userSP == 0xFFFFFFFF){
return;
}
/* Set up stack pointer */
__asm("msr msp, r0");
__asm("msr psp, r0");
/* Relocate vector table */
S32_SCB->VTOR = (uint32_t)APP_ENRTY_POINT_FLASH_ADDR;
/* Jump to application PC (r1) */
__asm("mov pc, r1");
}
I don't know where my code went wrong, could you give me some hints?
Thanks~~