EC Proxy is a high-performance embedded controller communication system that provides hardware abstraction and control for embedded devices. It bridges Modbus RTU communication with modern ZeroMQ-based RPC/PUB-SUB architecture, enabling intuitive hardware control through simple command-line tools or programmatic interfaces.
- Features
- Architecture
- Components
- System Requirements
- Compilation
- Installation
- Usage
- Hardware Support
- Documentation
- Contributing
- License
- Modbus RTU Bridge: Seamless communication with embedded controllers via serial interface
- ZeroMQ RPC Service: Modern, high-performance remote procedure call interface
- Event Broadcasting: Real-time PUB/SUB event system for hardware state changes
- Comprehensive Hardware Control: Manage power, USB ports, PCIe slots, RGB LEDs, LCD displays, fans, and sensors
- Network Interface Management: Automatic IP address synchronization for multiple network interfaces
- Configuration Persistence: Flash storage for critical configuration data
- Multi-threaded Architecture: Efficient concurrent handling of multiple hardware subsystems
- Simple CLI Tool: User-friendly command-line interface for all hardware operations
- Cross-platform: Built for embedded Linux devices (ARM64 architecture)
- Open Source: Licensed under MIT License
The EC Proxy system consists of two main components that work together to provide hardware abstraction:
┌─────────────────┐ Modbus RTU ┌──────────────────┐ ZMQ RPC/PUB ┌─────────────┐
│ Hardware EC │ ◄─────────────────► │ EC Proxy │ ◄──────────────────► │ Client │
│ (STM32/MCU) │ /dev/ttyS3 │ Server │ IPC/TCP Sockets │ (CLI/App) │
└─────────────────┘ 115200-921600bps └──────────────────┘ └─────────────┘
- Hardware Layer: Embedded controller (EC) exposes Modbus RTU interface over serial port
- Proxy Layer: EC Proxy server translates Modbus commands to ZMQ RPC calls
- Client Layer: CLI tools or applications interact via simple RPC interface
- Event Layer: Hardware events (button presses, status changes) broadcast via PUB/SUB
The proxy server daemon that manages all hardware communication:
- Modbus RTU serial communication
- ZeroMQ RPC service (
ipc:///tmp/rpc.ec_prox) - Event publisher (
ipc:///tmp/llm/ec_prox.event.socket) - Network interface monitoring
- Automatic fan control
- Button event handling
Command-line interface for hardware control:
# Control hardware peripherals
ec_cli device --fan -d 80 # Set fan to 80% speed
ec_cli device --rgb -d 5 # Set RGB LED mode
ec_cli device --board # Get power consumption info
ec_cli device --poweroff -d 1 # Trigger system poweroff
# Execute custom RPC calls
ec_cli exec -l # List all available functions
ec_cli exec -f <function> -d <data> # Call custom function
# Monitor hardware events
ec_cli echo --button # Subscribe to button eventsSee detailed documentation for complete command reference.
- ARM64-based embedded Linux device (AX630C, AX650N, or compatible)
- Serial port for Modbus communication (e.g.,
/dev/ttyS3) - Embedded controller with Modbus RTU support
- Operating System: Ubuntu 20.04+ (ARM64) or compatible Linux distribution
- Cross-compilation Toolchain: aarch64-none-linux-gnu-gcc 10.3+
- Build Tools: SCons, Python 3.8+
- Libraries: ZeroMQ, libmodbus, fmt, nlohmann-json
# Download and install ARM64 cross-compilation toolchain
wget https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz
sudo tar Jxvf gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz -C /opt
# Add to PATH (add to ~/.bashrc for persistence)
export PATH=/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin:$PATH# Install required packages
sudo apt update
sudo apt install -y python3 python3-pip libffi-dev git
# Install Python build tools
pip3 install parse scons requests kconfiglib# Clone repository
git clone https://github.com/m5stack/Ai_Pyramid_ec_proxy.git
cd Ai_Pyramid_ec_proxy
# Initialize submodules (SDK components)
git submodule update --init --recursive
# Navigate to EC Proxy project
cd projects/ec_proxy
# Clean previous builds (optional)
scons distclean
# Compile (use -j flag for parallel compilation)
scons -j$(nproc)After successful compilation, binaries will be located in:
projects/ec_proxy/build/
├── main_ec_proxy/
│ └── ec_proxy # Proxy server executable
└── main_ec_cli/
└── ec_cli # CLI tool executable
# Copy binaries to target device
scp build/main_ec_proxy/ec_proxy root@<target-ip>:/usr/local/bin/
scp build/main_ec_cli/ec_cli root@<target-ip>:/usr/local/bin/
# On target device, make executable
chmod +x /usr/local/bin/ec_proxy
chmod +x /usr/local/bin/cliCreate /etc/systemd/system/ec-proxy.service:
[Unit]
Description=EC Proxy Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/ec_proxy
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.targetEnable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable ec-proxy
sudo systemctl start ec-proxy# Run directly
./ec_proxy
# Or use systemd service
sudo systemctl start ec-proxy# Get hardware status
ec_cli device --board # Power consumption info
ec_cli device --version # EC firmware version
ec_cli device --fanspeed # Current fan speed
# Control peripherals
ec_cli device --fan -d 60 # Set fan PWM to 60%
ec_cli device --rgb -d 1 # Set RGB mode to 1
ec_cli device --lcd_brightness -d 200 # Set LCD brightness
# Network configuration
ec_cli device --ip_eth0 -d "192.168.1.100"
ec_cli device --flash_value # Save to flash memory
# Monitor events
ec_cli echo --button # Watch for button pressesEC Proxy supports control of the following hardware peripherals:
- Board power control
- External power switch
- USB PD power info
- Power consumption monitoring
- Scheduled power on/off
- 3× USB downstream ports (with high-power mode)
- 2× PCIe slots
- GL3510 USB hub
- Grove I2C/UART interfaces
- RGB LED array (up to 64 LEDs)
- LCD display with brightness control
- Multiple display modes
- Fan PWM control with RPM monitoring
- Temperature-based auto fan control
- CPU voltage (VDD) adjustment
- Button input detection
- Ethernet interface management (eth0, eth1)
- WLAN interface support
- Automatic IP address synchronization
See complete hardware documentation for detailed register mappings.
- EC Proxy Full Documentation - Complete guide with all commands and features
- SDK Documentation - Build system and component information
- API Reference - Modbus register mapping
# RPC socket path (default: ipc:///tmp/rpc.ec_prox)
export AX650C_EC_PROXY_RPC_SOCKET="ipc:///tmp/rpc.ec_prox"
# PUB socket path (default: ipc:///tmp/llm/ec_prox.event.socket)
export AX650C_EC_PROXY_PUB_SOCKET="ipc:///tmp/llm/ec_prox.event.socket"
# Initial RGB LED mode (default: 1)
export AX650_EC_RGB_MODE=1
# Initial LCD display mode (default: 2)
export AX650_EC_LCD_MODE=2
# Auto power-off timer in seconds (default: 30000)
export AX650_EC_POWER_OFF_TIME=30000- Serial Port:
/dev/ttyS3(configurable in code) - Baud Rate: 921600 bps (auto-negotiable)
- Data Format: 8N1 (8 data bits, no parity, 1 stop bit)
- Slave Address: 1
1. Compilation Errors
# Ensure toolchain is in PATH
which aarch64-none-linux-gnu-gcc
# Update submodules
git submodule update --init --recursive
# Clean and rebuild
scons distclean && scons -j$(nproc)2. Connection Issues
# Check if proxy is running
systemctl status ec-proxy
# Verify serial port
ls -l /dev/ttyS3
# Check socket files
ls -l /tmp/rpc.ec_prox3. Permission Issues
# Add user to dialout group for serial access
sudo usermod -aG dialout $USER
# Set proper permissions
sudo chmod 666 /dev/ttyS3Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please report bugs and feature requests via GitHub Issues.
This project is licensed under the MIT License - see the LICENSE file for details.
- M5Stack team for hardware platform support
- AXERA for AI acceleration platform
- Open source community for excellent libraries (ZeroMQ, libmodbus, fmt, nlohmann-json)
- Documentation: M5Stack Docs
- Forum: M5Stack Community
- Issues: GitHub Issues
Note: This project provides hardware abstraction for embedded controllers. It can be integrated with AI frameworks for advanced applications like voice-controlled hardware or automated system management.