net: ot: rework NCP interface configuration
Rework NCP interface configuration and NCP sample. Remove CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME and CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM Kconfig options in favor of chosen node zephyr,ot-uart usage. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
e1d5416df3
commit
f460848002
12 changed files with 56 additions and 45 deletions
|
@ -339,6 +339,8 @@ device.
|
|||
interprocess-communication (IPC)
|
||||
* - zephyr,itcm
|
||||
- Instruction Tightly Coupled Memory node on some Arm SoCs
|
||||
* - zephyr,ot-uart
|
||||
- Used by the OpenThread to specify UART device for Spinel protocol
|
||||
* - zephyr,shell-uart
|
||||
- Sets default :kconfig:`CONFIG_UART_SHELL_ON_DEV_NAME`
|
||||
* - zephyr,sram
|
||||
|
|
|
@ -47,6 +47,10 @@ Removed APIs in this release
|
|||
* Removed support for the Kconfig ``USB`` option. Option ``USB_DEVICE_STACK``
|
||||
is sufficient to enable USB device support.
|
||||
|
||||
* Removed ``CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM`` and
|
||||
``CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME`` Kconfig options
|
||||
in favor of chosen node ``zephyr,ot-uart``.
|
||||
|
||||
============================
|
||||
|
||||
Stable API changes in this release
|
||||
|
|
|
@ -32,6 +32,15 @@ Build the OpenThread NCP sample application like this:
|
|||
:goals: build
|
||||
:compact:
|
||||
|
||||
Build the OpenThread NCP sample application which uses CDC ACM UART device:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:zephyr-app: samples/net/openthread/coprocessor
|
||||
:board: nrf52840dk_nrf52840
|
||||
:goals: build flash
|
||||
:gen-args: -DDTC_OVERLAY_FILE=usb.overlay -DOVERLAY_CONFIG=overlay-usb-nrf-br.conf
|
||||
:compact:
|
||||
|
||||
Example building for the nrf52840dk_nrf52840 for RCP:
|
||||
|
||||
.. zephyr-app-commands::
|
||||
|
|
12
samples/net/openthread/coprocessor/app.overlay
Normal file
12
samples/net/openthread/coprocessor/app.overlay
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,ot-uart = &uart0;
|
||||
zephyr,console = &uart1;
|
||||
};
|
||||
};
|
|
@ -1,16 +1,6 @@
|
|||
# TRI n4m BR
|
||||
# Use UART_0 for Shell/Console
|
||||
CONFIG_UART_SHELL_ON_DEV_NAME="UART_0"
|
||||
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0"
|
||||
CONFIG_SHELL_PROMPT_UART="ncp-uart:~$ "
|
||||
|
||||
# Use UART_1 for Co-Processor
|
||||
#CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME="UART_1"
|
||||
|
||||
# Use USB-CDC-ACM for NCP
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM=y
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME="CDC_ACM_0"
|
||||
|
||||
CONFIG_STDOUT_CONSOLE=y
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_USB_DEVICE_STACK=y
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
# Nordic NCP USB CDC-ACM
|
||||
|
||||
# Use UART_0 for Shell/Console
|
||||
CONFIG_UART_SHELL_ON_DEV_NAME="UART_0"
|
||||
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0"
|
||||
CONFIG_SHELL_PROMPT_UART="ncp-uart:~$ "
|
||||
|
||||
# Use USB-CDC-ACM for Co-Processor
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM=y
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME="CDC_ACM_0"
|
||||
CONFIG_USB_DEVICE_STACK=y
|
||||
CONFIG_USB_DEVICE_PRODUCT="OpenThread CoProcessor NRF"
|
||||
CONFIG_USB_CDC_ACM=y
|
||||
|
|
|
@ -33,6 +33,3 @@ CONFIG_OPENTHREAD_BORDER_AGENT=y
|
|||
CONFIG_OPENTHREAD_BORDER_ROUTER=y
|
||||
CONFIG_OPENTHREAD_UDP_FORWARD=y
|
||||
CONFIG_OPENTHREAD_ENABLE_SERVICE=y
|
||||
|
||||
# Move console to other UART to not interfere with NCP
|
||||
CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_1"
|
||||
|
|
|
@ -16,6 +16,7 @@ tests:
|
|||
platform_allow: nrf52840dk_nrf52840 nrf52833dk_nrf52833
|
||||
tags: ci_build
|
||||
extra_args: OVERLAY_CONFIG=overlay-usb-nrf-br.conf
|
||||
DTC_OVERLAY_FILE="usb.overlay"
|
||||
samples.openthread.coprocessor.rcp:
|
||||
build_only: true
|
||||
platform_allow: nrf52840dk_nrf52840 nrf52833dk_nrf52833
|
||||
|
|
18
samples/net/openthread/coprocessor/usb.overlay
Normal file
18
samples/net/openthread/coprocessor/usb.overlay
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,ot-uart = &cdc_acm_uart0;
|
||||
};
|
||||
};
|
||||
|
||||
&zephyr_udc0 {
|
||||
cdc_acm_uart0: cdc_acm_uart0 {
|
||||
compatible = "zephyr,cdc-acm-uart";
|
||||
label = "CDC_ACM_0";
|
||||
};
|
||||
};
|
|
@ -187,7 +187,7 @@ endif # LOG_BACKEND_RTT
|
|||
|
||||
config LOG_BACKEND_SPINEL
|
||||
bool "Enable OpenThread dedicated Spinel protocol backend"
|
||||
depends on (OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME!=UART_CONSOLE_ON_DEV_NAME || !LOG_BACKEND_UART)
|
||||
depends on !LOG_BACKEND_UART
|
||||
depends on NET_L2_OPENTHREAD
|
||||
help
|
||||
When enabled, backend will use OpenThread dedicated SPINEL protocol for logging.
|
||||
|
|
|
@ -233,24 +233,12 @@ config OPENTHREAD_COPROCESSOR_RCP
|
|||
bool "RCP - Radio Co-Processor"
|
||||
endchoice
|
||||
|
||||
config OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME
|
||||
string "UART device to use for Co-Processor SPINEL"
|
||||
default "UART_0"
|
||||
help
|
||||
UART device to use for Co-Processor SPINEL.
|
||||
|
||||
config OPENTHREAD_COPROCESSOR_UART_RING_BUFFER_SIZE
|
||||
int "Set Co-Processor UART ring buffer size"
|
||||
default 4096
|
||||
help
|
||||
TX buffer size for the OpenThread Co-Processor UART.
|
||||
|
||||
config OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM
|
||||
bool "Run SPINEL over USB-ACM"
|
||||
depends on USB_CDC_ACM
|
||||
help
|
||||
Is the SPINEL device a USB-CDC-ACM device.
|
||||
|
||||
config OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE
|
||||
string "Path to vendor hook source file"
|
||||
help
|
||||
|
|
|
@ -19,9 +19,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <sys/ring_buffer.h>
|
||||
#include <sys/atomic.h>
|
||||
|
||||
#ifdef CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM
|
||||
#include <usb/usb_device.h>
|
||||
#endif
|
||||
|
||||
#include <openthread/ncp.h>
|
||||
#include <openthread-system.h>
|
||||
|
@ -159,11 +157,10 @@ void platformUartProcess(otInstance *aInstance)
|
|||
|
||||
otError otPlatUartEnable(void)
|
||||
{
|
||||
ot_uart.dev = device_get_binding(
|
||||
CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_DEV_NAME);
|
||||
ot_uart.dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_ot_uart));
|
||||
|
||||
if ((&ot_uart)->dev == NULL) {
|
||||
LOG_ERR("UART device not found");
|
||||
if (!device_is_ready(ot_uart.dev)) {
|
||||
LOG_ERR("UART device not ready");
|
||||
return OT_ERROR_FAILED;
|
||||
}
|
||||
|
||||
|
@ -171,8 +168,7 @@ otError otPlatUartEnable(void)
|
|||
uart_callback,
|
||||
(void *)&ot_uart);
|
||||
|
||||
#ifdef CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM
|
||||
{
|
||||
if (DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_ot_uart), zephyr_cdc_acm_uart)) {
|
||||
int ret;
|
||||
uint32_t dtr = 0U;
|
||||
|
||||
|
@ -201,7 +197,6 @@ otError otPlatUartEnable(void)
|
|||
/* Data Set Ready - the NCP SoC is ready to communicate */
|
||||
(void)uart_line_ctrl_set(ot_uart.dev, UART_LINE_CTRL_DSR, 1);
|
||||
}
|
||||
#endif /* CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM */
|
||||
|
||||
uart_irq_rx_enable(ot_uart.dev);
|
||||
|
||||
|
@ -210,13 +205,13 @@ otError otPlatUartEnable(void)
|
|||
|
||||
otError otPlatUartDisable(void)
|
||||
{
|
||||
#ifdef CONFIG_OPENTHREAD_COPROCESSOR_SPINEL_ON_UART_ACM
|
||||
int ret = usb_disable();
|
||||
if (DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_ot_uart), zephyr_cdc_acm_uart)) {
|
||||
int ret = usb_disable();
|
||||
|
||||
if (ret) {
|
||||
LOG_WRN("Failed to disable USB (%d)", ret);
|
||||
if (ret) {
|
||||
LOG_WRN("Failed to disable USB (%d)", ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uart_irq_tx_disable(ot_uart.dev);
|
||||
uart_irq_rx_disable(ot_uart.dev);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue