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

how to set fixed address for variables/functions  at compiling stage in ADS?

Note: This was originally posted on 18th September 2009 at http://forums.arm.com

in ads 1.2, I set fixed address for a variable like this:

int    file_len  __attribute__((_at_(0x16000))) = 0;  

but compile error, how can i do?

thank you very much!
  • Note: This was originally posted on 18th September 2009 at http://forums.arm.com

    You can use this but you have to set the initial value manually...

    #define file_len   (*(int *)(0x00016000))


    -----ohh,thanks.
    But in my program, I need "file_len" located at 0x00016000 and occupy 4bytes memory,
    how can I do?

    best regards,
  • Note: This was originally posted on 18th September 2009 at http://forums.arm.com

    You can do this directly using linker tricks, but it's not really designed for placement of individual variables.

    If you really need this, I'd suggested storing a pointer to the location rather than the value itself:

    static int * const pFileLen = (int *)(0x00016000);

    /* Store value. */
    *pFileLen = uiMyValue;

    /* Get value. */
    uiMyValue = *pFileLen;
  • Note: This was originally posted on 13th November 2009 at http://forums.arm.com

    Can Any body tell me how to place a function at specified location in RVDS? __at__ has got limitations. I don't want to change my linker file hence i am looking for trick or hack in code.
  • Note: This was originally posted on 18th September 2009 at http://forums.arm.com

    in ads 1.2, I set fixed address for a variable like this:

    int    file_len  __attribute__((_at_(0x16000))) = 0;  

    but compile error, how can i do?

    thank you very much!


    You can use this but you have to set the initial value manually...

    #define file_len   (*(int *)(0x00016000))

    On second thought, this address is most likely in the on-chip NV (flash) memory region...
    So , you can NOT have a variable at this particular address. Maybe the compiler was
    trying to tell you this simple fact :-) What error does compiler give you anyway ?