I’m trying to follow Jared’s example of adding BLE to the nrf9160-feather but I’m running into problems with the hci_uart implementation.
My preferred build environment is
VSCode using the nRF Connect SDK extension
NCS version 2.5.0
I’m trying to use the Adafruit Feather nRF52840 as the “co-processor”.

In Code, I open the folder ~/ncs/v2.5.0/zephyr/samples/bluetooth/hcl_uart
In the boards folder I place the following adafruit_feather_nrf52840.overlay file:

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

/* Re-mapping */
&pinctrl {
    uart1_default_alt: uart1_default_alt{
        group1{
            psels = <NRF_PSEL(UART_TX, 0, 9)>,
                    <NRF_PSEL(UART_RX, 0, 8)>;
        };
    };
    uart1_sleep_alt: uart1_sleep_alt{
        group1{
            psels = <NRF_PSEL(UART_TX, 0, 9)>,
                    <NRF_PSEL(UART_RX, 0, 8)>;
                    low-power-enable;
        };
    };
};

/{
    chosen {
        zephyr,bt-c2h-uart = < &lpuart >;
        //zephyr,bt_c2h_uart = < &lpuart >;
    };
};

&uart1 {
    status = "okay";
    current-speed = < 1000000 >;

    lpuart:nrf-sw-lpuart {
        compatible = "nordic,nrf-sw-lpuart";
        req-pin = <6>;  // CTS
        rdy-pin = <27>;  // DTS
    };

    pinctrl-0 = < &uart1_default_alt >;
    pinctrl-1 = < &uart1_sleep_alt >;
    pinctrl-names = "default", "sleep";
};

&gpiote {
    interrupts = < 6 NRF_DEFAULT_IRQ_PRIORITY >;
};

/* Turn off un-used interfaces */

&uart0 {
    status = "disabled";
};

In the boards folder I place the following adafruit_feather_nrf52840.conf file:

CONFIG_GPIO=y

CONFIG_MAIN_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512

CONFIG_BT_MAX_CONN=16
CONFIG_BT_TINYCRYPT_ECC=n
CONFIG_BT_CTLR_DTM_HCI=y
CONFIG_BT_CTLR_ASSERT_HANDLER=y

CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_UARTE1=y

CONFIG_UART_1_ASYNC=y
CONFIG_UART_1_INTERRUPT_DRIVEN=N
CONFIG_UART_1_NRF_HW_ASYNC=y
CONFIG_UART_1_NRF_HW_ASYNC_TIMER=2

CONFIG_NRF_SW_LPUART=y
CONFIG_NRF_SW_LPUART_INT_DRIVEN=y

CONFIG_GPIO_AS_RESET=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n

The prj.conf looks like this:

CONFIG_STDOUT_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_BT=y
CONFIG_BT_WAIT_NOP=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_HCI_RAW_H4=y
CONFIG_BT_HCI_RAW_H4_ENABLE=y
CONFIG_BT_BUF_ACL_RX_SIZE=255
CONFIG_BT_BUF_CMD_TX_SIZE=255
CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255
CONFIG_BT_CTLR_ASSERT_HANDLER=y

A pristine build errors out with:

In file included from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/toolchain/gcc.h:92,
                 from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/toolchain.h:50,
                 from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/kernel_includes.h:19,
                 from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/kernel.h:17,
                 from ../src/main.c:13:
/home/jim/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_DT_CHOSEN_zephyr_bt_c2h_uart_ORD' undeclared here (not in a function)
   85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                         ^~~~~~~~~
/home/jim/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/jim/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:33: note: in expansion of macro '_CONCAT'
   85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
      |                                 ^~~~~~~
/home/jim/ncs/v2.5.0/zephyr/include/zephyr/device.h:211:37: note: in expansion of macro 'DEVICE_NAME_GET'
  211 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
      |                                     ^~~~~~~~~~~~~~~
/home/jim/ncs/v2.5.0/zephyr/include/zephyr/device.h:228:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
  228 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
      |                                  ^~~~~~~~~~~~~~~~~~
../src/main.c:36:9: note: in expansion of macro 'DEVICE_DT_GET'
   36 |         DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_c2h_uart));
      |         ^~~~~~~~~~~~~

You can see in the adafruit_feather_nrf52840.overlay that I’ve tried changing the chosen
zephyr,bt-c2h-uart = < &lpuart >; to zephyr,bt_c2h_uart = < &lpuart >;
When I do that, a pristine build gives the following error:

In file included from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/toolchain/gcc.h:92,
                 from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/toolchain.h:50,
                 from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/kernel_includes.h:19,
                 from /home/jim/ncs/v2.5.0/zephyr/include/zephyr/kernel.h:17,
                 from ../src/main.c:13:
/home/jim/ncs/v2.5.0/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_81' undeclared here (not in a function); did you mean '__device_dts_ord_11'?
   85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)

Other then adding the adafruit_feather_nrf52840.conf and adafruit_feather_nrf52840.overlay to the boards folder and changing the original prj.conf, I haven’t touched anything else.
Is this something to do with the adafruit_feather_nrf52840 or am I missing something in the overlay or conf’s?
Any help is appreciated.

    Looks like your zephyr,bt-c2h-uart entry is missing. This needs to be on the nRF52 side. Example:

    / {
    	chosen {
    		zephyr,bt-c2h-uart=&lpuart;
    	};
    };
    
    &uart1 {
        status = "okay";
    	current-speed = <1000000>;
    
    	pinctrl-0 = <&uart1_default_alt>;
    	pinctrl-1 = <&uart1_sleep_alt>;
    	pinctrl-names = "default", "sleep";
    
    	lpuart: nrf-sw-lpuart {
    		compatible = "nordic,nrf-sw-lpuart";
    		status = "okay";
    		req-pin = <15>; /* */
    		rdy-pin = <17>; /* */
    	};
    };
    
    &gpiote {
    	interrupts = <6 NRF_DEFAULT_IRQ_PRIORITY>;
    };
    
    /* Re-mapping */
    &pinctrl {
    	uart1_default_alt: uart1_default_alt {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 1, 9)>,
    				<NRF_PSEL(UART_RX, 0, 30)>;
    		};
    	};
    
    	uart1_sleep_alt: uart1_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 1, 9)>,
    				<NRF_PSEL(UART_RX, 0, 30)>;
    			low-power-enable;
    		};
    	};
    };

    Here is a working overlay for the nRF9160 Feather:

    / {
    	chosen {
    		zephyr,bt-uart=&lpuart;
    		nordic,pm-ext-flash = &w25q32jv;
    	};
    
    	nrf52_reset: gpio-reset {
    		compatible = "circuitdojo,nrf52840-reset";
    		status = "okay";
    		gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    	};
    };
    
    &gpiote {
    	interrupts = <49 NRF_DEFAULT_IRQ_PRIORITY>;
    };
    
    &uart2 {
    	current-speed = <1000000>;
    	status = "okay";
    	/delete-property/ hw-flow-control;
    
    	lpuart: nrf-sw-lpuart {
    		compatible = "nordic,nrf-sw-lpuart";
    		status = "okay";
    		req-pin = <22>;
    		rdy-pin = <21>;
    	};
    };

    Likewise your mating device needs to be configured as well. LPUART is only supported by Nordic parts.

    Hope that helps!

      I don’t understand. My zephyr,bt-c2h-uart=&lpuart; entry is right after the pinctrl block in my adafruit_feather_nrf52840.overlay file, (in the chosen block). Also, don’t you need the opening and closing <>?

        Terms and Conditions | Privacy Policy