This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PRU-C-Compiler, symbol at wrong address?

Genius 5820 points

Hi,

I'm using TI's C-compiler to create some PRU-code. My first test application consisted of the main-function only and worked well with PRU starting at address 0x0000.

Now I added a function which is called out of main() and the whole thing is damaged. What I found from MAP-file this new function sendFrame() was placed at address 0x0000:

 output                                  attributes/
section   page    origin      length       input sections
--------  ----  ----------  ----------   ----------------
.text      0    00000000    00000450     
                  00000000    000001f4     main.obj (.text:sendFrame$0)
                  000001f4    000001a4     main.obj (.text:main)

So when PRU starts at address 0x0000 it of course will fail since execution is started somewhere in between.

So my question: Is there an option to tell the compiler to always place main() at address 0x00000000?

  • qxc said:
    So when PRU starts at address 0x0000

    Why do you think execution begins at address 0?

    I presume that when you build you create a linker map file by using the option --map_file=filename (or -m for short).  This file usually has the extension .map.  For the build which works, look in the map file to see a line similar to this ...

    ENTRY POINT SYMBOL: "_c_int00_noinit_noargs_noexit"  address: 00000038
    

    This indicates where execution begins.  It does not begin at the function main.  For this specific example, execution begins with a function named _c_int00_noinit_no_args_noexit at address 0x38.  This function sets up the stack, initializes global variables, etc. then calls main.

    The important point is: The function main does not need to be at address 0.

    Thanks and regards,

    -George

  • George Mock said:
    Why do you think execution begins at address 0?

    OK, good pint, this was just a fond assumption...

    George Mock said:
    execution begins with a function named _c_int00_noinit_no_args_noexit at address 0x38.

    So is there a possibility to force/lock this function to a specific address? This would avoid bugs because one can't forget to change the start address in PRU initialisation after changing something in PRU code.

  • There is a convention that some loaders use that the PRU entrypoint is 0. If the loader can load an ELF executable, then it should use the entry point field to identify where program execution starts. However, if you're loading a binary image then there is no entrypoint symbol to query. Starting at address 0 is as good as any. The easiest way to make this happen is to include this line in your linker command file's SECTION specification:

    .text:_c_int00* >  0x0, PAGE 0