This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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 execute code from RAM on nRF51 using GCC Environment

How to execute code from RAM on nRF51 using GCC Environment

Parents
  • Hi,

    You can place a function in RAM in GCC like this:

    __attribute__((used, long_call, section(".data"))) void some_func(void)
    {
      do_something();
    }
    

    Then you should check the .map file to see that it's located somewhere in RAM (0x2000XYZZ)

    Cheers, Håkon

  • Hi Anand,

    You're seeing a conflict between the function you state to be placed in RAM, where it calls functions that have been placed in .text (flash) and therefore the linker throws an error back. In order to link the application properly, you will have to make sure that all functions called within the function that you have placed in RAM, also are located in RAM. If not, only partial segments of the call tree is present in RAM, thus invoking a higher current consumption. I would recommend that you look into the gcc linker scripts and create proper RAM-segments, or manually trace the call tree of your function and place the sub-functions into RAM using attribute. However; What I have to ask is which functions do you need to place in RAM? Normally you want time-consuming functions to be placed in RAM, for instance flash-writing operations, or interrupt functions.

    Cheers, Håkon

Reply
  • Hi Anand,

    You're seeing a conflict between the function you state to be placed in RAM, where it calls functions that have been placed in .text (flash) and therefore the linker throws an error back. In order to link the application properly, you will have to make sure that all functions called within the function that you have placed in RAM, also are located in RAM. If not, only partial segments of the call tree is present in RAM, thus invoking a higher current consumption. I would recommend that you look into the gcc linker scripts and create proper RAM-segments, or manually trace the call tree of your function and place the sub-functions into RAM using attribute. However; What I have to ask is which functions do you need to place in RAM? Normally you want time-consuming functions to be placed in RAM, for instance flash-writing operations, or interrupt functions.

    Cheers, Håkon

Children
No Data
Related