Jumping from one image to another (5282).

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

Jumping from one image to another (5282).

2,766 Views
SVC1
Contributor I
Hi,
 
I have an image (BL) running in SRAM or Internal Flash from address (0 to 0x4000).

From this BL, I would like to jump to another application burned in
Internal Flash address 0x8000. Note that from 0x8000 to 0x8438, I have
the vector table as well as some data, so the actual code starts at 0x8438.

What are the steps (in assembly I presume) to achieve this?

I tried the following without success:

Code:
 uint32 APP_START = 0x8438; asm ( move.w        #0x2700,sr); // Disable interrupts asm ( MOVE.L   (APP_START), A0); asm ( jmp   (a0));

 
Thanks,
Simon

 
Labels (1)
0 Kudos
8 Replies

900 Views
SVC1
Contributor I
I tried
 
Code:
asm ( move.w   #0x2700,sr); // Disable interrupts asm ( MOVE.L   #0x8438, A0); asm ( jmp      (a0));  

 
Still does not work. I get exceptions continiously:
   Error on instruction fetch
   Access Error -- PC = 0x008438
 
which corresponds to:
 
Code:
void mcf_exception_handler(void *framepointer) {   volatile unsigned long  stackFrameVector   = (unsigned long)MCF5XXX_RD_SF_VECTOR(&stackFrameWord);   switch (stackFrameVector)   { case 3:        VECTORDISPLAY3(MCF5XXX_EXCEPTFMT, "Address Error", stackFramePC);        switch (stackFrameFS)        {           case 4:              VECTORDISPLAY("Error on instruction fetch\n");               break;                ... ... ...
               }
         ....
   }

 
Simon
0 Kudos

900 Views
SVC1
Contributor I
Actually, I can see that the first image (BL) is jumping to the right address and code. Nevertheless, the second I step through the first instruction, the exception is generated.
 
S
 
0 Kudos

900 Views
SimonMarsden_de
Contributor II
0 Kudos

900 Views
SVC1
Contributor I
I do have the protective words. Here is my vector table:
 
Code:
VECTOR_TABLE:_VECTOR_TABLE:INITSP:  .long ___SP_AFTER_RESET /* 0 (0x000) Initial SP */INITPC:  .long _start   /* 1 (0x004) Initial PC */// ... ... ...vectorFF: .long _asm_isr_handler /* 255  Reserved    */  //  CFM Flash Configuration Field KEY_UPPER:  .long   0xAAAAAAAA  // 4 bytesKEY_LOWER:  .long   0xBBBBBBBB // 4 bytesCFMPROT:    .int    0xCCCC  // 2 bytesCFMSACC:    .int    0xDDDD  // 2 bytesCFMDACC:    .int    0xEEEE  // 2 bytesCFMSEC:     .int    0xFFFF  // 2 bytes     // total 16 bytes = 0x10/********************************************************************/// HeaderHEAD_SIGNATURE: .long   0x12351236   // 4 bytesVERSION:  .long   _DEF_SW_VERSION // 4 bytesN_WORDS:     .long   0xAAAAAAAA  // 4 bytesCHECKSUM:  .long   0xBBBBBBBB  // 4 bytesSPARE1:      .int    0x1111   // 2 bytesSPARE2:      .int    0x2222   // 2 bytesSPARE3:      .int    0x3333   // 2 bytesSPARE4:      .int    0x5555   // 2 bytes      // total 24 bytes = 0x18/********************************************************************/_start: move.w #0x2700,SR jmp _startup .end

 
I also see with CW than after the jump, it really goes to "move #9984, sr" at address 0x8438 and yet the next step results in generating the exception continuously.
 
Besides, the destination image starts at address 0x8000 so we are way passed the CFM protected area.
 
Simon
 
 
0 Kudos

900 Views
SVC1
Contributor I
I got it working.
 
It was the values of CFMPROT, which wasn't set to 0.
 
Thanks,
Simon
 
 
 
0 Kudos

900 Views
jfint
Contributor I
You need to jump to the address after the vector table, I hve this setup in my .lcf file to be 0x400 ofter the image start.  you can view the correct target address with codewarrior by starting the run in flash emulator and looking at the PC registerr before hitting 'Go'

I hope I'm on track here

-josh
0 Kudos

900 Views
SimonMarsden_de
Contributor II
I think you're doing one memory read too many. You want to jump to 0x8438, not read the contents of 0x8438 and jump to whatever address you read from there. Try:

uint32 APP_START = 0x8438;
 asm ( move.w   #0x2700,sr); // Disable interrupts
 asm ( MOVE.L   #APP_START, A0);
 asm ( jmp      (a0));
Hope this helps


Simon
0 Kudos

900 Views
jfint
Contributor I
I do that very thing with this line:

((void(*)(void))(_B_ImageInitialPC_))();

where _B_ImageInitialPC_) is the address of the initial PC of the second image, after the vectors.

Depending on your context you might need to disable interrupts before making the jump.

-Josh
0 Kudos