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,

    As per your suggestion I have made changes for one of the function as below.

    attribute((used, long_call, section(".data"))) void advertising_init(void) { uint32_t err_code; st_device_status device_status;

    uint8_t       flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    static uint8_t device_status_value;
    //uint8_t      	flags = BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE;
    

    . . . .

    }

    But when I tried to build the project I found below error:

    D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:39:(.data+0x1c): relocation truncated to fit: R_ARM_THM_CALL against symbol device_info' defined in .text.device_info section in _build/nRF_Authentication.o D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:56:(.data+0x38): relocation truncated to fit: R_ARM_THM_CALL against symbolmemset' defined in .text.memset section in C:/Program Files/GNU Tools ARM Embedded/4.8 2013q4/arm-none-eabi/lib/armv6-m\libc.a(lib_a-memset.o) D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:73:(.data+0x8c): relocation truncated to fit: R_ARM_THM_CALL against symbol memset' defined in .text.memset section in C:/Program Files/GNU Tools ARM Embedded/4.8 2013q4/arm-none-eabi/lib/armv6-m\libc.a(lib_a-memset.o) D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:95:(.data+0xee): relocation truncated to fit: R_ARM_THM_CALL against symbolble_advdata_set' defined in .text.ble_advdata_set section in _build/ble_advdata.o D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:107:(.data+0x10a): relocation truncated to fit: R_ARM_THM_CALL against symbol `app_error_handler' defined in .text.app_error_handler section in _build/main.o collect2.exe: error: ld returned 1 exit status make: *** [_build/FITTING_BOARD_HWV1P0_SD7_FV15_s110_xxaa.out] Error 1

    Could you please let me know what is the issue.

    Regards, Anand

Reply
  • Hi Håkon,

    As per your suggestion I have made changes for one of the function as below.

    attribute((used, long_call, section(".data"))) void advertising_init(void) { uint32_t err_code; st_device_status device_status;

    uint8_t       flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    static uint8_t device_status_value;
    //uint8_t      	flags = BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE;
    

    . . . .

    }

    But when I tried to build the project I found below error:

    D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:39:(.data+0x1c): relocation truncated to fit: R_ARM_THM_CALL against symbol device_info' defined in .text.device_info section in _build/nRF_Authentication.o D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:56:(.data+0x38): relocation truncated to fit: R_ARM_THM_CALL against symbolmemset' defined in .text.memset section in C:/Program Files/GNU Tools ARM Embedded/4.8 2013q4/arm-none-eabi/lib/armv6-m\libc.a(lib_a-memset.o) D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:73:(.data+0x8c): relocation truncated to fit: R_ARM_THM_CALL against symbol memset' defined in .text.memset section in C:/Program Files/GNU Tools ARM Embedded/4.8 2013q4/arm-none-eabi/lib/armv6-m\libc.a(lib_a-memset.o) D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:95:(.data+0xee): relocation truncated to fit: R_ARM_THM_CALL against symbolble_advdata_set' defined in .text.ble_advdata_set section in _build/ble_advdata.o D:\Power_optimization_Working_code\Power_Optimization_FV_15_Working_Copy\Build/../nRF_Application/Source/nRF_Advertise.c:107:(.data+0x10a): relocation truncated to fit: R_ARM_THM_CALL against symbol `app_error_handler' defined in .text.app_error_handler section in _build/main.o collect2.exe: error: ld returned 1 exit status make: *** [_build/FITTING_BOARD_HWV1P0_SD7_FV15_s110_xxaa.out] Error 1

    Could you please let me know what is the issue.

    Regards, Anand

Children
No Data
Related