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

Thingy91 migrate to LPUART

I'm having a bit trouble here getting migrated to LPUART on a working nRF9160 <> HCI BLE on nRF52 (On the Thingy91). As far as I can tell my .conf and .overlay files are what they should be. Are there any other gotchas that I may be missing here? I get an HCI timeout when initializing bluetooth:

[00:00:07.104,858] <inf> beacon_scanner: Initializing beacon scanner...
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:333
        k_sem_take failed with err -11
[00:00:17.125,946] <err> os: r0/a1:  0x00000003  r1/a2:  0x20023427  r2/a3:  0x00000000
[00:00:17.126,464] <err> os: r3/a4:  0x20019830 r12/ip:  0x0000a000 r14/lr:  0x00029eb1
[00:00:17.126,983] <err> os:  xpsr:  0x61000000
[00:00:17.127,319] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
[00:00:17.127,960] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
[00:00:17.128,601] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
[00:00:17.129,211] <err> os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
[00:00:17.129,852] <err> os: fpscr:  0x20014500
[00:00:17.130,218] <err> os: Faulting instruction address (r15/pc): 0x00029ebc
[00:00:17.130,645] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
[00:00:17.131,103] <err> os: Current thread: 0x20019148 (unknown)

Here are some of the pertinent files.

thingy91_nrf52840.overlay

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

	reset_input: gpio-reset {
		compatible = "nordic,thingy91-nrf52840-reset";
		status = "okay";
		gpios = <&gpio0 20
			(GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
	};

};

&uart0 {
	/delete-property/ rts-pin;
	/delete-property/ cts-pin;
	/delete-property/ rx-pin;
};

&uart1 {
	compatible = "nordic,nrf-uarte";
	status = "okay";
	current-speed = <1000000>;
	tx-pin = <25>;
	rx-pin = <32>;

	/delete-property/ rts-pin;
	/delete-property/ cts-pin;
	/delete-property/ hw-flow-control;

	lpuart: nrf-sw-lpuart {
		compatible = "nordic,nrf-sw-lpuart";
		status = "okay";
		label = "LPUART";
		req-pin = <19>;
		rdy-pin = <22>;
	};
};

/delete-node/ &usbd;

thingy91_nrf52840.conf

# General
CONFIG_GPIO=y
CONFIG_SERIAL=y

# Stack
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512

# Bluetooth
CONFIG_BT=y
CONFIG_BT_CTLR=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_HCI_RAW_H4=y
CONFIG_BT_HCI_RAW_H4_ENABLE=y
CONFIG_BT_TINYCRYPT_ECC=n
CONFIG_BT_CTLR_DTM_HCI=y
CONFIG_BT_CTLR_ASSERT_HANDLER=y
CONFIG_BT_WAIT_NOP=y

# UART
# CONFIG_UART_INTERRUPT_DRIVEN=y
# CONFIG_UART_LINE_CTRL=y

# Enable reset pin
CONFIG_GPIO_AS_PINRESET=y

# Stack
CONFIG_HEAP_MEM_POOL_SIZE=16384

# USB
# CONFIG_USB=y
# CONFIG_USB_DEVICE_STACK=y
# CONFIG_USB_DEVICE_MANUFACTURER="React Mobile"
# CONFIG_USB_DEVICE_PRODUCT="Thingy:91 UART"
# CONFIG_USB_DEVICE_VID=0x1915
# CONFIG_USB_DEVICE_PID=0x520F
# CONFIG_USB_COMPOSITE_DEVICE=y
# CONFIG_USB_CDC_ACM=y
# CONFIG_USB_CDC_ACM_RINGBUF_SIZE=16384
# CONFIG_USB_CDC_ACM_DEVICE_COUNT=1

# LPUART config
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

thingy91_nrf9160ns.overlay

/ {
	chosen {
		zephyr,bt-uart=&lpuart;
	};

	/* Reset control */
	nrf52840_reset: gpio-reset {
		compatible = "nordic,thingy91-nrf52840-reset";
		status = "okay";
		gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
	};
};

&uart0 {
	/delete-property/ rts-pin;
	/delete-property/ cts-pin;
	/delete-property/ rx-pin;
};

&uart1 {
	compatible = "nordic,nrf-uarte";
	status = "okay";
	current-speed = <1000000>;
	tx-pin = <22>;
	rx-pin = <23>;
	
	/delete-property/ rts-pin;
	/delete-property/ cts-pin;
	/delete-property/ hw-flow-control;

	lpuart: nrf-sw-lpuart {
		compatible = "nordic,nrf-sw-lpuart";
		status = "okay";
		label = "LPUART";
		req-pin = <25>;
		rdy-pin = <24>;
	};

};

thingy91_nrf9160ns.conf

# General config
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_ASSERT=y
CONFIG_REBOOT=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

CONFIG_LTE_NETWORK_MODE_NBIOT=n
CONFIG_LTE_LEGACY_PCO_MODE=n
CONFIG_LTE_EDRX_REQ_VALUE="1101" # 43.6 minutes

CONFIG_LTE_LOCK_BANDS=y

# AT host
# CONFIG_AT_HOST_LIBRARY=y

# Non-Volatile Storage (NVS)
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# Modem info
CONFIG_MODEM_INFO=y
CONFIG_CJSON_LIB=y

# GPS
CONFIG_SUPL_CLIENT_LIB=y

# Modem library
CONFIG_NRF_MODEM_LIB=y
# Disable Modem traces, since we need UART1 for HCI
CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=n

# Enable Bluetooth stack and libraries
CONFIG_BT=y
CONFIG_BT_H4=y
CONFIG_BT_WAIT_NOP=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SCAN=y

# CONFIG_UART_INTERRUPT_DRIVEN=y

# Watchdog
CONFIG_WATCHDOG=y

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=24576
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_HW_STACK_PROTECTION=y

# Image manager
CONFIG_IMG_MANAGER=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# FOTA library
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
CONFIG_DOWNLOAD_CLIENT_TCP_SOCK_TIMEO_MS=15000
CONFIG_DOWNLOAD_CLIENT_UDP_SOCK_TIMEO_MS=15000
CONFIG_DFU_TARGET=y
CONFIG_DFU_TARGET_MCUBOOT=y
CONFIG_FOTA_DOWNLOAD=y

# Application Upgrade support
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_APPLICATION_VERSION=27
CONFIG_APPLICATION_VERSION_STRING="1.4.x"

# Fatal error
CONFIG_RESET_ON_FATAL_ERROR=n


CONFIG_NRF_SW_LPUART=y
CONFIG_NRF_SW_LPUART_INT_DRIVEN=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

I'm probably doing something stupid here but any insight would be extremely appreciated! 

In the meantime I'll keep chugging on it here. 

Thanks!

Parents
  • Hi, Jared!!

    Thanks for reaching out. You're absolutely on the right path here, but there are quite a lot of pitfalls with the hci_lpuart unfortunately. Which version of NCS are you using? There are issues with the LPUART driver in 1.5.x so I suggest using master or at least 1.6.0-rc2.

    Secondly, have you added the required updates to the board files of the Thingy:91? I've recently did some testing with hci_lpuart on for a quite recent version of the NCS master branch, so you can have a look at the board files I have there as well as this modified version of mqtt_simple. The latter just scans for certain manufacturer data in BLE advertisements. Note as well that the bt_enable functions should be called early in main, to ensure proper synchronization. 

    Please notify me if you face any issues!

    Best regards,
    Carl Richard

Reply
  • Hi, Jared!!

    Thanks for reaching out. You're absolutely on the right path here, but there are quite a lot of pitfalls with the hci_lpuart unfortunately. Which version of NCS are you using? There are issues with the LPUART driver in 1.5.x so I suggest using master or at least 1.6.0-rc2.

    Secondly, have you added the required updates to the board files of the Thingy:91? I've recently did some testing with hci_lpuart on for a quite recent version of the NCS master branch, so you can have a look at the board files I have there as well as this modified version of mqtt_simple. The latter just scans for certain manufacturer data in BLE advertisements. Note as well that the bt_enable functions should be called early in main, to ensure proper synchronization. 

    Please notify me if you face any issues!

    Best regards,
    Carl Richard

Children
Related