How to execute code from RAM on nRF51 using GCC Environment
How to execute code from RAM on nRF51 using GCC Environment
Hi Håkon,
Thanks a lot for your reply. I will implement this and let you know the status.
Regards, Anand
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 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: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 symbol
ble_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
Hi Håkon,
To give you a more information. Please find below versions of the software and hardware I am using.
Soft device :s110_nrf51822_7.0.0_softdevice SDK : 6.1 Hardware : N51822 QFACA1 1442AB (version 3.1 -32 KB RAM variant).
Can you suggest me which files and what changes are needed to come out of the above error.
Regards, Anand
Hi Anand,
It seems gcc is trying to place standard functions (memset) into RAM, which will not work. Try switching out the "memset" command with a for-loop or similar to set it to '0'. Is there a specific reason why you want to place this specific function "advertising_init" in RAM? Normally you run this function only once, then you're done with it. It makes more sense to place timing and power critical functions in RAM.
Hi Håkon,
I just put the adverise_init into RAM to test whether attribute((used, long_call, section(".data"))) command will work or not. Right now I am thinking about what are the functions i can run from the RAM. Do you have any document or can you share some information about what are the functions in general/softdevice calls i can move it to RAM, So that i can achieve the maximum power optimization.
Note: The reason i am trying to execute code from RAM instead of flash is to optimize the power. When i check the nRF51822 version 3.1 product specification doc , i found there is 1.7 mA current consumption difference between Flash and RAM code execution.
Regards, Anand