Is it possible to call a function from another image on MPC5674F?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Is it possible to call a function from another image on MPC5674F?

1,757 次查看
hyenongijeong
Contributor III

My question is explained below.

functionCall.png

1. Build the main image.

2. Download main image using JTAG.

3. Build the application image.

4. Download app image using RS232.

5. Run main image.

6. Call the func_a in the application image from the main().

Is it possible on this system?

Please let me know what to do if possible.

Thank you,

Regards,

Henk

8 回复数

1,241 次查看
marianoT
Contributor III

hi, the main image must know the entry point of application image, you can find this kind of jump in bootloaders or bootstaps like uboot. i think you can´t return to main image.

static void GoToJumpAddress(unsigned int jumpAddr, unsigned int matchType)
{
    typedef void(*fctType)(volatile unsigned int, volatile unsigned int);
    void(*pFct)(volatile unsigned int r0_val, volatile unsigned int r1_val);

    pFct = (fctType)jumpAddr;
    pFct(0/*dummy value in r0*/, matchType/*matchType in r1*/);

    while (1);//never reach
}

1,241 次查看
hyenongijeong
Contributor III
Hi,
It will load and run the image from the boot loader. 
That's not what I want. I just call the function and then return to the original image.
It is okay to call a function and also I confirmed returning main().
The simple operation function is executed, but it is killed when it tries to process the string.
This means that the '.data' area is not loaded.I am looking for a way to load the image's data, sdata, bss, etc. into RAM.
I think it includes __start(). 
regards,
Henk
0 项奖励

1,241 次查看
biswanath_bhowmick
NXP Employee
NXP Employee

Hi,

In my case, I had divided the RAM area between the images. Main image start executing after reset, it invokes its startup() routine to initialize its data, sdata, bss, etc. into RAM(main partition). The main program calls application's init_app() (using function pointer loading this init_app() function location from a fixed flash location) which in tern invokes the it's startup() to initialize application image's data, sdata, bss, etc. into RAM(application partition). So, this init_app() is called only once by the main program.

Once this is done, main image is able to call application image APIs and return as and when required. I used function pointers to call application APIs from the main and vice versa.

Regards,

Biswanath

1,241 次查看
hyenongijeong
Contributor III

Does anyone have any help?

I want to know the contents of __start ().

Regards,

Henk

1,241 次查看
biswanath_bhowmick
NXP Employee
NXP Employee

Hi,

You can refer the start() routine available even in your main image/bootloader. Without this(i.e., its data sections initialized), even the main image/bootloader wouldn't have worked. You can probably build the same/similar start() routine into application image also and once the application entry point is invoked, that should simply call its start(). Note in this case, only the data sections of the application image will be initialized(as this is completely separate program than the boot loader).

Hope this helps.

Regards,

Biswanath

1,241 次查看
hyenongijeong
Contributor III

Hi,

That's what I want to do now.

How do I make init_app()?

How do I copy .data and .bss from FLASH to RAM?

Regards,

Henk

0 项奖励

1,241 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, I don’t think it would be possible to simply perform function calling from main image.

 

In the application image, you would have define start point located at exact address (i.e. _start) being branched from main image.

 

I suppose from your description you have 2 independently compiled binaries.

1,241 次查看
hyenongijeong
Contributor III
Hi,
It will load and run the image from the boot loader. 
That's not what I want. I just call the function and then return to the original image.
It is okay to call a function and also I confirmed returning main().
The simple operation function is executed, but it is killed when it tries to process the string.
This means that the '.data' area is not loaded.I am looking for a way to load the image's data, sdata, bss, etc. into RAM.
I think it includes __start(). 
Can I receive __start.asm ?
regards,
Henk
0 项奖励