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 Håkon,

    function2() has variable assignments like saving data from local variable to global variable, and itos() and memcpy() function and also some function which are related to our application are called.

    I just did one simple experiment like below code which does not have any memcpy or memcpy.

    void toggle_GPIO(); int main(void) { toggle_GPIO(); }

    attribute((used, long_call, section(".data"))) void toggle_GPIO(void) { nrf_gpio_pin_set(NRF_GPIO0); nrf_gpio_pin_clear(NRF_GPIO0); }

    when I build it I got the error "d:..........Source/main.c:190:(.data+0xc): relocation truncated to fit: R_ARM_THM_CALL against `nrf_gpio_pin_clear".'

    Is the section(".data") is the proper section name we are putting. Do I need to give some other section name instead of ".data"? or do I need to change any thing in the gcc_startup_nrf51.s or Makefile.common or in linker files?

    could you please share your email id ? Regards, Anand

Reply
  • Hi Håkon,

    function2() has variable assignments like saving data from local variable to global variable, and itos() and memcpy() function and also some function which are related to our application are called.

    I just did one simple experiment like below code which does not have any memcpy or memcpy.

    void toggle_GPIO(); int main(void) { toggle_GPIO(); }

    attribute((used, long_call, section(".data"))) void toggle_GPIO(void) { nrf_gpio_pin_set(NRF_GPIO0); nrf_gpio_pin_clear(NRF_GPIO0); }

    when I build it I got the error "d:..........Source/main.c:190:(.data+0xc): relocation truncated to fit: R_ARM_THM_CALL against `nrf_gpio_pin_clear".'

    Is the section(".data") is the proper section name we are putting. Do I need to give some other section name instead of ".data"? or do I need to change any thing in the gcc_startup_nrf51.s or Makefile.common or in linker files?

    could you please share your email id ? Regards, Anand

Children
No Data
Related