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

Trying to combine BLE Central UART with NFC URI examples

This is a beginner question and may well related to a misplaced setting in Segger Embedded Studio.

I am working towards a BLE scanner application which will include NFC tag capability.

To start me off I copied the NFC code from the record_url example and pasted this into the ble_app_uart_c example.

I updated my compile options to include the NFC libararies etc.

However, when building I am getting these errors saying " undefined reference to" etc.

I cannot work out what's the cause as I have checked all my references with the original project and they appear to match. Maybe I missed something.

Thanks

[code]

Building 'ble_app_###_pca10040_s132' from solution 'ble_app_###_pca10040_s132' in configuration 'Release'
  Assembling 'thumb_crt0.s'
  Compiling 'bsp_btn_ble.c'
  Compiling 'bsp.c'
  Compiling 'nrf_hw_backend_init.c'
  Compiling 'nrf_hw_backend_rng.c'
  Compiling 'nrf_hw_backend_rng_mbedtls.c'
  Compiling 'app_button.c'
  Compiling 'app_error_handler_gcc.c'
  Compiling 'app_error.c'
  Compiling 'app_timer2.c'
  Compiling 'app_scheduler.c'
  Compiling 'app_error_weak.c'
  Compiling 'app_util_platform.c'
  Compiling 'crc16.c'
  Compiling 'fds.c'
  Compiling 'drv_rtc.c'
  Compiling 'hardfault_implementation.c'
  Compiling 'mem_manager.c'
  Compiling 'nrf_assert.c'
  Compiling 'nrf_atfifo.c'
  Compiling 'nrf_atflags.c'
  Compiling 'nrf_atomic.c'
  Compiling 'nrf_balloc.c'
  Compiling 'nrf_fprintf.c'
  Compiling 'nrf_fstorage.c'
  Compiling 'nrf_fprintf_format.c'
  Compiling 'nrf_memobj.c'
  Compiling 'nrf_fstorage_sd.c'
  Compiling 'nrf_pwr_mgmt.c'
  Compiling 'nrf_queue.c'
  Compiling 'nrf_ringbuf.c'
  Compiling 'nrf_sortlist.c'
  Compiling 'nrf_section_iter.c'
  Compiling 'nrf_strerror.c'
  Compiling 'app_uart.c'
  Compiling 'nrf_drv_clock.c'
  Compiling 'nrf_drv_rng.c'
  Compiling 'nrf_drv_uart.c'
  Compiling 'nrfx_atomic.c'
  Compiling 'nrfx_clock.c'
  Compiling 'nrfx_gpiote.c'
  Compiling 'nrfx_prs.c'
  Compiling 'nrfx_uart.c'
  Compiling 'nrfx_rng.c'
  Compiling 'nrfx_uarte.c'
  Compiling 'boards.c'
  Compiling 'nrf_log_backend_serial.c'
  Compiling 'nrf_log_backend_rtt.c'
  Compiling 'nrf_log_backend_uart.c'
  Compiling 'nrf_log_default_backends.c'
  Compiling 'nrf_log_str_formatter.c'
  Compiling 'nrf_log_frontend.c'
  Compiling 'aes.c'
  Compiling 'ctr_drbg.c'
  Compiling 'platform_util.c'
  Compiling 'nrf_crypto_aead.c'
  Compiling 'nrf_crypto_aes.c'
  Compiling 'nrf_crypto_aes_shared.c'
  Compiling 'nrf_crypto_ecc.c'
  Compiling 'nrf_crypto_ecdh.c'
  Compiling 'nrf_crypto_ecdsa.c'
  Compiling 'nrf_crypto_eddsa.c'
  Compiling 'nrf_crypto_error.c'
  Compiling 'nrf_crypto_hash.c'
  Compiling 'nrf_crypto_hmac.c'
  Compiling 'nrf_crypto_hkdf.c'
  Compiling 'nrf_crypto_init.c'
  Compiling 'nrf_crypto_rng.c'
  Compiling 'nrf_crypto_shared.c'
  Compiling 'main.c'
  Compiling 'SEGGER_RTT.c'
  Compiling 'SEGGER_RTT_printf.c'
  Compiling 'SEGGER_RTT_Syscalls_SES.c'
  Assembling 'ses_startup_nrf52.s'
  Assembling 'ses_startup_nrf_common.s'
  Compiling 'auth_status_tracker.c'
  Compiling 'system_nrf52.c'
  Compiling 'ble_conn_state.c'
  Compiling 'ble_advdata.c'
  Compiling 'ble_db_discovery.c'
  Compiling 'ble_srv_common.c'
  Compiling 'gatt_cache_manager.c'
  Compiling 'gatts_cache_manager.c'
  Compiling 'nrf_ble_gatt.c'
  Compiling 'id_manager.c'
  Compiling 'nrf_ble_gq.c'
  Compiling 'nrf_ble_scan.c'
  Compiling 'nrf_ble_lesc.c'
  Compiling 'peer_data_storage.c'
  Compiling 'peer_database.c'
  Compiling 'peer_id.c'
  Compiling 'peer_manager.c'
  Compiling 'peer_manager_handler.c'
  Compiling 'pm_buffer.c'
  Compiling 'security_dispatcher.c'
  Compiling 'security_manager.c'
  Compiling 'utf.c'
  Compiling 'ble_bas_c.c'
  Compiling 'ble_hrs_c.c'
  Compiling 'nrf_sdh_ble.c'
  Compiling 'nrf_sdh.c'
  Compiling 'nrf_sdh_soc.c'
  Compiling 'oberon_backend_chacha_poly_aead.c'
  Compiling 'oberon_backend_ecc.c'
  Compiling 'oberon_backend_ecdh.c'
  Compiling 'oberon_backend_eddsa.c'
  Compiling 'oberon_backend_ecdsa.c'
  Compiling 'oberon_backend_hash.c'
  Compiling 'oberon_backend_hmac.c'
  Compiling 'nfc_ndef_msg.c'
  Compiling 'nfc_ndef_record.c'
  Compiling 'nfc_platform.c'
  Compiling 'nfc_uri_rec.c'
  Compiling 'nfc_uri_msg.c'
  Linking ble_app_###_pca10040_s132.elf
    Output/Release/Obj/ble_app_###_pca10040_s132/main.o: in function `update_NFCurl':
    undefined reference to `nfc_uri_msg_encode'
    ../../../../../../components/nfc/t2t_lib/nfc_t2t_lib_gcc.a(nfc_t2t_lib_al.c.o): in function `nrfx_nfct_evt_handler':
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:297: undefined reference to `nfc_platform_event_handler'
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:307: undefined reference to `nrfx_nfct_rx'
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:316: undefined reference to `nrfx_nfct_rx'
    ../../../../../../components/nfc/t2t_lib/nfc_t2t_lib_gcc.a(nfc_t2t_lib_al.c.o): in function `nrf_nfct_rx_frameend_handle':
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:252: undefined reference to `nrfx_nfct_init_substate_force'
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:277: undefined reference to `nrfx_nfct_rx'
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:285: undefined reference to `nrfx_nfct_init_substate_force'
    ../../../../../../components/nfc/t2t_lib/nfc_t2t_lib_gcc.a(nfc_t2t_lib_al.c.o): in function `nfc_t2t_lib_al_setup':
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:115: undefined reference to `nrfx_nfct_nfcid1_default_bytes_get'
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:123: undefined reference to `nfc_platform_setup'
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:129: undefined reference to `nrfx_nfct_init'
    ../../../../../../components/nfc/t2t_lib/nfc_t2t_lib_gcc.a(nfc_t2t_lib_al.c.o): in function `nfc_t2t_lib_al_start':
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:223: undefined reference to `nrfx_nfct_enable'
    ../../../../../../components/nfc/t2t_lib/nfc_t2t_lib_gcc.a(nfc_t2t_lib_al.c.o): in function `nfc_t2t_lib_al_send':
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:234: undefined reference to `nrfx_nfct_tx'
    ../../../../../../components/nfc/t2t_lib/nfc_t2t_lib_gcc.a(nfc_t2t_lib_al.c.o): in function `nfc_t2t_lib_al_stop':
    C:\nfc\nfc-library\private\nfc_t2t_lib\armgcc/../nfc_t2t_lib_al.c:239: undefined reference to `nrfx_nfct_disable'
Build failed

[/code]

  • I don't have any good suggestion than to check that NFC defines from the example project is copied over, and all the source (.c) files are included in the project and paths. Also try to do a clean build after saving all changes.

    Kenneth

  • Thanks for your help so far. YEs I've tried all those options.

    I have rechecked over and over the preprocessor options and user include directories and these are all referencing the correct files, because if I change the reference it tells me that it cannot find the file.

    No, for some reason when linking everything together it bombs. I am still convinced it has to do with the precompiled t2t_lib file. There must be some simple setting in the SES compiler that clears this problem.

    There has to be someone out there that got this working before. It is now getting very frustrating.

  • I could find this SES example for nRF52832 with BLE and NFC (based on nRF5 SDK v15.2 I believe):
    https://devzone.nordicsemi.com/f/nordic-q-a/43734/combining-ble-and-nfc-in-nrf52832/171638#171638

    Maybe that can be used as reference? I notice it is using the t4t library though, but that should also work.

    Best regards,
    Kenneth

  • Thanks for the suggestion. That was actually the one and only example that came up when searching on the forum. Because it related to t4t I decided not to use for the purposes of writing a NDEF URL and also want to stick with tag type 2 for now.

    For now I continue on this path and I am now attempting to build the other way.

    As in, start with a working NFC example and add in the BLE elements. This too is proving a troublesome process.

    The first build error I get (and all I've done to my code is add in libraries etc.) is that it tells me that it cannot find NRF_ERROR_INVALID_PARAM or NRF_SUCCESS.

    It took awhile to figure out why and it relates to the use of SOFTDEVICE_PRESENT in the Preprocessor Definitions. I need to use this definition for BLE.

    This in turn relates to the file "nrf_error".

    What makes this messy is that there are apparently 2 nrf_error files.

    The BLE example use "nrf_error" from "components/softdevice/..." folder while non BLE examples use the one in the "components/drivers_nrf/nrf_soc_nosd" folder.

    What I cannot figure out is where in the apps is reference to the correct nrf_error.h file as this appears not to be included in the main.c file as standard.

    Any advice as to how best to resolve will be greatly appreciated.

    Or should the advice really be that the tag type 2 library is incompatible with BLE softdevice and thus cannot be used.

  • Nothing worse than hacking around in circles, so I've returned back to my original error log to see if there is something I missed.

    And there is... staring me right in the face... it relates to a driver "nrfx_nfct" and I had not included this file in my project.

    So I now included that driver within my project and also I found that there is a setting in sdk_config: NRFX_NFCT_ENABLED which needs to set as this flag is disabled by default for non nfc projects.

    But this is now throwing up another error with this macro in nrfx_nfct.h.

    /** @brief Macro for creating a timer driver instance. */
    #define NRFX_TIMER_INSTANCE(id)                                   \
    {                                                                 \
        .p_reg            = NRFX_CONCAT_2(NRF_TIMER, id),             \
        .instance_id      = NRFX_CONCAT_3(NRFX_TIMER, id, _INST_IDX), \
        .cc_channel_count = NRF_TIMER_CC_CHANNEL_COUNT(id),           \
    }

    My error log tells me the following:

     --  Compiling 'nrfx_nfct.c' 1 Error

     --  ‘NRFX_TIMER4_INST_IDX’ undeclared here (not in a function); did you mean ‘NRFX_TIMER_INSTANCE’?

     --  in definition of macro ‘NRFX_CONCAT_3_’

     --  in expansion of macro ‘NRFX_CONCAT_3’

     --  in expansion of macro ‘NRFX_TIMER_INSTANCE’

    Any suggestions?

Related