jump to new application code

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

jump to new application code

906 Views
mehdikarimibiuk
Contributor V

I have a new application and I have created a new srec file based on the linker below:

MEMORY {

  m_interrupts (RX) : ORIGIN = 0x00040000, LENGTH = 0x000001E0

  m_text       (RX) : ORIGIN = 0x00040410, LENGTH = 0x00019410

  m_data       (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000

  m_factory_param (R) : ORIGIN = 0x0007C000, LENGTH = 0x00000400

  m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000

  m_cfmprotrom   (RX) : ORIGIN = 0x00040400, LENGTH = 0x00000010

}

 

I believe that I have to jump to the start address of the vector table which is 0x40000 here.

 

My jump function is looking like this:

 

void switch_mode(UINT32 IMAGE_ADDR)

{

 

  static uint_32 New_sp,New_pc; /* stack pointer and program counter */

  volatile uint_32 temp = 1; /* default the button is not pressed */

 

  /* Get PC and SP of application region */

  New_sp = ((uint_32 *) IMAGE_ADDR)[0];

  New_pc = ((uint_32 *) IMAGE_ADDR)[1];

 

  if (temp) {

  if ((New_sp != 0xffffffff) && (New_pc != 0xffffffff)) {

    /* Run the application */

  asm {

  ldr r4,=New_sp

  ldr sp, [r4]

  ldr r4,=New_pc

  ldr r5, [r4]

  blx r5

  }

  } /* EndIf */

  }

} /* EndBody */

 

 

But when I use this function by calling it and pass-in the starting address of my application (0x40000), it resets my core and starts my old application (which is at address zero).

I pass in switch_mode(0x00040000)

 

Can you tell me if my function is correct? and if so, why it is not jumping to the start of my new application and instead it is jumping back to the start of my old application which is located at address zero. How can this be possible?

 

Thanks

 

Ps. BTW, and FYI, My chip is MK60DN512VLL10, and I am using CodeWarrior 10.5 - bare board with Processor expert.

Labels (1)
0 Kudos
Reply
2 Replies

684 Views
travis_l
Contributor III

Hi Mehdi,

In your application (not the bootloader) are you sure you have set the vector table to be in RAM and set the proper address for it.  Also are you copying your applications vectors to that location in ram when it starts up?

0 Kudos
Reply

684 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi!

I cannot build your code. Can you attach a simple project?

Carlos

0 Kudos
Reply