You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Set up the Zephyr shell development environment
3
3
weight: 2
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
8
9
-
## Set up your environment
9
+
## Set up the Zephyr shell development environment
10
10
11
11
In this section, you will prepare your host computer and identify the hardware needed for two Zephyr shell examples. You will use the shell over two transports:
12
12
@@ -23,24 +23,22 @@ Make sure you have a working Zephyr development environment set up in Visual Stu
23
23
- A Zephyr SDK toolchain imported in Workbench
24
24
- A West workspace initialized
25
25
26
-
If you have not done this yet, complete [Build Zephyr projects with Workbench for Zephyr in VS Code learnin path](/learning-paths/embedded-and-microcontrollers/zephyr_vsworkbench/) first.
26
+
If you have not done this yet, complete [Build Zephyr projects with Workbench for Zephyr in VS Code](/learning-paths/embedded-and-microcontrollers/zephyr_vsworkbench/) first.
27
27
28
-
You also need:
28
+
The two examples in this Learning Path have different additional requirements:
29
29
30
-
- Docker Desktop, Docker Engine, or another Docker-compatible runtime
31
-
- A USB cable for each development board
30
+
-**MQTT shell example**: Docker Desktop, Docker Engine, or another Docker-compatible runtime on your host computer. The board communicates with a Mosquitto broker running in a container.
31
+
-**UART shell example**: A USB cable to connect the development board to your host computer. The board exposes a shell prompt over the USB serial interface.
32
32
33
33
## Hardware requirements
34
34
35
-
For the MQTT shell example, use a Zephyr-supported development board with Ethernet. The instructions use the [FRDM-MCXN947](https://www.nxp.com/design/design-center/development-boards-and-designs/FRDM-MCXN947), with the Zephyr board identifier `frdm_mcxn947/mcxn947/cpu0`.
35
+
Both examples use the [FRDM-MCXN947](https://www.nxp.com/design/design-center/development-boards-and-designs/FRDM-MCXN947) as the development board (Zephyr identifier `frdm_mcxn947/mcxn947/cpu0`). The FRDM-MCXN947 includes an Ethernet port for the MQTT shell example and a USB UART interface for the UART shell example, so both examples run on the same board.
36
36
37
-
For the UART shell example, use a Zephyr-supported development board with a USB UART interface. The instructions use the [FRDM-MCXN947](https://www.nxp.com/design/design-center/development-boards-and-designs/FRDM-MCXN947), with the Zephyr board identifier `frdm_mcxn947/mcxn947/cpu0`.
38
-
39
-
To check whether another board is supported by Zephyr, refer to the [Zephyr Supported Boards list](https://docs.zephyrproject.org/latest/boards/index.html).
37
+
To check whether another board is supported by Zephyr, see the [Zephyr Supported Boards list](https://docs.zephyrproject.org/latest/boards/index.html).
40
38
41
39
## Install UART terminal tools
42
40
43
-
For the UART shell example, install a serial terminal application on your host computer. You will use the terminal application to connect to the Zephyr shell over the board's UART interface.
41
+
For the UART shell example, install a serial terminal application on your host computer. You will use the terminal application to connect to the Zephyr shell over the board's UART interface. This Learning Path supports Windows, macOS, and Linux host computers.
44
42
45
43
### Windows
46
44
@@ -55,21 +53,12 @@ After installation:
55
53
3. Open PuTTY and configure:
56
54
57
55
-**Connection type**: `Serial`
58
-
59
56
-**Serial line**: your board's COM port (for example `COM5`)
60
-
61
57
-**Speed**: `115200`
62
58
63
59
Select **Open** to connect to the Zephyr UART shell.

73
62
74
63
### macOS
75
64
@@ -82,38 +71,59 @@ After connecting the development board over USB:
82
71
2. List available serial devices:
83
72
84
73
```bash
85
-
86
74
ls /dev/tty.*
75
+
```
76
+
77
+
3. Connect to the UART shell with:
87
78
79
+
```bash
80
+
screen /dev/tty.usbmodemXXXX 115200
88
81
```
89
82
90
-
3. Identify the board's serial device.
83
+
Replace `/dev/tty.usbmodemXXXX` with the serial device shown on your system.
84
+
85
+
To exit `screen`, press `Ctrl + A`, then `K`, then `Y` to confirm.
91
86
92
-
4. Connect to the UART shell with:
87
+
### Linux
88
+
89
+
Linux includes `screen` in most distributions, so no additional software is required. If `screen` is not installed, use your package manager to install it:
93
90
94
91
```bash
92
+
sudo apt install screen
93
+
```
95
94
96
-
screen /dev/tty.usbmodemXXXX 115200
95
+
After connecting the development board over USB:
96
+
97
+
1. Open a terminal window.
97
98
99
+
2. List available serial devices:
100
+
101
+
```bash
102
+
ls /dev/ttyACM* /dev/ttyUSB*
98
103
```
99
104
100
-
Replace `/dev/tty.usbmodemXXXX` with the serial device shown on your system.
105
+
3. If you see a permission error when connecting, add your user to the `dialout` group and log out and back in:
101
106
102
-
To exit `screen`:
107
+
```bash
108
+
sudo usermod -aG dialout $USER
109
+
```
103
110
104
-
1. Press `Ctrl + A`
111
+
4. Connect to the UART shell with:
105
112
106
-
2. Press `K`
113
+
```bash
114
+
screen /dev/ttyACM0 115200
115
+
```
107
116
108
-
3. Press `Y` to confirm
117
+
Replace `/dev/ttyACM0` with the device shown on your system. Boards using a CP210x or FTDI USB-UART chip typically appear as `/dev/ttyUSB0`.
109
118
110
-
{{% notice Note %}}
119
+
To exit `screen`, press `Ctrl + A`, then `K`, then `Y` to confirm.
111
120
121
+
{{% notice Note %}}
112
122
Workbench for Zephyr supports multiple debug runners depending on the connected board. The FRDM-MCXN947 board uses the onboard CMSIS-DAP / LinkServer interface for flashing and debugging, while shell access in this Learning Path uses UART over USB.
113
123
114
124
{{% /notice %}}
115
125
116
-
## Network requirements
126
+
## Network requirements for the MQTT shell example
117
127
118
128
For the MQTT shell example, the board needs access to an MQTT broker over Ethernet. You will run Mosquitto locally with Docker Compose and use the Mosquitto command-line tools to send and receive shell messages.
119
129
@@ -129,4 +139,4 @@ The example configuration uses IPv4. If your network does not provide DHCP, use
129
139
130
140
## What's next?
131
141
132
-
In the next section, you will read a short overview of the Zephyr shell subsystem and the two transports used in this Learning Path. After that, you will build the MQTT shell and the UART shell on the FRDM-MCXN947 using a USB serial connection and a UART terminal application such as PuTTY or the built-in macOS `screen`utility.
142
+
In the next section, you will read a short overview of the Zephyr shell subsystem and the two transports used in this Learning Path. After that, you will build the MQTT shell and the UART shell on the FRDM-MCXN947 using a USB serial connection and a UART terminal application such as PuTTY on Windows or `screen`on macOS and Linux.
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/zephyr_shell/2_overview.md
+14-13Lines changed: 14 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
-
title: Overview
2
+
title: Understand the Zephyr shell subsystem and backends
3
3
weight: 3
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
8
9
-
## What is the Zephyr shell?
9
+
## Understand the Zephyr shell subsystem and backends
10
10
11
11
The Zephyr shell subsystem (`CONFIG_SHELL=y`) adds an interactive command-line interface to your firmware. After the shell is enabled, you can inspect system state, run subsystem commands, and trigger application behavior at runtime without rebuilding or reflashing the application.
12
12
@@ -26,24 +26,25 @@ The shell command tree is independent of the transport. The same commands can ru
26
26
27
27
In this Learning Path you will work with two transports:
28
28
29
-
-`CONFIG_SHELL_BACKEND_MQTT=y` routes shell commands and responses over MQTT topics. Inbound on `<device_id>/sh/rx`, outbound on `<device_id>/sh/tx`. The backend connects automatically once the board has an IPv4 address. The MQTT backend is IPv4-only.
30
-
-`CONFIG_SHELL_BACKEND_SERIAL=y` routes shell commands and responses over the board's UART interface. The shell is accessible through a USB serial connection using a terminal application such as PuTTY on Windows or the built-in `screen` utility on macOS. The UART backend works on a wide range of Zephyr-supported development boards with no additional debug hardware required.
29
+
**MQTT backend** (`CONFIG_SHELL_BACKEND_MQTT=y`)
30
+
31
+
Routes shell commands and responses over MQTT topics. The board subscribes to `<device_id>/sh/rx` for inbound commands and publishes responses to `<device_id>/sh/tx`. The backend connects automatically once the board has an IPv4 address. This backend is IPv4-only.
Routes shell commands and responses over the board's UART interface, accessible through a USB serial connection. Use PuTTY on Windows, or `screen` on macOS and Linux. This backend works on a wide range of Zephyr-supported development boards with no additional debug hardware required.
31
36
32
37
Multiple backends can be enabled at the same time in a single application when the board has the required peripherals and memory.
33
38
34
-
A minimal shell build with only the kernel and device modules adds roughly 10 to 15 KB to flash and a few hundred bytes to RAM.
39
+
A minimal shell build with only the kernel and device modules adds roughly 10 to 15 KB to flash and a few hundred bytes to RAM on a Cortex-M target, though the exact footprint depends on the modules enabled and the toolchain optimization level.
35
40
36
-
## What you will do next
41
+
## What you will build next
37
42
38
-
The two following sections each build a small Zephyr application that enables one of these backends:
43
+
The next two sections each build a small Zephyr application that enables one of these backends:
39
44
40
45
-**MQTT shell** on the NXP FRDM-MCXN947, with a local Mosquitto broker running in Docker. You will send commands and read responses with the `mosquitto_pub` and `mosquitto_sub` command-line tools.
41
-
-**UART shell** on the FRDM-MCXN947, using a USB serial connection with PuTTY on Windows or the built-in `screen`utility on macOS.
46
+
-**UART shell** on the FRDM-MCXN947, using a USB serial connection with PuTTY on Windows or `screen` on macOS and Linux.
42
47
43
-
Each example is portable to any Zephyr-supported board with the right peripheral (Ethernet for MQTT, J-Link for RTT). The "Switch to a different board" section near the end of each page shows how to change the target board on an existing project.
48
+
Each example is portable to any Zephyr-supported board with the right peripheral — Ethernet for the MQTT backend, USB UART for the UART backend. The "Switch to a different board" section near the end of each page shows how to change the target board on an existing project.
44
49
45
50
For more information on the shell subsystem, see the [Zephyr Shell documentation](https://docs.zephyrproject.org/latest/services/shell/index.html).
46
-
47
-
## What's next?
48
-
49
-
In the next section, you will build the MQTT shell on the FRDM-MCXN947, run Mosquitto in Docker, and exchange shell commands with the board over MQTT topics.
0 commit comments