Program execution

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16815
Level 1
Level 1
Hi

I have two different Programms in Program memory. One begins with the adress 0x8000000 and other one begins with the adress 0xA0080000.

the execution of the code begins with the adress 0x8000000 and the first program runs correctly.
After that i try to jump with a function pointer to the adress 0xA008000 to run the second program. But as expected the program has crashed.

the code seems like that:

void *ptr = (void *)0xA0080000;
goto *ptr;

(assemble code does the same)


Are there any idea how can solve this problem?
0 Likes
8 Replies
Darren_Galpin
Employee
Employee
First solution authored First like received
Segment 8 and A are the same memory - segment 8 is cached, segment A is non-cached. You have located both programs within PFlash0 (are we talking about Aurix2G here, or another family?).

My first question would be how large is your program image? As these programs are in the same memory, could one be over-writing part of the other?

Depending on what device you are on, you could try locating the second program higher in flash, making it less likely to be overwritten by the first.
0 Likes
User16815
Level 1
Level 1
TC3x7 is my hardware...
The placement is done with the LDF Model Editor from Hightec and there is no overwriting issue, because the the Model Editor makes the check for you.
With presence of the both code in memory(ROM ) you can run the program individually without a problem.

The Problem occurs when i try to make a switch from runnng Program to another.
0 Likes
Darren_Galpin
Employee
Employee
First solution authored First like received
ok 🙂 The addresses are both in PFlash0 rather than ROM.

When you say the program crashed, how did it crash? Was there are trap from the processor, if so, what one?
0 Likes
User16815
Level 1
Level 1
can you tell me how can i read trap messages?
0 Likes
cwunder
Employee
Employee
5 likes given 50 likes received 50 solutions authored
Please have a look to the iLLD example in the files IfxCpu_Trap.h and IfxCpu_Trap.c. It would be easiest to have code in the trap table to get the information.

/** \brief Structure to contain the trap information. **/
typedef struct
{
unsigned int tAddr;
unsigned int tId : 8;
unsigned int tClass : 8;
unsigned int tCpu : 3;
} IfxCpu_Trap;

IFX_INLINE IfxCpu_Trap IfxCpu_Trap_extractTrapInfo(uint8 trapClass, uint32 tin)
{
IfxCpu_Trap trapInfo;
trapInfo.tAddr = (unsigned int)__getA11();
trapInfo.tClass = trapClass;
trapInfo.tId = tin;
trapInfo.tCpu = IfxCpu_getCoreId();
return trapInfo;
}


Example for a bus error (class 4)
void IfxCpu_Trap_busError(uint32 tin){
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_bus, tin);
IFX_CFG_CPU_TRAP_BE_HOOK(trapWatch);
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
}
0 Likes
User16815
Level 1
Level 1
So the trap does not deliver any messages. But i tried to jump to the address program address back. What i mean is that the first program adress strarts from 0x8000 0000 . I tried to jump again to the adress 0x8000 0000.
The code is running but stays alwas in a while loop. It should behave like software reset ...Am i wrong?
the part for the jump function is below:

////////

void *ptr = (void *)0x80000000;


/////////////
if(test ==1 ){
test = 0;
unlock_wdtcon();
SYSTEM_DisableInterrupts();

goto *ptr;

}

To summarize, i tri to make a jump function, which jumps to another adress where anohter program is in presence and the this program should then run ...

i l be appreciated for any further helps....

the code can be found in the example code of hightec
LCDDemo_ApplicationKitTC387A-Step
0 Likes
cwunder
Employee
Employee
5 likes given 50 likes received 50 solutions authored
You are not providing enough information to know what the problem could be that you are experiencing (at least for me)?

Here is a bifaces code snippet for the TC38x A-Step device. One case is to jump to address 0x80000000 and the other is to perform a software reset. Both work on my TriBoard.
void (*ptr)(void);
volatile uint32 test;
volatile uint32 cnt;

IFX_ALIGN(4) IfxCpu_syncEvent cpuSyncEvent= 0;

void core0_main (void)
{
ptr = (void (*)(void))0x80000000;

IfxCpu_enableInterrupts();
/*
* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdog in the demo if it is required and also service the watchdog periodically
* */
IfxScuWdt_disableCpuWatchdog (IfxScuWdt_getCpuWatchdogPassword ());
IfxScuWdt_disableSafetyWatchdog (IfxScuWdt_getSafetyWatchdogPassword ());

/* Cpu sync event wait*/
IfxCpu_emitEvent(&cpuSyncEvent);
IfxCpu_waitEvent(&cpuSyncEvent, 1);
while (1)
{
/* jump to address pointed to by ptr */
if(1==test)
{
test = 0;
ptr();
}
/* perform a Software reset */
if(2==test)
{
test = 0;
IfxScuWdt_clearCpuEndinit(IfxScuWdt_getCpuWatchdogPassword ());
SCU_SWRSTCON.B.SWRSTREQ = 1;
IfxScuWdt_setCpuEndinit(IfxScuWdt_getCpuWatchdogPassword ());
}
cnt++;
}
}
0 Likes
User16815
Level 1
Level 1
Hi Again
After i changed the location of Program through linker script, the program was able to run. I located the program through LDF Editor. I saw also differents in .hex of Program in two cases.
And through replacement the code through LDF Editor and run directly; the code is working; but if you jump to this code from a running code, then the program is crashing.
But now i have another Problem, but i will do open new Thread for those.
Thank you all for your helps.
0 Likes