s32k118 Can't Jump To User Application,Why?

cancel
Showing results for 
Search instead for 
Did you mean: 

s32k118 Can't Jump To User Application,Why?

1,782 Views
1515190497
Contributor II

I use the Bootloader from the AN12218 example.

JumpToApplication function:

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_CODE_ADDR_0;
 /* Jump to application PC (r1) */
 __asm("mov pc, r1");
}
call by;
       __asm("cpsid i");
        JumpToUserApplication(*((uint32_t*)0x0000E000), *((uint32_t*)(0x0000E000 + 4)));
Bootloader Linker file:
/* Entry Point */
ENTRY(Reset_Handler)
HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x00000200;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x00000200;
/* If symbol __flash_vector_table__=1 is defined at link time
 * the interrupt vector will not be copied to RAM.
 * Warning: Using the interrupt vector from Flash will not allow
 * INT_SYS_InstallHandler because the section is Read Only.
 */
M_VECTOR_RAM_SIZE = DEFINED(__flash_vector_table__) ? 0x0 : 0x00C0;
/* Specify the memory areas */
MEMORY
{
  /* Flash */
  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x000000C0
  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x0000DBF0
  /* SRAM_L */
  m_custom              (RW)  : ORIGIN = 0x1FFFFC00, LENGTH = 0x00000400
  /* SRAM_U */
  m_data                (RW)  : ORIGIN = 0x20000000, LENGTH = 0x000030C0
  m_data_2              (RW)  : ORIGIN = 0x200030C0, LENGTH = 0x00002740
}
Application linker file:
/* Entry Point */
ENTRY(Reset_Handler)
HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x00000200;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x00000200;
/* If symbol __flash_vector_table__=1 is defined at link time
 * the interrupt vector will not be copied to RAM.
 * Warning: Using the interrupt vector from Flash will not allow
 * INT_SYS_InstallHandler because the section is Read Only.
 */
M_VECTOR_RAM_SIZE = DEFINED(__flash_vector_table__) ? 0x0 : 0x00C0;
/* Specify the memory areas */
MEMORY
{
  /* Flash */
  m_interrupts          (RX)  : ORIGIN = 0x0000E000, LENGTH = 0x000000C0
  m_flash_config        (RX)  : ORIGIN = 0x0000E400, LENGTH = 0x00000010
  m_text                (RX)  : ORIGIN = 0x0000E410, LENGTH = 0x00019000
 
  /* SRAM_L */
  m_custom              (RW)  : ORIGIN = 0x1FFFFC00, LENGTH = 0x00000400
  /* SRAM_U */
  m_data                (RW)  : ORIGIN = 0x20000000, LENGTH = 0x000030C0
  m_data_2              (RW)  : ORIGIN = 0x200030C0, LENGTH = 0x00002740
}
But I can't jump to Application function:
debug interface.png
How can I solve it?I hope somebody has an idea.

0 Kudos
9 Replies

900 Views
happybaby8882
Contributor I

Hi, I got the same problem as you did. Do you solve the problem? Could you tell me how?

0 Kudos

893 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

 

can you please share more details? Are you using RappID bootloader, your custom bootloader, what kind of error/issue you can see? 

 

Jiri

0 Kudos

1,176 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

from your screenshot it looks that you already jumped into application, but application ends in some exception. Is your app running as standalone (without bootloader)? 

Jiri

0 Kudos

1,176 Views
1515190497
Contributor II

Hi Jiri,

Can't I make app running as standalone ?

I don't know how to make my app running with bootloader. Can you tell me?Thanks.

xiaoping

0 Kudos

1,176 Views
jiri_kral
NXP Employee
NXP Employee

Um, I don't get it. So, the first step is check, if the application is working without bootloader. It looks, that the issue is in the application itself, not in bootloader. If I'm correct - your app starts on 0xE000 - from screenshot you are already in the app - in loop on address 0xE46C. I'm assuming that this is loop where program ends if some exception occurs:

pastedImage_1.png

Jiri 

0 Kudos

1,176 Views
1515190497
Contributor II

Hi Jiri,

If i don't use bootloader jump to app,app is correct.Of course,app memory start from 0x0. 

Now how to avoid this situation? Or how to configure my project make app running with bootloader after jump?

Thank you very much for your help.

xiaoping

0 Kudos

1,175 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

The issue may be caused by some peripheral already configured in Bootloader, clock settings, incorrect interrupt vector table (VTOR register - application vector table is on different location that boodloader's)  or any other stuff. It's hard to say where may be issue. Try to debug your code. Select your app project in design studio. In debug configuration choose attach to target, set breakpoint to app entry point: 

pastedImage_1.png

invoke reset and step by step try find out what's wrong: 

s32ds_2019-06-13_11-03-43.png

Jiri 

0 Kudos

1,175 Views
1515190497
Contributor II

Hi,

I use J-Link Debug.

If App is hello_wold_s32k118 :

screent0.png

I speculate issue is in bootloader. Do you have example of bootloader using CAN ? 

Thanks

0 Kudos

1,176 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

I'm afraid that there is no CAN bootloader example available.

Jiri 

0 Kudos