A streamlined, interactive batch firmware update tool for CubeOrange/CubeOrangePlus autopilots and DroneCAN peripheral devices.
- Two-Phase Operation:
- Phase A: One-time Cube device detection & update
- Phase B: Continuous DroneCAN device monitoring & auto-update
- Robust Device Detection: Multi-attempt retry logic handles USB re-enumeration and bootloader transitions
- Multiple Device Support: Parallel detection and updating of multiple Cube devices
- Minimal User Interaction: Single confirmation prompt then fully automated
- Real-time Progress Display: Grouped progress bars by device type
- Cross-platform: Single binary for Windows, macOS, and Linux with platform-specific optimizations
- Dynamic Node Allocation: Built-in DNA server for DroneCAN devices
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Create the firmware directory structure:
firmware/
├── CubeOrange.apj # Cube firmware files
├── CubePilot-CubeOrangePlus.apj
├── com.cubepilot.gps/
│ └── firmware.bin
├── com.cubepilot.esc/
│ └── firmware.bin
└── com.cubepilot.compass/
└── firmware.bin
# Development mode
python src/main.py
# Or build and run executable
python build.py
./dist/dronecan-batch-updater
- Place APJ firmware files directly in
firmware/
directory - Files should be named descriptively (e.g.,
CubeOrange.apj
) - Tool auto-matches firmware based on board ID
- Create subdirectories named after device identifier from GetNodeInfo
- Format:
firmware/com.cubepilot.{device_name}/firmware.bin
- Device name extracted from GetNodeInfo response
- Tool auto-detects and updates when devices appear
- Startup: Tool scans for connected Cube devices
- Version Check: Compares current firmware vs available firmware
- User Confirmation: Single prompt for batch Cube updates
- Cube Updates: Sequential update of all Cube devices with progress display
- DroneCAN Mode: Starts DNA server and continuous monitoring
- Auto-Updates: Automatically updates DroneCAN devices as they connect
# Build single executable for current platform
python build.py
# Clean build artifacts
python build.py clean
Executables are created in dist/
directory.
Default settings in src/dronecan_monitor.py
:
- CAN Port:
/dev/ttyACM0
- Node ID: 100
- Bitrate: 1000000
Modify these values as needed for your setup.
CubeOrange Devices:
├── /dev/ttyACM0 [████████████████████] 100% Complete ✓
├── /dev/ttyACM1 [████████████░░░░░░░░] 65% Uploading
└── /dev/ttyACM2 [░░░░░░░░░░░░░░░░░░░░] 0% Queued
DroneCAN Devices:
├── Node 42 (com.cubepilot.gps) [████████████████████] 100% Complete ✓
├── Node 43 (com.cubepilot.esc) [████████░░░░░░░░░░░░] 40% Uploading...
└── Node 44 (com.cubepilot.compass) [░░░░░░░░░░░░░░░░░░░░] 0% Detected, updating...
- USB Device Detection: The tool uses robust retry logic to handle USB re-enumeration during bootloader transitions
- Multiple Devices: Supports detection and parallel updating of multiple Cube devices
- Permissions: Ensure user is in
dialout
group for serial port access:sudo usermod -a -G dialout $USER newgrp dialout
- COM Port Scanning: Automatically scans COM1-COM255 for devices
- USB Drivers: Ensure proper USB drivers are installed for Cube devices
- USB Interface: Uses
/dev/tty.usbmodem*
pattern for device detection - Security: May require approval for USB device access
-
No Cube devices detected
- Check USB connections and try different ports
- Verify device is in bootloader mode (rapid LED blinking)
- On Linux: Check user permissions with
groups
command - Try unplugging and reconnecting USB cable
-
Linux-specific detection issues
- Tool automatically retries detection with proper USB re-enumeration handling
- Multiple USB interfaces (
-if00
,-if02
) are handled automatically - Bootloader transitions are managed with appropriate delays
-
DroneCAN devices not appearing
- Verify CAN bus connections and termination
- Check CAN port configuration in source code
- Ensure devices are powered and operational
- Use
mcast:0
for testing with single devices
-
Firmware not found
- Check firmware directory structure matches expected format
- Verify APJ file board IDs match detected devices
- Ensure GetNodeInfo returns correct device identifier
Uncomment DEBUG_PRINT statements in source files for detailed logging:
print(f"[DEBUG] Message here")
dronecan>=1.0.0
- DroneCAN protocol supportpymavlink>=2.4.0
- MAVLink communicationpyserial>=3.5
- Serial port communicationrich>=13.0.0
- Enhanced terminal UIpyinstaller>=5.0.0
- Binary buildingcolorama>=0.4.0
- Cross-platform colorsclick>=8.0.0
- CLI framework
This project integrates existing PX4/ArduPilot uploader code which is licensed under BSD-3-Clause.