Skip to content

Commit 5504e4e

Browse files
KAGA164rlubos
authored andcommitted
samples: remote_shell: Add Remote Shell sample
Adds new sample for nRF5340 target. The sample provides remote shell host functionality and can relay shell data from IPC to the USB or the UART interface. NCSDK-13995 Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
1 parent a1dd846 commit 5504e4e

12 files changed

+585
-0
lines changed

samples/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ if (CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE)
9393
)
9494
endif()
9595

96+
if (CONFIG_NCS_SAMPLE_REMOTE_SHELL_CHILD_IMAGE)
97+
add_child_image(
98+
NAME "remote_shell"
99+
SOURCE_DIR "${NRF_DIR}/samples/nrf5340/remote_shell"
100+
DOMAIN "CPUAPP"
101+
BOARD ${CONFIG_DOMAIN_CPUAPP_BOARD}
102+
)
103+
endif()
104+
96105
if (CONFIG_NCS_INCLUDE_RPMSG_CHILD_IMAGE)
97106

98107
if (CONFIG_NCS_SAMPLE_MULTIPROTOCOL_RPMSG_CHILD_IMAGE)

samples/Kconfig

+9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ config NCS_INCLUDE_RPMSG_CHILD_IMAGE
4646
- nRF IEEE 802.15.4 Serialization RPMsg: When only nRF IEEE 802.15.4 Serialization host is enabled.
4747
- nRF RPC Host: When Bluetooth and Bluetooth serialization over RPC are enabled.
4848

49+
config NCS_SAMPLE_REMOTE_SHELL_CHILD_IMAGE
50+
bool "Add remote_shell sample as a child image"
51+
depends on SHELL_IPC
52+
select PARTITION_MANAGER_ENABLED
53+
help
54+
Add remote_shell as a child image (application core).
55+
Used by samples that run on the network core only.
56+
57+
4958
if NCS_INCLUDE_RPMSG_CHILD_IMAGE
5059

5160
config NCS_SAMPLE_MULTIPROTOCOL_RPMSG_CHILD_IMAGE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright (c) 2022 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(NONE)
11+
12+
# NORDIC SDK APP START
13+
target_sources(app PRIVATE
14+
src/main.c
15+
src/shell_ipc_host.c
16+
)
17+
# NORDIC SDK APP END

samples/nrf5340/remote_shell/Kconfig

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) 2022 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
source "Kconfig.zephyr"
8+
9+
menu "Nordic Remote Shell sample"
10+
11+
config REMOTE_SHELL_TX_RING_BUFFER_SIZE
12+
int "Set TX ring buffer size"
13+
default 64
14+
help
15+
If UART is utilizing DMA transfers then increasing ring buffer size
16+
increases transfers length and reduces number of interrupts. It is used
17+
to collect data from transport medium and passing it to remote shell.
18+
19+
config REMOTE_SHELL_RX_RING_BUFFER_SIZE
20+
int "Set RX ring buffer size"
21+
default 64
22+
help
23+
RX ring buffer size, used to collect data received from remote shell and passing
24+
them to chosen transport medium.
25+
26+
config REMOTE_SHELL_UART_DEV
27+
string "UART device name"
28+
default "CDC_ACM_0"
29+
help
30+
Name of the used UART device. The sample uses cdc_acm_0 by default.
31+
The UART device should not be used as logger backend.
32+
33+
endmenu
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.. _nrf5340_remote_shell:
2+
3+
nRF5340: Remote IPC shell
4+
#########################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
You can use this sample to run the remote shell on the nRF5340 network core through the IPC service.
11+
12+
Requirements
13+
************
14+
15+
The sample supports the following development kit:
16+
17+
.. table-from-rows:: /includes/sample_board_rows.txt
18+
:header: heading
19+
:rows: nrf5340dk_nrf5340_cpuapp
20+
21+
Overview
22+
********
23+
24+
The sample shows how to run remote shell on the remote CPU using IPC service backend for shell.
25+
It collects shell data from the IPC endpoint and forwards it to the terminal over USB transport or UART.
26+
If the shell runs on the network core, you might want to use a peripheral that the network core does not have, for example USB.
27+
You can use this sample to demonstrate how to forward shell data from the network core to the application core and connect the shell terminal through the application core.
28+
29+
Building and running
30+
********************
31+
32+
.. |sample path| replace:: :file:`samples/nrf5340/remote_shell`
33+
34+
.. include:: /includes/build_and_run.txt
35+
36+
.. _remote_shell_testing:
37+
38+
Testing
39+
=======
40+
41+
To test the sample, complete the following steps:
42+
43+
1. Program the sample to the application core.
44+
#. Program the :ref:`radio_test` sample to the network core.
45+
#. Plug the DK into a USB host device.
46+
The DK is visible as a COM port (Windows) or ttyACM device (Linux) after you connect the development kit over USB.
47+
#. |connect_terminal|
48+
49+
Dependencies
50+
************
51+
52+
This sample the following Zephyr libraries:
53+
54+
* :ref:`zephyr:kernel_api`:
55+
56+
* ``include/device.h``
57+
* ``include/drivers/uart.h``
58+
* ``include/zephyr.h``
59+
* ``include/sys/ring_buffer.h``
60+
* ``include/sys/atomic.h``
61+
* ``include/usb/usb_device.h``
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2022 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
&zephyr_udc0 {
8+
cdc_acm_uart0 {
9+
compatible = "zephyr,cdc-acm-uart";
10+
label = "CDC_ACM_0";
11+
};
12+
};
13+
14+
/ {
15+
chosen {
16+
zephyr,shell-ipc = &ipc0;
17+
};
18+
};

samples/nrf5340/remote_shell/prj.conf

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Copyright (c) 2022 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
################################################################################
7+
8+
CONFIG_STDOUT_CONSOLE=y
9+
10+
CONFIG_USB_DEVICE_STACK=y
11+
CONFIG_USB_DEVICE_PRODUCT="Nordic Remote Shell sample"
12+
CONFIG_USB_DEVICE_VID=0x1915
13+
CONFIG_USB_DEVICE_PID=0x530E
14+
15+
CONFIG_LOG=y
16+
17+
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
18+
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
19+
20+
CONFIG_SERIAL=y
21+
CONFIG_UART_INTERRUPT_DRIVEN=y
22+
CONFIG_UART_LINE_CTRL=y
23+
24+
CONFIG_IPC_SERVICE=y
25+
CONFIG_IPC_SERVICE_BACKEND_RPMSG=y
26+
CONFIG_MBOX=y
27+
28+
CONFIG_HEAP_MEM_POOL_SIZE=4096
29+
30+
CONFIG_BOARD_ENABLE_CPUNET=y
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) 2022 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
################################################################################
7+
8+
CONFIG_STDOUT_CONSOLE=y
9+
10+
CONFIG_REMOTE_SHELL_UART_DEV="UART_0"
11+
12+
CONFIG_SERIAL=y
13+
CONFIG_UART_INTERRUPT_DRIVEN=y
14+
CONFIG_RING_BUFFER=y
15+
16+
CONFIG_IPC_SERVICE=y
17+
CONFIG_IPC_SERVICE_BACKEND_RPMSG=y
18+
CONFIG_MBOX=y
19+
20+
CONFIG_MBOX_NRFX_IPC=y
21+
CONFIG_NRFX_UARTE0=y
22+
23+
CONFIG_HEAP_MEM_POOL_SIZE=4096
24+
25+
# Config logger
26+
CONFIG_LOG=y
27+
CONFIG_USE_SEGGER_RTT=y
28+
CONFIG_LOG_BACKEND_RTT=y
29+
CONFIG_LOG_BACKEND_UART=n
30+
31+
CONFIG_REMOTE_SHELL_TX_RING_BUFFER_SIZE=1024
32+
33+
CONFIG_BOARD_ENABLE_CPUNET=y
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sample:
2+
name: Remote IPC shell sample
3+
description: Remote shell sample based on IPC service shell backend.
4+
tests:
5+
samples.nrf5340.empty_app_core.build:
6+
build_only: true
7+
platform_allow: nrf5340dk_nrf5340_cpuapp
8+
integration_platforms:
9+
- nrf5340dk_nrf5340_cpuapp
10+
tags: ci_build
11+
samples.nrf5340.remote_shell.uart.build:
12+
build_only: true
13+
platform_allow: nrf5340dk_nrf5340_cpuapp
14+
extra_args: CONF_FILE=prj_uart.conf
15+
integration_platforms:
16+
- nrf5340dk_nrf5340_cpuapp
17+
tags: ci_build

0 commit comments

Comments
 (0)