How to let hci uart work on nRF5340

I want to use hci uart function on nRF5340 board, but it doesn't work after I flash image to it. 

BTW, my nRF Connect SDK is v2.0.0, and Windows 11 system.

and I followed the suggestion from this website:

(+) nRF5340-DK : trouble with hci_uart sample - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)

use uart1 to work as hci uart, but I can't set uart TX/RX to certain pins, i changed nrf5340dk_nrf5340_cpuapp.overlay file like this:

/* SPDX-License-Identifier: Apache-2.0 */

&uart1 {
compatible = "nordic,nrf-uarte";
current-speed = <115200>;
status = "okay";
hw-flow-control;
rx-pin = <44>;
tx-pin = <45>;
cts-pin = <46>;
rts-pin = <47>;
};
/ {
chosen {
zephyr,bt-c2h-uart=&uart1;
};
};

then it failed to build like this:

[18/173] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj
FAILED: zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj
C:\ncs\toolchains\v2.0.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -I../../../../include/zephyr -I../../../../include -Izephyr/include/generated -I../../../../soc/arm/nordic_nrf/nrf53 -I../../../../soc/arm/nordic_nrf/common/. -I../../../../subsys/bluetooth -IC:/ncs/v2.0.0/nrf/include -IC:/ncs/v2.0.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.0.0/modules/hal/nordic/nrfx -IC:/ncs/v2.0.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.0.0/modules/hal/nordic/nrfx/mdk -I../../../../modules/hal_nordic/nrfx/. -Imodules/libmetal/libmetal/lib/include -IC:/ncs/v2.0.0/modules/lib/open-amp/open-amp/lib/include -IC:/ncs/v2.0.0/nrfxlib/softdevice_controller/include -isystem ../../../../lib/libc/minimal/include -isystem c:/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/include -isystem c:/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/include-fixed -isystem C:/ncs/v2.0.0/nrfxlib/crypto/nrf_cc312_platform/include -Os -imacros C:/ncs/v2.0.0/zephyr/samples/bluetooth/hci_uart/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee -imacros C:/ncs/v2.0.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/ncs/v2.0.0/zephyr/samples/bluetooth/hci_uart=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.0.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.0.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj -MF zephyr\drivers\serial\CMakeFiles\drivers__serial.dir\uart_nrfx_uarte.c.obj.d -o zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj -c C:/ncs/v2.0.0/zephyr/drivers/serial/uart_nrfx_uarte.c
In file included from c:\ncs\v2.0.0\zephyr\include\zephyr\toolchain.h:50,
from c:\ncs\v2.0.0\zephyr\include\zephyr\sys\errno_private.h:10,
from c:\ncs\v2.0.0\zephyr\lib\libc\minimal\include\errno.h:32,
from c:\ncs\v2.0.0\zephyr\include\zephyr\drivers\uart.h:23,
from C:\ncs\v2.0.0\zephyr\drivers\serial\uart_nrfx_uarte.c:11:
c:\ncs\v2.0.0\zephyr\soc\arm\nordic_nrf\common\soc_nrf_common.h:229:2: error: static assertion failed: "/soc/peripheral@50000000/uart@9000 has legacy *-pin properties defined although PINCTRL is enabled"
229 | BUILD_ASSERT(!IS_ENABLED(CONFIG_PINCTRL) || \
| ^~~~~~~~~~~~
C:\ncs\v2.0.0\zephyr\drivers\serial\uart_nrfx_uarte.c:2053:2: note: in expansion of macro 'NRF_DT_CHECK_PIN_ASSIGNMENTS'
2053 | NRF_DT_CHECK_PIN_ASSIGNMENTS(UARTE(idx), 1, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.0.0\zephyr\drivers\serial\uart_nrfx_uarte.c:2147:1: note: in expansion of macro 'UART_NRF_UARTE_DEVICE'
2147 | UART_NRF_UARTE_DEVICE(1);
| ^~~~~~~~~~~~~~~~~~~~~
[30/173] Building C object zephyr/drivers/mbox/CMakeFiles/drivers__mbox.dir/mbox_nrfx_ipc.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.0.0\opt\bin\cmake.EXE' --build 'c:\ncs\v2.0.0\zephyr\samples\bluetooth\hci_uart\build'

So guys, any good ideas? thanks.

Parents Reply Children
  • Hi Marte, 

    I added these code in nrf5340_cpunet.dtsi

    		uart1: uart@41015000 {
    			compatible = "nordic,nrf-uarte";
    			reg = <0x41015000 0x1000>;
    			interrupts = <19 NRF_DEFAULT_IRQ_PRIORITY>;
    			status = "disabled";
    		};

    and undefined node label 'uart1' error disappeared, the @41015000 is added, it seems the base address of uart1 register, but I am not sure whether this is right, is there any documents to introduce it?

  • Hi,

    Which board are you building for, and are you building for app core or net core? You mention nrf5340dk_nrf5340_cpuapp.overlay in the original ticket, nRF5340 Audio DK in one reply, and I see nrf5340dk_nrf5340_cpunet.dts in your log.

    Are you still trying to build the HCI UART sample or a different sample?

    Best regards,
    Marte

  • Hi Marte,

    Thanks for your reply!

    I want to build a controller which support hci uart function, so net core is needed, my board is nRF5340 Audio DK. my purpose is to let board work as controller, which can communicate with host by hci uart, thanks.

    Best regards,

    Handom

  • Hi Handom,

    John81 said:
    my board is nRF5340 Audio DK

    If your board is the nRF5340 Audio DK you should be using this as build target (nrf5340_audio_dk_nrf5340_cpuapp and nrf5340_audio_dk_nrf5340_cpunet), not the nRF5340 DK.

    John81 said:
    I want to build a controller which support hci uart function, so net core is needed,

    Just to verify, does this mean you are building the HCI UART project for the network core (nrf5340_audio_dk_nrf5340_cpunet)?

    John81 said:
    I added these code in nrf5340_cpunet.dtsi

    You should not change the board files directly unless you have made a custom board. Instead you should use an overlay file and disable or delete the node there.

    Best regards,
    Marte

  • Just to verify, does this mean you are building the HCI UART project for the network core (nrf5340_audio_dk_nrf5340_cpunet)?

    Hi Marte, 

    Sorry for answering your question so late.

    My description was a little obscure before.

    So I try my best to describe my requirements clearly here.

    I have two NRF5340 Audio DK boards, and I want to let one work as Controller, and another works as Host, these two boards are connected by HCI UART.

    So my questions are like these:

    1. How to build an image works as Controller?

    2. Do there any default pins work as HCI UART for Controller? if yes, please show me their positions on the board; if not, how can I set them?

    3. How to build an image works as Host?

    4. Do there any default pins work as HCI UART for Host? if yes, please show me their positions on the board; if not, how can I set them?

    Thanks for your great patience!

    Best regards,

    Handom

Related