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

"Undefined Reference" on the linker level

Hi. I am a beginner with nrf52832. Trying to get Bluetooth and UART and a I2C peripheral working at the same time. I had a working version of the I2C peripheral and UART working together and tried to merge Bluetooth in, referencing the ble_app_uart example provided in nRF5_SDK_12.3.0. Currently when I try to do make flash I do not get any compiling errors, but I am getting linker errors that say that I have "undefined reference":

Linking target: _build/nrf52832_xxaa.out
_build/nrf52832_xxaa_twi.c.o: In function `twi_master_init':
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./twi.c:43: undefined reference to `nrf_drv_twi_init'
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./twi.c:46: undefined reference to `nrf_drv_twi_enable'
_build/nrf52832_xxaa_lis3dh.c.o: In function `lis3dh_read_data':
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./lis3dh.c:171: undefined reference to `nrf_drv_twi_tx'
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./lis3dh.c:180: undefined reference to `nrf_drv_twi_rx'
_build/nrf52832_xxaa_lis3dh.c.o: In function `lis3dh_init':
/home/yilunsheng/src/accelerometer, SDK12.3, app_uart_merge/./lis3dh.c:232: undefined reference to `nrf_drv_twi_tx'
collect2: error: ld returned 1 exit status
../nRF5_SDK_12.3.0/components/toolchain/gcc/Makefile.common:153: recipe for target '_build/nrf52832_xxaa.out' failed
make: *** [_build/nrf52832_xxaa.out] Error 1

Very confused about where the problem is.

  • http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.3.0%2Fsdk_config.html&cp=4_0_7_1_6 states:

    "All examples contain a full configuration header file in which only the used modules are enabled." (emphasis mine)

    With all due respect, this statement is untrue. 

    I just wrote a short program which simply counts the lines in each sdk_config.h file in SDK 12.3 which is designated for the PCA10040 board (the ones we use).  Here is the output.

    dtm/direct_test_mode/pca10040/blank/config/sdk_config.h: 135
    dtm/direct_test_mode/pca10040/s332/config/sdk_config.h: 135
    dtm/direct_test_mode/pca10040/s132/config/sdk_config.h: 135
    dtm/dtm_serialization/pca10040/ser_s132_spi/config/sdk_config.h: 915
    dtm/dtm_serialization/pca10040/ser_s132_uart/config/sdk_config.h: 746
    dtm/dtm_serialization/pca10040/ser_s132_hci/config/sdk_config.h: 753
    dtm/dtm_serialization/pca10040/ser_s132_spi_5W/config/sdk_config.h: 753
    ble_peripheral/ble_app_beacon/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_keyboard/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_keyboard/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_keyboard/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_keyboard/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_bms/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hrs_freertos/pca10040/s132/config/sdk_config.h: 3811
    ble_peripheral/ble_app_gls/pca10040/ser_s132_spi/config/sdk_config.h: 3804
    ble_peripheral/ble_app_gls/pca10040/s132/config/sdk_config.h: 3804
    ble_peripheral/ble_app_gls/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/ble_app_gls/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/ble_app_cts_c/pca10040/ser_s132_spi/config/sdk_config.h: 3804
    ble_peripheral/ble_app_cts_c/pca10040/s132/config/sdk_config.h: 3804
    ble_peripheral/ble_app_cts_c/pca10040/ser_s132_uart/config/sdk_config.h: 3804
    ble_peripheral/ble_app_cts_c/pca10040/ser_s132_hci/config/sdk_config.h: 3804
    ble_peripheral/ble_app_cscs/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/ble_app_cscs/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_cscs/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/ble_app_cscs/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/ble_app_alert_notification/pca10040/ser_s132_spi/config/sdk_config.h: 3804
    ble_peripheral/ble_app_alert_notification/pca10040/s132/config/sdk_config.h: 3804
    ble_peripheral/ble_app_alert_notification/pca10040/ser_s132_uart/config/sdk_config.h: 3804
    ble_peripheral/ble_app_alert_notification/pca10040/ser_s132_hci/config/sdk_config.h: 3804
    ble_peripheral/ble_app_uart/pca10040/s132/config/sdk_config.h: 3811
    ble_peripheral/ble_app_bps/pca10040/ser_s132_spi/config/sdk_config.h: 3804
    ble_peripheral/ble_app_bps/pca10040/s132/config/sdk_config.h: 3804
    ble_peripheral/ble_app_bps/pca10040/ser_s132_uart/config/sdk_config.h: 3804
    ble_peripheral/ble_app_bps/pca10040/ser_s132_hci/config/sdk_config.h: 3804
    ble_peripheral/ble_app_eddystone/pca10040/s132/config/sdk_config.h: 3804
    ble_peripheral/ble_app_rscs/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/ble_app_rscs/pca10040/s332/config/sdk_config.h: 3797
    ble_peripheral/ble_app_rscs/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_rscs/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/ble_app_rscs/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hrs/pca10040/ser_s132_spi/config/sdk_config.h: 3827
    ble_peripheral/ble_app_hrs/pca10040/s332/config/sdk_config.h: 3827
    ble_peripheral/ble_app_hrs/pca10040/s132/config/sdk_config.h: 3837
    ble_peripheral/ble_app_hrs/pca10040/ser_s132_uart/config/sdk_config.h: 3827
    ble_peripheral/ble_app_hrs/pca10040/ser_s132_hci/config/sdk_config.h: 3827
    ble_peripheral/ble_app_hrs/pca10040/ser_s132_spi_5W/config/sdk_config.h: 3827
    ble_peripheral/experimental_ble_app_hids_keyboard_pairing_nfc/pca10040/s132/config/sdk_config.h: 3937
    ble_peripheral/experimental_ble_app_buttonless_dfu/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_mouse/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_mouse/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_mouse/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hids_mouse/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_hrs_pairing_nfc/pca10040/s132/config/sdk_config.h: 3951
    ble_peripheral/experimental_ble_app_blinky/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_blinky/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_blinky/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_blinky/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/ble_app_proximity/pca10040/s132/config/sdk_config.h: 3811
    ble_peripheral/experimental_ble_app_cgms/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hts/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hts/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hts/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/ble_app_hts/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/ble_app_ancs_c/pca10040/ser_s132_spi/config/sdk_config.h: 3811
    ble_peripheral/ble_app_ancs_c/pca10040/s132/config/sdk_config.h: 3811
    ble_peripheral/ble_app_ancs_c/pca10040/ser_s132_uart/config/sdk_config.h: 3804
    ble_peripheral/ble_app_ancs_c/pca10040/ser_s132_hci/config/sdk_config.h: 3804
    ble_peripheral/ble_app_template/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_lns/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_lns/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_lns/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_lns/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_peripheral/experimental_bluetoothds_template/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/experimental_ble_app_queued_writes/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_pwr_profiling/pca10040/ser_s132_spi/config/sdk_config.h: 3797
    ble_peripheral/ble_app_pwr_profiling/pca10040/s132/config/sdk_config.h: 3797
    ble_peripheral/ble_app_pwr_profiling/pca10040/ser_s132_uart/config/sdk_config.h: 3797
    ble_peripheral/ble_app_pwr_profiling/pca10040/ser_s132_hci/config/sdk_config.h: 3797
    ble_central/ble_app_uart_c/pca10040/ser_s132_spi/config/sdk_config.h: 3818
    ble_central/ble_app_uart_c/pca10040/s132/config/sdk_config.h: 3818
    ble_central/ble_app_multilink_central/pca10040/s132/config/sdk_config.h: 3804
    ble_central/experimental/ble_app_blinky_c/pca10040/s132/config/sdk_config.h: 3804
    ble_central/experimental/ble_app_rscs_c/pca10040/ser_s132_spi/config/sdk_config.h: 3804
    ble_central/experimental/ble_app_rscs_c/pca10040/s132/config/sdk_config.h: 3804
    ble_central/ble_app_hrs_c/pca10040/ser_s132_spi/config/sdk_config.h: 3834
    ble_central/ble_app_hrs_c/pca10040/s132/config/sdk_config.h: 3844
    nfc/experimental_writable_ndef_msg/pca10040/blank/config/sdk_config.h: 754
    nfc/wake_on_nfc/pca10040/blank/config/sdk_config.h: 699
    nfc/record_text/pca10040/blank/config/sdk_config.h: 753
    nfc/record_launch_app/pca10040/blank/config/sdk_config.h: 753
    nfc/adafruit_tag_reader/pca10040/blank/config/sdk_config.h: 1250
    nfc/record_url/pca10040/blank/config/sdk_config.h: 753
    peripheral/rng/pca10040/blank/config/sdk_config.h: 3797
    peripheral/rng/pca10040/s132/config/sdk_config.h: 3797
    peripheral/uart/pca10040/blank/config/sdk_config.h: 516
    peripheral/pwr_mgmt/pca10040/blank/config/sdk_config.h: 848
    peripheral/csense_drv/pca10040/blank/config/sdk_config.h: 992
    peripheral/blinky/pca10040/blank/config/sdk_config.h: 3797
    peripheral/blinky/pca10040/s132/config/sdk_config.h: 3797
    peripheral/temperature/pca10040/blank/config/sdk_config.h: 479
    peripheral/rtc/pca10040/blank/config/sdk_config.h: 695
    peripheral/preflash/pca10040/blank/config/sdk_config.h: 853
    peripheral/wdt/pca10040/blank/config/sdk_config.h: 796
    peripheral/csense/pca10040/blank/config/sdk_config.h: 1064
    peripheral/twi_master_with_twis_slave/pca10040/blank/config/sdk_config.h: 909
    peripheral/radio/transmitter/pca10040/blank/config/sdk_config.h: 633
    peripheral/radio/receiver/pca10040/blank/config/sdk_config.h: 626
    peripheral/uicr_config/pca10040/blank/config/sdk_config.h: 122
    peripheral/saadc/pca10040/blank/config/sdk_config.h: 1007
    peripheral/qdec/pca10040/blank/config/sdk_config.h: 721
    peripheral/spi/pca10040/blank/config/sdk_config.h: 821
    peripheral/pwm_library/pca10040/blank/config/sdk_config.h: 789
    peripheral/blinky_systick/pca10040/blank/config/sdk_config.h: 135
    peripheral/fpu_fft/pca10040/blank/config/sdk_config.h: 479
    peripheral/fpu_fft/pca10040/s132/config/sdk_config.h: 608
    peripheral/fpu_fft/pca10040/blank_irq/config/sdk_config.h: 479
    peripheral/fpu_fft/pca10040/s132_irq/config/sdk_config.h: 608
    peripheral/blinky_freertos/pca10040/blank/config/sdk_config.h: 699
    peripheral/ppi/pca10040/blank/config/sdk_config.h: 692
    peripheral/twi_master_using_app_twi/pca10040/blank/config/sdk_config.h: 960
    peripheral/i2s/pca10040/blank/config/sdk_config.h: 700
    peripheral/pwm_driver/pca10040/blank/config/sdk_config.h: 876
    peripheral/gpiote/pca10040/blank/config/sdk_config.h: 776
    peripheral/simple_timer/pca10040/blank/config/sdk_config.h: 791
    peripheral/spis/pca10040/blank/config/sdk_config.h: 793
    peripheral/twi_scanner/pca10040/blank/config/sdk_config.h: 614
    peripheral/template_project/pca10040/blank/config/sdk_config.h: 3367
    peripheral/radio_test/pca10040/blank/config/sdk_config.h: 516
    peripheral/led_softblink/pca10040/blank/config/sdk_config.h: 622
    peripheral/lpcomp/pca10040/blank/config/sdk_config.h: 614
    peripheral/ram_retention/pca10040/blank/config/sdk_config.h: 122
    peripheral/pin_change_int/pca10040/blank/config/sdk_config.h: 563
    peripheral/twi_sensor/pca10040/blank/config/sdk_config.h: 614
    peripheral/timer/pca10040/blank/config/sdk_config.h: 630
    peripheral/flashwrite/pca10040/blank/config/sdk_config.h: 479
    peripheral/low_power_pwm/pca10040/blank/config/sdk_config.h: 615
    peripheral/bsp/pca10040/blank/config/sdk_config.h: 633
    peripheral/fatfs/pca10040/blank/config/sdk_config.h: 718
    ble_central_and_peripheral/experimental/ble_app_multirole_lesc/pca10040/s132/config/sdk_config.h: 3818
    ble_central_and_peripheral/experimental/ble_app_hrs_rscs_relay/pca10040/s132/config/sdk_config.h: 3818
    ble_central_and_peripheral/experimental/ble_app_att_mtu_throughput/pca10040/s132/config/sdk_config.h: 3884
    ble_central_and_peripheral/ble_connectivity/pca10040/ser_s132_spi/config/sdk_config.h: 862
    ble_central_and_peripheral/ble_connectivity/pca10040/ser_s132_uart/config/sdk_config.h: 661
    ble_central_and_peripheral/ble_connectivity/pca10040/ser_s132_hci/config/sdk_config.h: 675
    ble_central_and_peripheral/ble_connectivity/pca10040/ser_s132_spi_5W/config/sdk_config.h: 862
    multiprotocol/experimental_ble_app_gzll/pca10040/s132/config/sdk_config.h: 3811
    multiprotocol/ble_ant_app_hrm/pca10040/s332/config/sdk_config.h: 1155
    proprietary_rf/esb_ptx/pca10040/blank/config/sdk_config.h: 479
    proprietary_rf/esb_prx/pca10040/blank/config/sdk_config.h: 479
    proprietary_rf/gzll/experimental/gzp_dynamic_pairing/device/pca10040/blank/config/sdk_config.h: 602
    proprietary_rf/gzll/experimental/gzp_dynamic_pairing/host/pca10040/blank/config/sdk_config.h: 602
    proprietary_rf/gzll/experimental/gzll_ack_payload/device/pca10040/blank/config/sdk_config.h: 602
    proprietary_rf/gzll/experimental/gzll_ack_payload/host/pca10040/blank/config/sdk_config.h: 602
    proprietary_rf/gzll/experimental/gzp_desktop_emulator/pca10040/config/sdk_config.h: 516
    proprietary_rf/esb_low_power_ptx/pca10040/blank/config/sdk_config.h: 479
    proprietary_rf/esb_low_power_prx/pca10040/blank/config/sdk_config.h: 479
    dfu/bootloader_secure/pca10040/config/sdk_config.h: 515
    dfu/bootloader_secure/pca10040_debug/config/sdk_config.h: 654
    dfu/experimental_ant_bootloader/pca10040/dual_bank_ant_s332/config/sdk_config.h: 868
    dfu/experimental_ant_bootloader/pca10040/dual_bank_ant_s212/config/sdk_config.h: 868
    dfu/experimental_ant_bootloader/ota_tester/pca10040/s332/config/sdk_config.h: 527
    dfu/experimental_ant_bootloader/ota_tester/pca10040/s212/config/sdk_config.h: 527
    ant/ant_time_synchronization/tx/pca10040/s212/config/sdk_config.h: 786
    ant/ant_time_synchronization/rx/pca10040/s212/config/sdk_config.h: 809
    ant/ant_search_sharing/pca10040/s212/config/sdk_config.h: 839
    ant/ant_broadcast/tx/pca10040/s212/config/sdk_config.h: 786
    ant/ant_broadcast/rx/pca10040/s212/config/sdk_config.h: 786
    ant/ant_cw_mode/pca10040/s212/config/sdk_config.h: 640
    ant/ant_continuous_scanning_controller/pca10040/s212/config/sdk_config.h: 797
    ant/ant_high_duty_search_and_background_scanning/pca10040/s212/config/sdk_config.h: 797
    ant/ant_multi_channels/tx/pca10040/s212/config/sdk_config.h: 774
    ant/ant_multi_channels/rx/pca10040/s212/config/sdk_config.h: 797
    ant/ant_debug/pca10040/s212/config/sdk_config.h: 826
    ant/ant_background_scanning/pca10040/s212/config/sdk_config.h: 797
    ant/ant_plus/ant_hrm/hrm_tx/pca10040/s212/config/sdk_config.h: 1072
    ant/ant_plus/ant_hrm/hrm_rx/pca10040/s212/config/sdk_config.h: 993
    ant/ant_plus/ant_sdm/sdm_tx/pca10040/s212/config/sdk_config.h: 1238
    ant/ant_plus/ant_sdm/sdm_rx/pca10040/s212/config/sdk_config.h: 1138
    ant/ant_plus/ant_bpwr/bpwr_rx/pca10040/s212/config/sdk_config.h: 1122
    ant/ant_plus/ant_bpwr/bpwr_tx/pca10040/s212/config/sdk_config.h: 1201
    ant/ant_plus/ant_bsc/bsc_tx/pca10040/s212/config/sdk_config.h: 1135
    ant/ant_plus/ant_bsc/bsc_rx/pca10040/s212/config/sdk_config.h: 1083
    ant/experimental/ant_shared_channel/slave/pca10040/s212/config/sdk_config.h: 644
    ant/experimental/ant_shared_channel/master_to_master/pca10040/s332/config/sdk_config.h: 741
    ant/ant_relay_demo/pca10040/s212/config/sdk_config.h: 835
    ant/ant_message_types/master/pca10040/s332/config/sdk_config.h: 774
    ant/ant_message_types/master/pca10040/s212/config/sdk_config.h: 774
    ant/ant_async_transmitter/pca10040/s212/config/sdk_config.h: 797
    ant/ant_fs/client/pca10040/s212/config/sdk_config.h: 926
    ant/ant_io_demo/ant_io_rx/pca10040/s212/config/sdk_config.h: 802
    ant/ant_io_demo/ant_io_tx/pca10040/s212/config/sdk_config.h: 797
    ant/ant_scan_and_forward/pca10040/s212/config/sdk_config.h: 802
    ant/ant_search_uplink/pca10040/s212/config/sdk_config.h: 792
    ant/ant_multi_channels_encrypted/tx/pca10040/s212/config/sdk_config.h: 781
    ant/ant_multi_channels_encrypted/rx/pca10040/s212/config/sdk_config.h: 811
    ant/ant_advanced_burst/pca10040/s212/config/sdk_config.h: 781

    These files differ by A LOT.  It's not just which flags are 1 and which flags are 0.  Hundreds, even thousands of lines may differ.  Some flags are only defined in certain sdk_config.h files.  I have found it challenging to identify the differences between sdk_config.h files, and to merge them when I need multiple subsystems to work together.

  • Absolutely!

    That's exactly my point!

    1. The module documentation does not clearly describe what settings need to be made.
    2. The module documentation does not clearly state what files need to be added to the project.
    3. Dependencies are poorly documented.

    Another one this morning:

    https://devzone.nordicsemi.com/f/nordic-q-a/39627/error-l6218e - relates to app_uart & nrfx_twim

    So let's look at the UART documentation:

    https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/group__app__uart.html?cp=4_0_0_6_11_57

    Under 'UART driver configuration'

    Again, we have APP_UART_ENABLED "Set to 1 to enable", but no clear definition of where to do that - just the cryptic "This is an NRF_CONFIG macro".

    And I do not see anywhere that it tells you that files need to be added to the project - let alone what those files are!

    This appears to be a classic case of documentation written by coder!

     - perhaps we could discuss doing an external review? PM me ...

  • I have reported both your concerns to our SDK team. We will see if we can get something better for future releases.

  • OK. Turned out that when I combine our program with the example I had our version of sdk_config.h in the project directory but also the example's sdk_config.h in the config folder which cause the problem. It was solved by removing the config holder and also the related line in the Makefile.

Related