This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Linker Error :: while upgrading the sdk version to 13

HI All,

I am trying to upgrade sdk v11 to sdk v13 in my  project and after compilation i am facing Linker Error as mentioned below.

binaries/app/SmartTag2/dfuFlash.c.o:/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../components/nordic/softdevice/s132/headers/ble_gap.h:2157: multiple definition of `m_fs'
binaries/app/SmartTag2/fds.c.o:(.fs_data+0x0): first defined here
binaries/app/SmartTag2/bleDrv.c.o:(.sdh_ble_observers1+0x8): undefined reference to `ble_db_discovery_on_ble_evt'
binaries/app/SmartTag2/bleDrv.c.o: In function `client_init':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../source/peripherals/bluetooth/bleDrv.c:2458: undefined reference to `ble_db_discovery_init'
binaries/app/SmartTag2/bleDrv.c.o: In function `on_ble_gap_evt_connected':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../source/peripherals/bluetooth/bleDrv.c:2542: undefined reference to `ble_db_discovery_start'
binaries/app/SmartTag2/amtc.c.o: In function `nrf_ble_amtc_init':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../source/peripherals/bluetooth/amtc.c:289: undefined reference to `ble_db_discovery_evt_register'
binaries/app/SmartTag2/ble_dfu.c.o: In function `ble_dfu_buttonless_bootloader_start_finalize':
/home/dcpl/Videos/Tack_Test_31_May/ToolChainSetup/coolR/build/linux/../../components/nordic/ble/ble_services/ble_dfu/ble_dfu.c:295: undefined reference to `nrf_pwr_mgmt_shutdown'
collect2: error: ld returned 1 exit status
../../components/nordic/toolchain/gcc/Makefile.common:292: recipe for target 'binaries/app/SmartTag2.out' failed
make: *** [binaries/app/SmartTag2.out] Error 1

also i am attaching my linker script.

please help me to resolved this error.

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
	/* Flash partitions */
/*	MBR				(rx)	:   ORIGIN = 0x00000000, LENGTH = 0x01000		/* Master Boot Record, size = 4KB  */
/*	SOFTDEVICE		(rx)	:   ORIGIN = 0x00001000, LENGTH = 0x1E000		/* Softdevice, size = 120KB */
	APPLICATION		(rx)	:	ORIGIN = 0x0001F000, LENGTH = 0x45000		/* Application, size = 340KB */
/*	BOOTLOADER		(rx)	:   ORIGIN = 0x00074000, LENGTH = 0x06000		/* Bootloader, size = 24KB */
/*	MBR_SETTING		(rw)	:   ORIGIN = 0x0007A000, LENGTH = 0x01000		/* MBR setting, size = 4KB */
	BL_SETTING		(rw)	:   ORIGIN = 0x0007B000, LENGTH = 0x01000		/* BL setting, size = 4KB */
	NVCONFIG		(rw)	:	ORIGIN = 0x0007C000, LENGTH = 0x04000		/* NVconfig, size = 16KB */
	

	/* RAM partitions */
/*	MBR_SD			(rw)	:	ORIGIN = 0x20000000, LENGTH = 0x2128		/* */
	RAM 			(rwx)	:	ORIGIN = 0x20002128, LENGTH = 0xAED8		/* */
	DM_RAM_BUFFER	(rwx)	:	ORIGIN = 0x2000D000, LENGTH = 0x1000		/* */	
	CONFIG 			(rwx) 	:	ORIGIN = 0x2000E000, LENGTH = 0x2000        /* */
}
/*
SECTIONS
{
	.config :
	{
		PROVIDE(__start_config = .);
	    KEEP(*(.config))
    	PROVIDE(__stop_config = .);
	} > CONFIG
}
*/
SECTIONS
{
  .config(NOLOAD) :
  {

  } > CONFIG
}

SECTIONS
{
  .dmRamBuffer(NOLOAD) :
  {

  } > DM_RAM_BUFFER
}

SECTIONS
{
   /* Place the bootloader settings page in flash. */
  .bootloaderSettings(NOLOAD) :
  {
	
  } > BL_SETTING
  .cli_sorted_cmd_ptrs :
  {
    PROVIDE(__start_cli_sorted_cmd_ptrs = .);
    KEEP(*(.cli_sorted_cmd_ptrs))
    PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
  } > RAM
  .log_dynamic_data :
  {
    PROVIDE(__start_log_dynamic_data = .);
    KEEP(*(SORT(.log_dynamic_data*)))
    PROVIDE(__stop_log_dynamic_data = .);
  } > RAM
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } > RAM
} INSERT AFTER .data;

SECTIONS
{
  .mem_section_dummy_rom :
  {
  }
  .sdh_soc_observers :
  {
    PROVIDE(__start_sdh_soc_observers = .);
    KEEP(*(SORT(.sdh_soc_observers*)))
    PROVIDE(__stop_sdh_soc_observers = .);
  } > APPLICATION
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } > APPLICATION
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } > APPLICATION
    .cli_command :
  {
    PROVIDE(__start_cli_command = .);
    KEEP(*(.cli_command))
    PROVIDE(__stop_cli_command = .);
  } > APPLICATION
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_data = .);
  } > APPLICATION
  .sdh_req_observers :
  {
    PROVIDE(__start_sdh_req_observers = .);
    KEEP(*(SORT(.sdh_req_observers*)))
    PROVIDE(__stop_sdh_req_observers = .);
  } > APPLICATION
  .sdh_state_observers :
  {
    PROVIDE(__start_sdh_state_observers = .);
    KEEP(*(SORT(.sdh_state_observers*)))
    PROVIDE(__stop_sdh_state_observers = .);
  } > APPLICATION
  .sdh_stack_observers :
  {
    PROVIDE(__start_sdh_stack_observers = .);
    KEEP(*(SORT(.sdh_stack_observers*)))
    PROVIDE(__stop_sdh_stack_observers = .);
  } > APPLICATION


} INSERT AFTER .text

INCLUDE "nrf52_common.ld"

  • Hi,

    The "undefined reference" errors are typically either because the .c files where they are implemented has not been compiled, or that the specific part of the file has been stripped out by the preprocessor. For instance, ble_db_discovery_evt_register is implemented in ble_db_discovery.c, but will the preprocessor will not include it unless BLE_DB_DISCOVERY_ENABLED is defined (in the projects sdk_config.h).

    I don't know why you got the "multiple definition" error for m_fsm. It only exists one place in SDK 13, in fsm.c, and I do not make sense of the line number in ble_gap.h:2157. Have you kept parts of SDK 11 as well (since this does not seem to match SDK 13)?

  • Hi,

    As you mention in upper para, i know this is implemented only one place.

    I am completely remove sdk11 and import all file from sdk13. When i compile i get some warning, not a single error. 

    I dont know why i am getting this error in linker as mention. Please suggest me what i can do to remove this. 

  • It is difficult to say exactly what causes this without having and building your code. I think it makes sense to start with the first error and try to eliminate them one by one. The "undefined reference" is most probably due to missing defines in your projects sdk_config.h, as I suggested in the previous post. The "multiple definition" error for m_fsm could be caused by including the .c file by a mistake (where you should have included the corresponding .h file). Or it could be something else.

  • Ok, i can try.

    Give me some tips where to start. to resolved the 1st error.

  • Sounds good.

    There are basically two types of linker errors in your log, as we have already discussed:

    • the "multiple definition" error, and
    • the "undefined reference".

    I have made some suggestions for both errors. But to make it clearer for the "undefined reference", you should check a few things

    1. Ensure that you actually build the .c file which has the reference which is undefined.
    2. If you include the file and it still does not work, then probably it is removed by the preprocessor.

    I can elaborate on the second point, as the sdk_config.h concept can be a bit confusing when you are not used to it. Try looking at the file, and you should will typically see a #ifdef or #if NRF_MODULE_ENABLED(...). For the "undefined reference to `ble_db_discovery_on_ble_evt'" error, you can see that in the top of ble_db_discovery.c there is a #if NRF_MODULE_ENABLED(BLE_DB_DISCOVERY). This means that everything until the matching #endif will be removed by the preprocessor if not BLE_DB_DISCOVERY_ENABLED is set to 1 in the projects sdk_config.h. So, the fix is probably to set BLE_DB_DISCOVERY_ENABLED in your projects sdk_config.h.

    I am sure you will root out the errors once you start handling them one by one. Good luck!

Related