Skip to main content

STM32 Nucleo Setup

STM32 Nucleo boards are ARM Cortex-M development boards from STMicroelectronics. ZeroClaw communicates with them via USB serial (ST-LINK Virtual COM Port) using a JSON protocol.

Supported Boards

Nucleo-F401RE is the primary supported board. Other Nucleo boards may work with firmware modifications.

Hardware Features

  • MCU: ARM Cortex-M4, 84 MHz
  • GPIO: Arduino-compatible headers + Morpho connectors
  • Peripherals: I2C, SPI, UART, ADC, PWM
  • Debugger: Onboard ST-LINK/V2.1
  • USB: Virtual COM Port (no FTDI needed)
  • LED: PA5 (Arduino D13 equivalent, LD2)
  • Button: PC13 (USER button)

Quick Start

1. Flash Firmware

ZeroClaw provides pre-built firmware for the Nucleo-F401RE:
This command:
  1. Builds the firmware from firmware/zeroclaw-nucleo/
  2. Flashes it via OpenOCD + ST-LINK
  3. Verifies the upload

2. Find Serial Port

3. Add to Configuration

4. Test Connection

Pin Mapping

Arduino Headers

Special Pins

Do not use PA2, PA3: Reserved for USART2 (ZeroClaw serial protocol)

Wiring Examples

External LED

Button Input

Manual Firmware Flashing

Prerequisites

Build Firmware

Flash with OpenOCD

Flash with probe-rs (Alternative)

Serial Protocol

The firmware implements a JSON-over-UART protocol:

Request Format

Response Format

Supported Commands

Testing Manually

Tools Provided

When a Nucleo board is connected, ZeroClaw exposes:

Firmware Architecture

The firmware is built with:
  • Language: Rust (embedded, no_std)
  • Framework: Embassy (async embedded)
  • HAL: embassy-stm32
  • Protocol: Newline-delimited JSON over USART2
  • Size: ~30KB (fits easily in 512KB flash)
Source: firmware/zeroclaw-nucleo/src/main.rs

Advanced: Custom Firmware

To add custom peripherals (I2C sensors, PWM servos, etc.):
  1. Edit firmware/zeroclaw-nucleo/src/main.rs
  2. Add new commands to the handleLine function
  3. Rebuild and reflash
  4. Add corresponding Rust tools in src/peripherals/serial.rs
Example: Add I2C read command

Troubleshooting

Serial port not found

Permission denied on Linux

Firmware upload fails

No response from firmware

”Response id mismatch”

  • Firmware crashed or rebooted
  • Serial buffer corruption
  • Try unplugging and replugging USB

Performance Notes

  • GPIO speed: ~1 MHz toggle rate
  • Serial latency: ~10ms round-trip
  • Flash time: ~5 seconds
  • Boot time: ~100ms after reset

Next Steps

Supported Boards

Compare all hardware platforms

Arduino Setup

Similar setup for Arduino boards

Hardware Architecture

Understand the peripheral system

Adding Boards

Add support for new boards

Reference