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

ble_app_uart combined with ble_app_hrs: undefined reference

Hey guys,

I'm working with a Laird BL652-DVK (nrF 52832 - chip), Nordic SDK v.14.2.0 and SES (Segger Embedded Studio v.4.30). I am trying to combine the examples ble_app_uart and ble_app_hrs. Both examples are working separatly. But when I build my program, I'm getting "undefined reference errors" and I don't know why, because I changed my paths, config-file and makefile.?

For better understanding: I worked with the program ble_app_uart to send datas and string but that works only for the nordic app (phone and pc), because "pairing not supported". To send and receive datas and strings to a central ble modul (not programmed in C), I want to use the peer manager  for the data communication and use the example ble_app_hrs as reference. Maybe someone has another idea to solve this problem?

Here is my main.c:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Here is my config_sdk.c:

sdk_config.h

And here is my makefile:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
PROJECT_NAME := ble_app_uart_pca10040_s132
TARGETS := nrf52832_xxaa
OUTPUT_DIRECTORY := _build
SDK_ROOT := ../../../../../..
PROJ_DIR := ../../..
$(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
LINKER_SCRIPT := ble_app_uart_gcc_nrf52.ld
# Source files common to all targets
SRC_FILES += \
$(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_rtt.c \
$(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_serial.c \
$(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_backend_uart.c \
$(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_default_backends.c \
$(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_frontend.c \
$(SDK_ROOT)/components/libraries/experimental_log/src/nrf_log_str_formatter.c \
$(SDK_ROOT)/components/libraries/button/app_button.c \
$(SDK_ROOT)/components/libraries/util/app_error.c \
$(SDK_ROOT)/components/libraries/util/app_error_weak.c \
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

With main.c posted above I'm getting this errors:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Building ‘ble_app_uart_pca10040_s132’ from solution ‘ble_app_uart_pca10040_s132’ in configuration ‘Debug’
Compiling ‘main.c’
Linking ble_app_uart_pca10040_s132.elf
Output/ble_app_uart_pca10040_s132 Debug/Obj/peer_manager.o: in function `ble_evt_handler':
undefined reference to `im_ble_evt_handler'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:294: undefined reference to `sm_ble_evt_handler'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:295: undefined reference to `gcm_ble_evt_handler'
Output/ble_app_uart_pca10040_s132 Debug/Obj/peer_manager.o: in function `pm_init':
undefined reference to `pds_init'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:321: undefined reference to `pdb_init'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:327: undefined reference to `sm_init'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:333: undefined reference to `smd_init'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:339: undefined reference to `gcm_init'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:345: undefined reference to `gscm_init'
M:\Programme\C\nRF5_SDK_14.2.0_17b948a\components\ble\peer_manager/peer_manager.c:351: undefined reference to `im_init'
Output/ble_app_uart_pca10040_s132 Debug/Obj/peer_manager.o: in function `pm_sec_params_set':
undefined reference to `sm_sec_params_set'
Output/ble_app_uart_pca10040_s132 Debug/Obj/peer_manager.o: in function `pm_conn_sec_config_reply':
undefined reference to `sm_conn_sec_config_reply'
Output/ble_app_uart_pca10040_s132 Debug/Obj/peer_manager.o: in function `pm_peer_delete':
undefined reference to `im_peer_free'
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

If I activate my dispatch_function in main.c (commented out at the moment):

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
//dispatch BLE events to the peer manager
//this must be called before any event handler uses this module
static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
ble_conn_state_on_ble_evt(p_ble_evt);
ble_conn_params_on_ble_evt(p_ble_evt);
pm_on_ble_evt(p_ble_evt);
ble_nus_on_ble_evt(&m_nus, p_ble_evt);
on_ble_evt(p_ble_evt);
ble_advertising_on_ble_evt(p_ble_evt);
bsp_btn_ble_on_ble_evt(p_ble_evt);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I'm getting this error:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Building ‘ble_app_uart_pca10040_s132’ from solution ‘ble_app_uart_pca10040_s132’ in configuration ‘Debug’
Compiling ‘main.c’
implicit declaration of function 'ble_conn_state_on_ble_evt'; did you mean 'ble_conn_state_conn_idx'? [-Wimplicit-function-declaration]
implicit declaration of function 'ble_conn_params_on_ble_evt'; did you mean 'ble_conn_params_init'? [-Wimplicit-function-declaration]
implicit declaration of function 'pm_on_ble_evt'; did you mean 'on_adv_evt'? [-Wimplicit-function-declaration]
passing argument 1 of 'ble_nus_on_ble_evt' from incompatible pointer type [-Wincompatible-pointer-types]
main.c
expected 'const ble_evt_t *' {aka 'const struct <anonymous> *'} but argument is of type 'ble_nus_t *' {aka 'struct ble_nus_s *'}
implicit declaration of function 'on_ble_evt'; did you mean 'on_adv_evt'? [-Wimplicit-function-declaration]
too few arguments to function 'ble_advertising_on_ble_evt'
main.c
declared here
implicit declaration of function 'bsp_btn_ble_on_ble_evt'; did you mean 'nrf_ble_qwr_on_ble_evt'? [-Wimplicit-function-declaration]
Build failed
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I hope someone can help me.

Thanks in advance

Christoph

Parents
  • Hi,

    Maybe the online tutorial on importing files and drivers can be useful?
    https://www.youtube.com/watch?v=t-kh1EbesvI&list=PLx_tBuQ_KSqGHmzdEL2GWEOeix-S5rgTV&index=6 

    Also http://infocenter.nordicsemi.com/pdf/getting_started_ses.pdf chapter 8.6 Adding files can be useful.

    Best regards,
    Kenneth

  • Hey Kenneth,

    thank you for your advice. I will look at your online tutorial and your ses document. So do you think I only added and imported the files not correct?

    Best regards,

    Christoph

  • And I have another issue:

    It's not clear which flags in sdk_config.h should be 1 and which flags should be 0. Hundreds, even thousands of lines may differ. Some flags are only defined in certain sdk_config.h files. Also I don't know which header files are needed. Is there a documentation or something else which explains for e.g. "peer manager" what should be changed in config file and which headers should be included?

    Because how to include headers, paths and c-files and how to change config file is the easiest thing of all... But not to choose the right h-files and config flags.

    I hope, you or someone else can help me.

    Best regards

    Christoph

  • Unfortunately I am not aware of any easy overview, however I believe you should find a rather complete sdk_config.h file in [SDK root]\config\nRF52832

    Typically you need to refer an example that use a specific software module for example configuration. Also you may find the documentation for the SDK config file useful in general:
    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/sdk_config.html

  • Hey Kenneth,

    the CMSIS tool is very helpful. I forgot 3 ble libraries. Now I can build my program but I get an error in uart_init in part app_uart_fifo_init (code below).

    Error code:

    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE]

    lines:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    static void uart_init(void)
    {
    ...
    APP_UART_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart_event_handle,
    APP_IRQ_PRIORITY_LOWEST,
    err_code);
    APP_ERROR_CHECK(err_code);
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    According this thread this error could mean that the UART driver is already initialized. What do you think?

    If I comment out this lines, I get another error at this line in main:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    int main(void)
    {
    ...
    err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    ...
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    The error code is:

    <error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM]

Reply
  • Hey Kenneth,

    the CMSIS tool is very helpful. I forgot 3 ble libraries. Now I can build my program but I get an error in uart_init in part app_uart_fifo_init (code below).

    Error code:

    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE]

    lines:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    static void uart_init(void)
    {
    ...
    APP_UART_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart_event_handle,
    APP_IRQ_PRIORITY_LOWEST,
    err_code);
    APP_ERROR_CHECK(err_code);
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    According this thread this error could mean that the UART driver is already initialized. What do you think?

    If I comment out this lines, I get another error at this line in main:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    int main(void)
    {
    ...
    err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    ...
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    The error code is:

    <error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM]

Children
No Data