0

Hi everyone here is my issue.

I have two distincts projects, first has a linker file mapped as the following:

MEMORY
{
    rom (rx)  : ORIGIN = 0x08000000, LENGTH = 0x0000C400 
    ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}

Second a linker file as the following:

MEMORY
{
    rom (rx)  : ORIGIN = 0x0800C400, LENGTH = 0x00019CFC 
    ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}

Both of the projects runs on the same MCU and are burned in flash separatly. In my second project I would like to map pointers on functions declared in the first project. I tried the code below but it doesn't work, at execution debugger tels me that the symbol could not be found, but according to the .map file of the first project the address (0x0800458C) is mapped on the function I want to use.

uint32_t (*Myfunction)(void);

int main(void)
{
    Myfunction = ((uint32_t(*) (void)) 0x0800458C); // address in the first project
    Myfunction();
} 

Does anybody have experienced this ? Thanks !!

EDIT: It seems to work with Keil IDE when in directly include .symbols file in project. But with CoIDE (eclipse based) it doesn't work. I'm still trying to figure out this issue.

LOSnel
  • 161
  • 1
  • 1
  • 8
  • 3
    So where did you get the map file from? Why can't you call the function directly, assuming the map file and your `main()` are in the same project (which seems to make sense)? Confusing. – unwind May 19 '17 at 12:49
  • The map file comes from an other project that is in memory of my MCU. I'm building a second project that needs to use functions created in my first project. That's why I can't call the function directly. – LOSnel May 19 '17 at 12:54
  • 2
    If you're writing for a freestanding MCU implementation, then it seems to me that you would want to build your whole image as a unit, and to load the whole thing as a unit. I see a wide variety of problems that might arise from trying to load two separate images or trying to merge multiple images into one before loading them. – John Bollinger May 19 '17 at 14:32
  • Why not create a table which contains pointers to all functions, and then place that table in well defined address? That way you don't have to care where each function is, just read the address from the table. – user694733 May 22 '17 at 06:30
  • I'm not sure to see how to do it. Can you provide me an example ? – LOSnel May 22 '17 at 07:53

1 Answers1

0

Did you try this: Linker script: insert absolute address of the function to the generated code

I think the last answer might be what your looking for.

ncenerar
  • 1,517
  • 12
  • 25