nuttx-periphery
Pure Python peripheral APIs for NuttX character devices.
nuttx_periphery wraps GPIO, PWM, User LED, and Timer character devices with typed Python methods built on os.open, fcntl.ioctl, and ctypes structures aligned with NuttX headers.
NuttX is a POSIX compliant real-time operating system (RTOS) which now has CPython support on QEMU RISC-V and Espressif devices such as ESP32-P4.
Installation
On NuttX RTOS, this package is installed automatically during build of Python (see INTERPRETERS_CPYTHON_INSTALL_NUTTX_PACKAGE on nuttx-apps).
Features
- GPIO: output, input, and signal-based interrupt registration.
- User LED: per-LED and mask read/write.
- PWM: per-channel frequency, duty, and optional dead-time / pulse count.
- Timer: status polling, timeouts, and signal notification.
- Generic device access: raw read/ioctl via
CharacterDevice.
Requirements
- NuttX running on microcontroller with CPython available
- esp32p4-function-ev-board:python
- NuttX on QEMU
- rv-virt:python
Quick Start
Start Python on NuttX:
NuttShell (NSH) NuttX-12.4.0
nsh> python
Toggle pin state using GPIO module:
from nuttx_periphery import GPIO, GPIOPinType
with GPIO("/dev/gpio0") as gpio:
gpio.set_pin_type(GPIOPinType.GPIO_OUTPUT_PIN)
gpio.write(True)
Or operate a PWM pin:
from nuttx_periphery.pwm import PWM
with PWM("/dev/pwm0", channel_count=1) as pwm:
print(pwm.list_channels()) # See available channels
pwm.frequency = 200
pwm.channel[0].duty = 45
pwm.apply()
pwm.start()
time.sleep(5)
pwm.stop()
Examples
Additional runnable scripts are in examples/:
gpio_out.py— blink a GPIO outputgpio_interrupt.py— wait for a GPIO interrupt via signalpwm.py— read and write PWM channel settingstimer.py— poll timer time left until expirationtimer_notification.py— wait for timer expiration via signal
Download scripts to the target board using wget:
- Host:
Clone this repository on the host machine and start Python HTTP server
cd nuttx-periphery
python3 -m http.server
- Target:
Use wget on the target board to download scripts
wget -o /tmp/gpio_out.py http://192.168.0.20:8000/examples/gpio_out.py
python /tmp/gpio_out.py
Contributing
Contributions are welcome.
- Tests are required for new features.
- Code linting via
pre-commitis required.
Install from source:
git clone <repository-url>
cd nuttx-periphery
python -m pip install -e ".[dev]"
pre-commit install
pytest
The generated .whl and install script will be in dist/.
License
This project is licensed under the Apache License 2.0.
Metadata
Release files for nuttx-periphery 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nuttx_periphery-0.2.0.tar.gz | 35.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nuttx_periphery-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.7 kB
Release files / nuttx_periphery-0.2.0.tar.gz
| Download URL | nuttx_periphery-0.2.0.tar.gz |
|---|---|
| Size | 35.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a44c12ba9a249bd70a9cf7f9ffcd08b606b42b57a937b1174bf1ffdcde2fdc37
|
|
BLAKE2b-256 checksum How to use checksums |
e16ca172ad824dad164df5e66c316f245fc105932f09873e40fd4ca76dc1bbb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 12, 2026.
Transparency logRelease files / nuttx_periphery-0.2.0-py3-none-any.whl
| Download URL | nuttx_periphery-0.2.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6955244297c9d01577fa4cbc18580edaad10098a41737611342a553c83aa9510
|
|
BLAKE2b-256 checksum How to use checksums |
c8736dd045bf5c00a19c3ae50387f49b272f86806f0add2dbc2435485930ea6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 12, 2026.
Transparency log