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,

    Sorry, I was busy with something else in the last few days.

    I just want it to be able to communicate with other test tools, such as wvt tool, no matter network core or application core, thanks.

  • Hi,

    You should change &uart1 in the overlay file to add the pinctrl properties, and also add &pinctrl:

    &uart1 {
        compatible = "nordic,nrf-uarte";
        current-speed = <115200>;
        status = "okay";
        hw-flow-control;
        pinctrl-0 = <&uart1_default>;
    	pinctrl-1 = <&uart1_sleep>;
        pinctrl-names = "default", "sleep";
    };
    
    / {
        chosen {
            zephyr,bt-c2h-uart=&uart1;
        };
    };
    
    
    &pinctrl {
    	uart1_default: uart1_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 1, 14)>,
    				<NRF_PSEL(UART_RTS, 1, 16)>;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_RX, 1, 13)>,
    				<NRF_PSEL(UART_CTS, 1, 15)>;
    			bias-pull-up;
    		};
    	};
    
    	uart1_sleep: uart1_sleep {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 1, 14)>,
    				<NRF_PSEL(UART_RX, 1, 13)>,
    				<NRF_PSEL(UART_RTS, 1, 16)>,
    				<NRF_PSEL(UART_CTS, 1, 15)>;
    			low-power-enable;
    		};
    	};
    };

    Best regards,

    Marte

  • Hi Marte,

    I followed your instruction, but there is a compile error like this:

    devicetree error: D:/ncs/v2.4.2/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet.dts:138 (column 1): parse error: undefined node label 'uart1'
    I am not sure how to fix this problem.

    BTW, my board is nrf5340 Audio DK, thanks.

  • 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

Related