This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Jump to function at absolute address

Hi,

In my project I have some functions that has to be protected against changes. For that reason a checksum has to be calculated on that specific code in runtime, just to prove that the actual code is intact.

Those specific functions are built in an own outside project (just to protect it from changes) and downloaded to a dedicated area in the flash.

When the standard code wants to access this functionality in the "outside code" an absolute jump is made to the start address of this outside function (0x50000).

This seems to go right, in the "outside code" I can set some outputs to light some LEDs, so the jump seems to have gone right.

But when I try to use variables in this "outside code" nothing seems to work, I tried to make a while loop to blink a diode and counted a variable down to zero, but the variables seems corrupt.

What can be the problem? Can it be something with the memory model that makes references to variables corrupt? I don't know, I'm not so good at memory models.

Any Idea, some one ?

Regards / Rasmus

Parents
  • I'm don't think I am following you entirely so this may be nonsense.

    It is fairly common to have code from two projects loaded and running sequentially on same target (boot then application). This is fairly simple because you can run their own startup code and can share data memory, etc.

    Running code from two projects simulataneously sounds much more difficult and problematic to me.

    Have you considered making the part of your application that cannot change a library? You can include it in your main project and call the functions directly. You don't have to fool around with merging hex files and shouldn't have to deal with problems you are seeing (which sounds like a memory overlap or addressing problem). Just make sure the library is built with the same memory model as the main application.

    The library will never change unless you purposly rebuild it. You can also use linker commands to locate it where you like if necessary.

Reply
  • I'm don't think I am following you entirely so this may be nonsense.

    It is fairly common to have code from two projects loaded and running sequentially on same target (boot then application). This is fairly simple because you can run their own startup code and can share data memory, etc.

    Running code from two projects simulataneously sounds much more difficult and problematic to me.

    Have you considered making the part of your application that cannot change a library? You can include it in your main project and call the functions directly. You don't have to fool around with merging hex files and shouldn't have to deal with problems you are seeing (which sounds like a memory overlap or addressing problem). Just make sure the library is built with the same memory model as the main application.

    The library will never change unless you purposly rebuild it. You can also use linker commands to locate it where you like if necessary.

Children