Issue in Jump to Application from Bootloader

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Issue in Jump to Application from Bootloader

4,243件の閲覧回数
lakshmi_s
Contributor I

I am using S32K144 EVB, out of 512kb of PFlash 44kb is used for Bootloader, and remaining for Application.

app config

m_interrupts (RX) : ORIGIN = 0x0000E000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x0000E400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x0000E410, LENGTH = 512k - 0xE410

/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00007000

boot config

/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0000B000

/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00007000

i wanted to jump from bootloader to application, but i am facing error like

No source available for "0xe478"

this is my code

#define APP_RESET_ADDRESS    0x0000E000

JumpToUserApplication(*((uint32_t*)APP_RESET_ADDRESS), *((uint32_t*)(APP_RESET_ADDRESS + 4)));  (Calling from main 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_RESET_ADDRESS;

/* Jump to application PC (r1) */
__asm("mov pc, r1");
}

Please help me to solve this issue. Thanks in Advance

0 件の賞賛
返信
8 返答(返信)

3,815件の閲覧回数
Ray_V
Contributor V

In your jump 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_RESET_ADDRESS;

  /* Jump to application PC (r1) */
  __asm("mov pc, r1");
}

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

When you enter the function the passed parameters are in r0 and r1 as you know. However once you execute some C code, such as:

 S32_SCB->VTOR = (uint32_t)APP_RESET_ADDRESS;

It is possible that the compiler used either or both r1 and r0 to execute that line.

Even the compare in the if statement could modify r0 or r1.

So you can't be sure that r1 still has the Reset Handler of your application. So you may not be jumping to your application.

You could reload the values from the stack, as they are also pushed to the stack when entering the function, or you could avoid executing those statements in the jump function.

You can instead execute these statements before calling the jump function:

if((*((uint32_t*)APP_RESET_ADDRESS)) != 0xFFFFFFFF){
  /* Relocate vector table */
  S32_SCB->VTOR = (uint32_t)APP_RESET_ADDRESS;
  JumpToUserApplication(*((uint32_t*)APP_RESET_ADDRESS), *((uint32_t*)(APP_RESET_ADDRESS + 4)));
}


void JumpToUserApplication( unsigned int userSP, unsigned int userStartup){
  /* Set up stack pointer */
  __asm("msr msp, r0");
  __asm("msr psp, r0");
  /* Jump to application PC (r1) */
  __asm("mov pc, r1");
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Alternatively you can load the values inside the Jump function instead of passing the values.

0 件の賞賛
返信

3,815件の閲覧回数
lakshmi_s
Contributor I

Hi 

I fallowed your suggestion even though the error is coming. i think some signal intterupt is coming so it is giving error like  

Program received signal SIGINT, Interrupt.
0x0000e478 in ?? ()

After debugging in debugger console view it showing error like No source available for the application project main() file.

How can i resolve this issue?

I attached debugger console window for better information.debugger_console_view.jpg

0 件の賞賛
返信

3,815件の閲覧回数
Ray_V
Contributor V

I also noticed in your entry from Feb 13, 2020 3:18 AM

You tried to issue the command 

file F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds/Debug/s32k144_asw_uds.elf

this command replaces all symbols instead of adding. I also noticed that you have some errors

Reading symbols from F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds/Debug/s32k144_asw_uds.elf...done.
Error in re-setting breakpoint 3: No source file named F:\\PROJECTS\\BMS_2020\\Code\\S32k144_UDS\\Sources\\main.c.
Error in re-setting breakpoint 4: No source file named F:\\PROJECTS\\BMS_2020\\Code\\S32k144_UDS\\Sources\\14229_uds\\iso14229_serv11.c

From this it seems that you compiled your project in one directory

F:\\PROJECTS\\BMS_2020\\Code\\S32k144_UDS

and then moved your project to a different directory

F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds

The information is saved with the complete path, so the debugger can't find the sources.

If you move your project you need to clean and re-compile so the debug source paths are correct

0 件の賞賛
返信

3,815件の閲覧回数
lakshmi_s
Contributor I

hello 

i tried by adding add-symbol-file "F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds/Debug/s32k144_asw_uds.elf" 0x0x0000E000

Now the error is solved ...it is also jumping to application but it is jumping some where else other than main()..

Can anyone tell that which address stack pointer and Program Counter holds if my application starts from 0xe000 address?

0 件の賞賛
返信

3,815件の閲覧回数
Ray_V
Contributor V

Lakshmi, main() does not start at 0xe000. The vector table starts there.

The first vector  (0xe000) contains the "initial stack pointer" and the second vector (0xe004) contains the address for the "ResetISR" vector. Look at the JumpToUserApplication() call.

The first vector is loaded to SP (msp and psp) and the second vector is loaded to PC register.

ResetISR will jump to main() after executing some initialization such as loading RAM regions, setting the CPU clock, configuring IO pins, etc.

You can look at the .map file (if you generate it) to see what the actual addresses of your ResetISR() and main() are.

0 件の賞賛
返信

3,815件の閲覧回数
Ray_V
Contributor V

The SIGINT is normal with some breakpoints, I don't think it is a problem.

About the "No Source Available" message, on the debugger console enter

add-symbol-file "F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds/Debug/s32k144_asw_uds.elf" 0x0x0000E000

After this is done you can single-step and it should refresh the debugger to show the code.

You can even issue the add-symbol-file before jumping to the program so it will show the source right away after jumping

0 件の賞賛
返信

3,815件の閲覧回数
raresvasile
NXP Employee
NXP Employee

Hi,

i wanted to jump from bootloader to application, but i am facing error like

No source available for "0xe478"

This error appears because gdb does not have the debug symbols for the application. A workaround can be done by adding a breakpoint to the entry of the application and by manually loading the debug symbols in gdb.

In S32DS, Debugger Console view, type file <path_to_app.elf> and after the next step the symbols will be loaded.

pastedImage_4.png

As far of the entry of the application: If you are running in thumb mode, then you must add 1 to the entry address to let the cpu know that the code is in Thumb.

/* Add 1 to the entry to respect Thumb requirements */
__asm("add r1, r1, #0x1");
/* Jump to application PC (r1) */
__asm("bx r1");
‍‍‍‍‍‍‍‍‍

Hope this helps.

Best regards,
Rares

0 件の賞賛
返信

3,815件の閲覧回数
lakshmi_s
Contributor I

Hi 

I tried your two suggestions by adding path and assembly command.

if i add this command _asm("add  r1, r1, 0x1"  in my  JumpToUserApplication function, i am getting error like "No source available for "main() at main.c:151 0xac2"

Also i got error when i try to add the path in debbuger console.

//////////////////////////////////////////////////////////

...................file F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds/Debug/s32k144_asw_uds.elf
A program is being debugged already.
Are you sure you want to change the file? (y or n) [answered Y; input not from terminal]
Load new symbol table from "F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds/Debug/s32k144_asw_uds.elf"? (y or n) [answered Y; input not from terminal]
Reading symbols from F:/PROJECTS/BMS_2020/Code/s32k144_asw_uds/Debug/s32k144_asw_uds.elf...done.
Error in re-setting breakpoint 3: No source file named F:\\PROJECTS\\BMS_2020\\Code\\S32k144_UDS\\Sources\\main.c.
Error in re-setting breakpoint 4: No source file named F:\\PROJECTS\\BMS_2020\\Code\\S32k144_UDS\\Sources\\14229_uds\\iso14229_serv11.c. ..................................

////////////////////////////////////////////////////////////////

HOWTO: Debug multiple elf files in S32 Design Studio with GDB   i fallowed these steps to debug my bootloader and application code both at a time.

 Can you please see and tell what is my mistake. 

0 件の賞賛
返信