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

Using NRF_LOG_BACKEND_UART with OpenThread

Hi everyone,

I'm currently working on my bachelor thesis and need some LOG ouput from my application.

I'm using the Development Board from Makerdiary and the nRF5_SDK_for_Thread_and_Zigbee_v1.0.0 - SDK.

I also followed the this thread to deactivate the CLI from Thread and started working from "ble_thread_dyn_template but when enabling the NRF_LOG_BACKEND_UART in the sdk_config and compile the project i get the following errors

In file included from /home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/modules/nrfx/nrfx.h:45,
                 from /home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/integration/nrfx/legacy/nrf_drv_uart.h:44,
                 from /home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/components/libraries/experimental_log/src/nrf_log_backend_uart.c:45:
/home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/modules/nrfx/drivers/include/nrfx_uarte.h:83:35: error: 'NRFX_UARTE0_INST_IDX' undeclared here (not in a function); did you mean 'NRFX_UARTE1_INST_IDX'?
   83 |     .drv_inst_idx = NRFX_CONCAT_3(NRFX_UARTE, id, _INST_IDX), \
      |                                   ^~~~~~~~~~
/home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/modules/nrfx/drivers/nrfx_common.h:117:37: note: in definition of macro 'NRFX_CONCAT_3_'
  117 | #define NRFX_CONCAT_3_(p1, p2, p3)  p1 ## p2 ## p3
      |                                     ^~
/home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/modules/nrfx/drivers/include/nrfx_uarte.h:83:21: note: in expansion of macro 'NRFX_CONCAT_3'
   83 |     .drv_inst_idx = NRFX_CONCAT_3(NRFX_UARTE, id, _INST_IDX), \
      |                     ^~~~~~~~~~~~~
/home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/integration/nrfx/legacy/nrf_drv_uart.h:56:18: note: in expansion of macro 'NRFX_UARTE_INSTANCE'
   56 |         .uarte = NRFX_UARTE_INSTANCE(id),
      |                  ^~~~~~~~~~~~~~~~~~~
/home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/integration/nrfx/legacy/nrf_drv_uart.h:165:5: note: in expansion of macro 'NRF_DRV_UART_CREATE_UARTE'
  165 |     NRF_DRV_UART_CREATE_UARTE(id) \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/components/libraries/experimental_log/src/nrf_log_backend_uart.c:48:25: note: in expansion of macro 'NRF_DRV_UART_INSTANCE'
   48 | nrf_drv_uart_t m_uart = NRF_DRV_UART_INSTANCE(0);
      |                         ^~~~~~~~~~~~~~~~~~~~~
/home/Dnil/Nordic/nrf52840-mdk/nrf_sdks/nRF5_SDK_for_Thread_and_Zigbee_v1.0.0/components/toolchain/gcc/Makefile.common:272: recipe for target '_build/nrf52840_xxaa/nrf_log_backend_uart.c.o' failed
make: *** [_build/nrf52840_xxaa/nrf_log_backend_uart.c.o] Error 1

Parents
  • Hello,

    The UART is used by the openthread stacks, so either you must build the openthread stack again without using the UART (so that you can use it in your application), or you can use the RTT backend for the logging. I really recommend the latter, because it is a lot less work, and you probably won't use the logger module in a finished product.

    Is there any particular reason why you use such an old SDK? I would recommend you to move to the latest release, 4.1.0 which you can find here. It contains a lot of bugfixes.

    You can find the latest SDK here.

    BR,

    Edvin

Reply
  • Hello,

    The UART is used by the openthread stacks, so either you must build the openthread stack again without using the UART (so that you can use it in your application), or you can use the RTT backend for the logging. I really recommend the latter, because it is a lot less work, and you probably won't use the logger module in a finished product.

    Is there any particular reason why you use such an old SDK? I would recommend you to move to the latest release, 4.1.0 which you can find here. It contains a lot of bugfixes.

    You can find the latest SDK here.

    BR,

    Edvin

Children
  • Hi,

    i now changed to the newer SDK version.

    Could you explain me how to connect to the Board over RTT backend? I couldn't figure it out by myself.

    I'm working on Linux and tried to connect via your programmer software getting the following error:


    Unsupported device. The detected device could not be recognized as neither JLink device nor Nordic USB device.

    To my mind this development board is not supported by your tool because is uses DAPLink instead of JLink

  • Dnil said:
    To my mind this development board is not supported by your tool because is uses DAPLink instead of JLink

     Then I am not sure whether RTT would work. But you can try to use "JLink RTT Viewer" from Segger.

    Not the nRF Connect for Desktop either, for that matter.

    How was the DAPLink usually used to program the nRF?

    If you want to use the UART, you must rebuild the openthread with the option set to not use UART. Please refer this guide.

    Please also check the log output settings described on infocenter.

    Back to your original question, please check out one of the non-thread examples from the SDK, e.g SDK\examples\ble_peripheral\ble_app_hrs, which use the UART as log backend. Look at the sdk_config.h file. Make sure that UART0 is enabled. Please set both UART_ENABLED to 1 and UART0_ENABLED to 1 in sdk_config.h.

    BR,
    Edvin

  • The JLink is not working for that Board.

    I rebuild openthread, is it correct to use the switch USB=1 to not use the UART?

  • Dnil said:
    I rebuild openthread, is it correct to use the switch USB=1 to not use the UART?

     The USB doesn't affect the UART. They are two different peripherals.

    Back to the original issue. Did you include the files that contain the macros that it is missing? NRFX_UARTE0_INST_IDX?

    You need the UART files from the SDK that generate this. You also need the UART definitions in sdk_config.h. Check out how it is defined in one of the examples that use it, such as the SDK\examples\ble_peripheral\ble_app_hrs. This example uses UART for logging by default. 

    Your compiler is complaining about the missing NRFX_UARTE0_INST_IDX. It is defined in nrfx_uarte.h if NRFX_UARTE0_ENABLED is defined.

    Try to define the following definitions in sdk_config.h:

    #define UART_ENABLED 1
    #define UART0_ENABLED 1
    #define NRFX_UARTE_ENABLED 1
    #define NRFX_UART_ENABLED 1

    BR,

    Edvin

  • I started a new test project.

    I included the follwoing files to the Makefile
    $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
    $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
    $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \
    $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_uart.c \
    and only truned on the switches you told me. I did not define the NRFX_UARTE0_ENABLED but still get this issue
Related