Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: Set up your environment
weight: 2

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Set up your environment

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:

- MQTT over Ethernet
- UART over a USB serial connection

By the end of this section, you will know which boards to use, which host tools to install, and how the Zephyr shell fits into an embedded application.

## Before you begin

Make sure you have a working Zephyr development environment set up in Visual Studio Code using the Workbench for Zephyr extension, including:

- The Workbench for Zephyr extension installed
- A Zephyr SDK toolchain imported in Workbench
- A West workspace initialized

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.

You also need:

- Docker Desktop, Docker Engine, or another Docker-compatible runtime
- A USB cable for each development board

## Hardware requirements

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`.

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`.

To check whether another board is supported by Zephyr, refer to the [Zephyr Supported Boards list](https://docs.zephyrproject.org/latest/boards/index.html).

## Install UART terminal tools

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.

### Windows

Install [PuTTY](https://www.putty.org/index.html), which provides a lightweight serial terminal for UART communication.

After installation:

1. Connect the development board over USB.

2. Open **Device Manager** and locate the board's COM port under **Ports (COM & LPT)**.

3. Open PuTTY and configure:

- **Connection type**: `Serial`

- **Serial line**: your board's COM port (for example `COM5`)

- **Speed**: `115200`

Select **Open** to connect to the Zephyr UART shell.

<p style="text-align:center;">
<img src="/learning-paths/embedded-and-microcontrollers/zephyr_shell/images/putty_installation.png"
alt="PuTTY Installation"
width="640"
style="max-width:100%;height:auto;" />
<br/>
<em>PuTTY Serial Terminal Configuration</em>
</p>

### macOS

macOS includes a built-in UART terminal utility through the `screen` command, so no additional software is required.

After connecting the development board over USB:

1. Open a terminal window.

2. List available serial devices:

```bash

ls /dev/tty.*

```

3. Identify the board's serial device.

4. Connect to the UART shell with:

```bash

screen /dev/tty.usbmodemXXXX 115200

```

Replace `/dev/tty.usbmodemXXXX` with the serial device shown on your system.

To exit `screen`:

1. Press `Ctrl + A`

2. Press `K`

3. Press `Y` to confirm

{{% notice Note %}}

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.

{{% /notice %}}

## Network requirements

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.

Make sure that:

- The board is connected to the same network as the host computer.
- The network provides DHCP, or you configure a static IPv4 address in `prj.conf`.
- The board can reach the MQTT broker on port `1883`.

{{% notice Note %}}
The example configuration uses IPv4. If your network does not provide DHCP, use the static IPv4 settings shown in the next section.
{{% /notice %}}

## What's next?

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Overview
weight: 3

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## What is the Zephyr shell?

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.

Several Zephyr subsystems register shell commands automatically. Common built-in modules include:

| Module | Example commands |
|--------|------------------|
| `kernel` | `version`, `uptime`, `thread list`, `thread stacks` |
| `net` | `iface`, `ping`, `dns`, `tcp` |
| `device` | `list` |
| `log` | `enable`, `disable`, `levels` |
| `shell` | `help`, `history`, `resize` |

## How shell backends work

The shell command tree is independent of the transport. The same commands can run over UART, RTT, MQTT, or another enabled backend. You select a transport by setting a single Kconfig option, with no code changes in `main.c`.

In this Learning Path you will work with two transports:

- `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.
- `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.

Multiple backends can be enabled at the same time in a single application when the board has the required peripherals and memory.

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.

## What you will do next

The two following sections each build a small Zephyr application that enables one of these backends:

- **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.
- **UART shell** on the FRDM-MCXN947, using a USB serial connection with PuTTY on Windows or the built-in `screen` utility on macOS.

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.

For more information on the shell subsystem, see the [Zephyr Shell documentation](https://docs.zephyrproject.org/latest/services/shell/index.html).

## What's next?

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.
Loading
Loading