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

cancel
Showing results for 
Search instead for 
Did you mean: 

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

638 Views
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 Replies

122 Views
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
}

122 Views
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 Kudos

122 Views
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

122 Views
hyenongijeong
Contributor III

Does anyone have any help?

I want to know the contents of __start ().

Regards,

Henk

0 Kudos

122 Views
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

0 Kudos

122 Views
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 Kudos

122 Views
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.

122 Views
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 Kudos