Tutorial: Core 0 Full-Duplex DMA Audio, USB OTG & Edge AI Profiles

This guide covers high-throughput multimedia, USB peripheral/host roles, and on-device SIMD neural inference on ESP32-S3 boards.


1. Core 0 Full-Duplex DMA I2S Audio (hal.audio_*)

PylotOS upgrades legacy square-wave beepers to a Core 0 DMA-buffered I2S TX/RX engine (drivers/audio/hal_tone.c):

import hal

# Open 16 kHz mono full-duplex stream (speaker TX + microphone RX):
hal.audio_open(sample_rate=16000, channels=1, enable_rx=True, volume_pct=75)

# Stream signed 16-bit little-endian PCM frames to speaker DMA:
hal.audio_write(pcm_s16le_bytes, timeout_ms=20)

# Capture microphone PCM frames zero-copy into a reusable bytearray:
mic_pcm = bytearray(640)
n = hal.audio_read_into(mic_pcm, timeout_ms=20)

print(hal.audio_info())
hal.audio_close()

2. ESP32-S3 TinyUSB Device (cdc_msc_hid) & USB Host (host)

By default, ESP32-S3 boards use the hardware USB-Serial-JTAG controller (0 B TinyUSB overhead). Opt into full USB OTG on any of the 16 esp32s3 boards at build time:

# Composite USB Device (CDC Serial + Mass Storage + USB HID Keyboard/Mouse/Gamepad):
python3 tools/build.py --board m5stack_cardputer_adv --usb-mode cdc_msc_hid

# USB OTG Host Mode (connect external USB keyboards, barcode scanners, or CDC devices):
python3 tools/build.py --board m5stack_cores3 --usb-mode host

Query active USB mode at runtime via hal.usb_info().


3. Edge AI (--enable-edge-ai), Cellular PPP, W5500 & WireGuard

All high-footprint networking and machine-learning stacks are packaged as zero-cost opt-in CMake/Kconfig profiles (boards/common/sdkconfig.*) so default 4 MiB builds stay compact:

tools/build.py FlagTarget RequirementEnabled Capabilities
--enable-edge-aiesp32s3 + PSRAMXtensa LX7 PIE 128-bit SIMD acceleration hooks for ulab, emlearn, ESP-NN, ESP-DL & ESP-SR wake-word/VAD pipelines.
--enable-modem>= 8 MiB Flashesp_modem + lwIP PPP client over UART (SIM7080G / SIM7600 / BG95 LTE-M / NB-IoT).
--enable-w5500Any SPI boardHardware SPI Ethernet (W5500) ESP-NETIF driver (M5Stack LAN Base / PoE Unit).
--enable-wireguard>= 8 MiB FlashEncrypted esp_wireguard peer-to-peer VPN tunnel interface.
--enable-lvgl>= 2 MiB PSRAMPSRAM-backed LVGL graphics profile alongside pylotos.ui.

Preview the DMA Audio, ULP & CAN demo locally:

pylotos-sim examples/audio_synth_and_industrial.py --board m5stack_cores3 --port 8080