Skip to main content

Seeed Studio XIAO ESP32C3 with NuttX(RTOS)

Introduction

NuttX is a mature real-time operating system (RTOS) widely recognized for its standards compliance and small footprint. One of NuttX's main features is its scalability, which allows it to be used in environments ranging from 8-bit microcontrollers to 64-bit systems. This flexibility is achieved through adherence to POSIX and ANSI standards, enabling you to experiment with similar NuttX features across a wide range of chips from different architectures, families, and semiconductor vendors.

Additionally, NuttX offers many advanced and useful features, such as USB, Ethernet, Audio, and Graphics subsystems. These characteristics make NuttX an attractive choice for developers seeking a versatile, robust RTOS capable of operating on various types of hardware.

NuttX supports a vast and continually expanding number of boards. The official documentation provides a comprehensive list of supported boards, organized by architecture and System-on-Chip (SoC) series.

For instance, the Seeed Studio XIAO ESP32C3 page in the NuttX documentation offers detailed descriptions of each supported feature and instructions on how to utilize them. Also there is a specific page in the NuttX documentation for Espressif ESP32C3 series chips, where you can find the list of MCUs and peripherals supported.

Installation

The Nuttx documentation provides a guide to different platforms. For Seeed Studio XIAO ESP32C3 please follow these steps:

  1. Download Espressif esptool(https://docs.espressif.com/projects/esptool/en/latest/esp32/):

    ~/nuttxspace/nuttx$ esptool.py version
    esptool.py v4.8.1
    4.8.1
  2. Create a workspace

    mkdir nuttxspace
  3. Clone the repositories

    cd nuttxspace
    git clone https://github.com/apache/nuttx.git nuttx
    git clone https://github.com/apache/nuttx-apps apps

The Apache Nuttx it's divided into two project:

  • Nuttx: contains implemented the kernel, driver and subsystems.
  • Apps: contains a collection of tools, shells, network utilities, libraries and interpreters.

Applications

To start an application it's necessary to load a configuration on NuttX, calling the command:

./tools/configurate.sh board_name:your_application

Also it's possible to check the list of board-supported a running the command:

./tools/configurate.sh -L
  1. Build NuttX (build process will generate the firmware binaries, including nuttx.bin):

    cd nuttx
    make distclean
    ./tools/configure.sh xiao-esp32c3:usbnsh
    make V=1
  2. The RESET and BOOT buttons can be used to enter “Bootloader” mode by press and hold the BOOT key while powering up and then press the RESET key once.

  3. Load the firmware using esptool.py:

    make flash ESPTOOL_PORT=/dev/ttyACM0 ESPTOOL_BINDIR=./

Hands-on

It's time to explore NuttX practically. In this session, four applications are available: USBNSH, COMBO, WIFI and BLE.

USBNSH

The NuttShell(NSH) is a shell system to be used in NuttX, similar to bash and other similar options. It supports a rich set of included commands, scripting and the ability to run your own applications as “builtin” (part of the same NuttX binary). The NSH configuration enables console at USB using 115200 bps.

We can start the build process clearing the previous configuration

cd ~/nuttxspace/nuttx
make distclean

Now we select the NSH configuration to the xiao-esp32c3 board:

./tools/configurate.sh xiao-esp32c3:usbnsh

Compile the source code.

make -j

Load the firmware into you board, reboot the board and connect NuttShell (NSH) console over USB using the CDC/ACM serial interface:

picocom -b 115200 /dev/ttyACM0

Access the NuttShell console:

NuttShell (NSH) NuttX-12.9.0
nsh> uname -a
NuttX 12.9.0 6b4bc72626-dirty Apr 26 2025 17:40:37 risc-v esp32c3-xiao
nsh>

Typing ?, you will access the available options for commands and built-in applications.

nsh> ?
help usage: [-v] [<cmd>]

. cp exec ls reboot truncate
[ cmp exit mkdir rm uname
? dirname expr mkrd rmdir umount
alias date false mount set unset
unalias dd fdinfo mv sleep uptime
basename df free pidof source usleep
break dmesg help printf test xd
cat echo hexdump ps time
cd env kill pwd true

Builtin Apps:
getprime hello nsh ostest sh

Let's say hello to NuttX, type hello and then it executes the command:

nsh> hello
Hello, World!!

Congratulations, your first interation with NuttX was completed.

GPIO

This configuration enables gpio example applications. The General Purpose Input/Output (GPIO) is a microcontroller's most fundamental part, allowing it to connect to the external world. This way we will use the NSH to access and configure those pins as we wish. But first, let's clear the previous configuration.

cd ~/nuttxspace/nuttx
make distclean

Select the gpio configuration to the xiao-esp32c3 board.

./tools/configurate.sh xiao-esp32c3:gpio

Compile de the source code.

make -j

Load the firmware into you board, run a serial communication program such as minicon or picocom:

picocom -b 115200 /dev/ttyACM0
NuttShell (NSH) NuttX-12.9.0
nsh>

To check which options are accepted to interact with this application, type gpio -h, and it will return a list of parameters.

NuttShell (NSH) NuttX-12.9.0
nsh> gpio -h
USAGE: gpio [-t <pintype>] [-w <signo>] [-o <value>] <driver-path>
gpio -h
Where:
<driver-path>: The full path to the GPIO pin driver.
-t <pintype>: Change the pin to this pintype (0-10):
-w <signo>: Wait for a signal if this is an interrupt pin.
-o <value>: Write this value (0 or 1) if this is an output pin.
mation and exit.
Pintypes:
0: GPIO_INPUT_PIN
1: GPIO_INPUT_PIN_PULLUP
IO_INPUT_PIN_PULLDOWN
3: GPIO_OUTPUT_PIN
4: GPIO_OUTPUT_PIN_OPENDRAIN
5: GPIO_INTERRUPT_PIN
6: GPIO_INTERRUPT_HIGH_PIN
7: GPIO_INTERRUPT_LOW_PIN
8: GPIO_INTERRUPT_RISING_PIN
9: GPIO_INTERRUPT_FALLING_PIN
10: GPIO_INTERRUPT_BOTH_PIN

To confirm the GPIO device files were created, type ls/dev. After typing, you can see some gpios were declared define on boards/risc-v/esp32c3/esp32c3-xiao/src/esp32c3_gpio.c, which represent :

  • GPIOs
    • 1 Input w/ IRQ -> GPIO3
    • 1 Output -> GPIO2
nsh> ls /dev
/dev:
console
gpio0
gpio1
null
ttyACM0
ttyS0
zero
nsh>

Following these commands to read GPIO1(/dev/gpio1) (with interruption) and write at GPIO2(/dev/gpio0).

NuttShell (NSH) NuttX-12.9.0
nsh> gpio -o 1 /dev/gpio0
Driver: /dev/gpio0
Output pin: Value=1
Writing: Value=1
Verify: Value=1
nsh>
nsh> gpio -o 0 /dev/gpio0
Driver: /dev/gpio0
Output pin: Value=1
Writing: Value=0
Verify: Value=0
nsh> gpio -w 1 /dev/gpio1
Driver: /dev/gpio1
Interrupt pin: Value=0
Verify: Value=1

Check the video below with the demo for gpio:

WIFI

This configuration enables a wlan network interface that can be configured and initialized using below commands:

nsh> ifup wlan0
nsh> wapi psk wlan0 mypasswd 3
nsh> wapi essid wlan0 myssid 1
nsh> renew wlan0

In this case a connection to AP with SSID myssid is done, using mypasswd as password. IP address is obtained via DHCP using renew command. You can check the result by running ifconfig afterwards.

Let's start by cleaning previous configuration:

cd ~/nuttxspace/nuttx
make distclean

Select the wifi configuration to the xiao-esp32c3 board.

./tools/configurate.sh xiao-esp32c3:wifi

Compile de the source code.

make -j

Load the firmware into you board, run a serial communication program such as minicon or picocom:

picocom -b 115200 /dev/ttyACM0
NuttShell (NSH) NuttX-12.9.0
nsh>

We can now use WAPI commands as documented at WAPI NuttX documentation ,

NuttShell (NSH) NuttX-12.9.0
nsh> wapi psk wlan0 nuttxpwd 3
nsh> wapi essid wlan0 nuttxnw 1
nsh> renew wlan0
nsh> ifconfig
wlan0 Link encap:Ethernet HWaddr a0:85:e3:0e:4a:30 at RUNNING mtu 576
inet addr:192.168.59.144 DRaddr:192.168.59.134 Mask:255.255.255.0

nsh> ping 8.8.8.8
PING 8.8.8.8 56 bytes of data
56 bytes from 8.8.8.8: icmp_seq=0 time=50.0 ms
56 bytes from 8.8.8.8: icmp_seq=1 time=40.0 ms
56 bytes from 8.8.8.8: icmp_seq=2 time=30.0 ms
56 bytes from 8.8.8.8: icmp_seq=3 time=60.0 ms
56 bytes from 8.8.8.8: icmp_seq=4 time=100.0 ms
56 bytes from 8.8.8.8: icmp_seq=5 time=100.0 ms
56 bytes from 8.8.8.8: icmp_seq=6 time=140.0 ms
56 bytes from 8.8.8.8: icmp_seq=7 time=40.0 ms
56 bytes from 8.8.8.8: icmp_seq=8 time=50.0 ms
56 bytes from 8.8.8.8: icmp_seq=9 time=30.0 ms
10 packets transmitted, 10 received, 0% packet loss, time 10100 ms
rtt min/avg/max/mdev = 30.000/64.000/140.000/34.985 ms
nsh> nslookup google.com
Host: google.com Addr: 142.251.128.238
nsh> nslookup nuttx.apache.org
Host: nuttx.apache.org Addr: 151.101.2.132

Check the video below with the demo for wifi:

BLE

This configuration is used to enable the Bluetooth Low Energy (BLE) of ESP32-C3 chip.

Let's start by cleaning previous configuration:

cd ~/nuttxspace/nuttx
make distclean

Select the ble configuration to the xiao-esp32c3 board.

./tools/configurate.sh xiao-esp32c3:ble

Compile de the source code.

make -j

Load the firmware into you board, run a serial communication program such as minicon or picocom:

picocom -b 115200 /dev/ttyACM0
NuttShell (NSH) NuttX-12.9.0
nsh>

We can now use BT commands as documented at btsak NuttX documentation ,

NuttShell (NSH) NuttX-12.9.0
nsh> bt bnep0 scan start
nsh> bt bnep0 scan stop
nsh> bt bnep0 scan get
Scan result:
1. addr: a0:46:5a:22:ea:c4 type: 0
rssi: -92
response type: 0
advertiser data: 02 01 02 19 16 f1 fc 04 f9 6e e8 58 e6 33 58 26 c5 4b bd 91 1c e0 4f b2 d9 51 455
2. addr: a0:46:5a:22:ea:c4 type: 0
rssi: -91
response type: 0
advertiser data: 02 01 02 19 16 f1 fc 04 f9 6e e8 58 e6 33 58 26 c5 4b bd 91 1c e0 4f b2 d9 51 455
3. addr: a0:46:5a:22:ea:c4 type: 0
rssi: -100
response type: 0
advertiser data: 02 01 02 19 16 f1 fc 04 f9 6e e8 58 e6 33 58 26 c5 4b bd 91 1c e0 4f b2 d9 51 455
4. addr: a0:46:5a:22:ea:c4 type: 0
rssi: -100
response type: 4
advertiser data:
5. addr: a0:46:5a:22:ea:c4 type: 0
rssi: -97
response type: 0
advertiser data: 02 01 02 19 16 f1 fc 04 f9 6e e8 58 e6 33 58 26

Check the video below with the demo for ble:

For more information about NuttX RTOS, please visit NuttX Documentation

✨ Contributor Project

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...