Jumping to RAM instead of inside switch-case?

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

Jumping to RAM instead of inside switch-case?

535 Views
mathias_edman
Contributor III

Hi,

I am using development board and daughter board for MPC5777C together with S32 and default compiler/linker (powerpc-eabivle-4_9). It all worked great until today when I inserted the flash driver code (example driver code). For some reason the MCU is jumping to start address in RAM when executing a simple switch()-case c statement !?

I have never seen anything like this before and I am totally mesmerized about how this can even happen.

I base everything I did so far on the example that I could find in your example list (interrupts are disabled):

Example MPC5777C Single ELF multi-core Pin Toggling - S32DS Power v1.2

 Please see below picture:

MPC5777_jumping_to_ram.PNG

The lockedBlockSelection is here set to C55_BLOCK_LOW.

When we execute the instruction at 0x00811cba (se_bctr) we jump to RAM address 0x40000000 (r7 will hold this value at that point). If I remove the switch case and replace it with something else everything works.

registers are as below in the position shown in picture:

General Registers General Purpose and FPU Register Group
r0 0x811e38 (Hex)
r1 0x40001f68 (Hex)
r2 0x40008000 (Hex)
r3 0x0 (Hex)
r4 0x0 (Hex)
r5 0x40040000 (Hex)
r6 0x100bf (Hex)
r7 0x0 (Hex)
r8 0x0 (Hex)
r9 0x0 (Hex)
r10 0x0 (Hex)
r11 0x40001fe0 (Hex)
r12 0x0 (Hex)
r13 0x40008018 (Hex)
r14 0x0 (Hex)
r15 0x0 (Hex)
r16 0x0 (Hex)
r17 0x0 (Hex)
r18 0x0 (Hex)
r19 0x0 (Hex)
r20 0x0 (Hex)
r21 0x0 (Hex)
r22 0x0 (Hex)
r23 0x0 (Hex)
r24 0x0 (Hex)
r25 0x0 (Hex)
r26 0x0 (Hex)
r27 0x0 (Hex)
r28 0x0 (Hex)
r29 0x0 (Hex)
r30 0x0 (Hex)
r31 0x40001f68 (Hex)
pc 0x811c80 (Hex)
msr 0x2001000 (Hex)
cr 0x40000004 (Hex)
lr 0x811e38 (Hex)
ctr 0x0 (Hex)
xer 0x0 (Hex)

Anyone know power pc architecture better than me that could explain how this can happen? Any hints?

Regards,

Mathias

Tags (1)
0 Kudos
1 Reply

390 Views
mathias_edman
Contributor III

I think I know what the problem was.

It seems that there are some hard coded search paths inside the link script for this example. Since I had some code outside this folder some sections were never linked for this code. This might get me into trouble when executing switch case if lookup table is used I guess.

0 Kudos