Automatically flash OpenShock firmware to ESP32 devices when they are plugged in. Features color-coded terminal backgrounds to indicate the current status at a glance.
- Automatic detection of newly connected devices
- Color-coded status with background colors:
- Blue - Waiting for device
- Yellow - Flashing in progress
- Green - Flash complete
- Red - Error occurred
- Firmware verification using SHA256 checksums
- Multiple channels - stable, beta, or develop
- Post-flash commands - Send serial commands to device after flashing
- Continuous mode - flash multiple devices in sequence
- Optional flash erase before flashing
- Smart text wrapping - Long messages wrap cleanly without cutting words
- Dynamic boards list - View available boards for any channel via
--help
- Python 3.12 or higher
- Linux, macOS, or Windows
- USB connection to ESP32 devices
Install directly from the latest GitHub version:
pipx install --force 'git+https://github.com/NanashiTheNameless/OpenShock-AutoFlasher@main'This makes the OPSH-AutoFlash command available system-wide.
If you prefer a release from PyPI:
pipx install OpenShock-AutoFlasher- Clone this repository:
git clone https://github.com/NanashiTheNameless/OpenShock-AutoFlasher.git
cd OpenShock-AutoFlasher- Install dependencies:
pip3 install -r requirements.txtFlash devices using the stable firmware channel:
OPSH-AutoFlash --board <board-name>View available boards for different channels:
OPSH-AutoFlash --help # Shows boards for stable channel
OPSH-AutoFlash --channel beta --help # Shows boards for beta channel
OPSH-AutoFlash -C develop --help # Shows boards for develop channel| Option | Short | Description | Default |
|---|---|---|---|
--channel |
-C |
Firmware channel: stable, beta, or develop |
stable |
--version |
-V |
Use specific firmware version (overrides channel) | - |
--board |
-B |
Board type (required) | - |
--chip |
- | Target chip for esptool | auto |
--erase |
-E |
Erase flash before flashing | false |
--no-auto |
-N |
Disable auto-flash (just detect devices) | false |
--post-flash |
-P |
Serial command to send after flashing (can use multiple times) | - |
--post-flash-delay |
- | Milliseconds to wait between post-flash commands | 0 |
--alert |
-A |
Beep audibly when flashing completes | false |
Flash with stable firmware:
OPSH-AutoFlash --board Wemos-D1-Mini-ESP32Flash with specific firmware version:
OPSH-AutoFlash --version 1.5.0 --board Wemos-D1-Mini-ESP32Flash with beta firmware and erase existing data:
OPSH-AutoFlash --channel beta --board Wemos-D1-Mini-ESP32 --eraseFlash with an explicit esptool chip:
OPSH-AutoFlash --board Seeed-Xiao-ESP32C3 --chip esp32c3 --eraseFlash and send post-flash commands to device:
OPSH-AutoFlash --board Wemos-D1-Mini-ESP32 \
--post-flash "help" \
--post-flash "version" \
--post-flash-delay 1500 \
--post-flash "status"Use development firmware with audio alert:
OPSH-AutoFlash --channel develop --board Wemos-D1-Mini-ESP32 --alertDetect devices without auto-flashing:
OPSH-AutoFlash --board Wemos-D1-Mini-ESP32 --no-auto- Fetches the latest firmware version from firmware.openshock.org (or uses specified version)
- Validates the specified board type against available boards
- Initializes known USB ports and begins monitoring
- Detects when new devices are connected
- Downloads firmware binary and checksum in parallel
- Verifies firmware integrity using SHA256 checksum
- Optionally erases flash memory (if
--eraseis specified) - Flashes the device using esptool
- Executes post-flash commands over serial (if specified)
- Repeats for additional devices (continuous mode)
The tool uses esptool with optimized settings and can send serial commands to the device after flashing for automated configuration or testing.
The tool supports multiple ESP32-based boards. To view the current list of available boards, run:
OPSH-AutoFlash --help # Stable channel boards
OPSH-AutoFlash --channel beta --help # Beta channel boards
OPSH-AutoFlash -C develop --help # Develop channel boardsCommon board types include:
Wemos-D1-Mini-ESP32Wemos-Lolin-S2-MiniWemos-Lolin-S3Wemos-Lolin-S3-MiniWaveshare_esp32_s3_zeroPishock-2023Pishock-Lite-2021Seeed-Xiao-ESP32C3Seeed-Xiao-ESP32S3DFRobot-Firebeetle2-ESP32EOpenShock-Core-V1OpenShock-Core-V2NodeMCU-32S
Note: Different channels may have different board support. Always check the help output for your selected channel.
On Linux, you may need to add your user to the dialout group to access serial ports:
sudo usermod -a -G dialout $USERThen log out and log back in for the changes to take effect.
Device not detected:
- Ensure the device is in bootloader mode
- Check USB cable connection
- Verify device appears in system (check
dmesgon Linux or Device Manager on Windows)
Permission errors:
- Add user to dialout/uucp group (Linux)
- Run with appropriate permissions
- Check USB cable supports data transfer (not charge-only)
Verification fails:
- Try using
--eraseflag to erase flash first - Check for hardware issues
- Try a different USB port or cable
The project includes a comprehensive test suite using pytest. To run the tests:
- Install development dependencies:
pip install -e .[dev]- Run the test suite:
pytest tests/ -v- Run tests with coverage:
pytest tests/ -v --cov=openshock_autoflasher --cov-report=term-missingThe project uses several tools for code quality:
- Black - Code formatting
- Flake8 - Linting
- Mypy - Type checking
Run code quality checks:
# Format code
black openshock_autoflasher/ tests/
# Lint code
flake8 openshock_autoflasher/ tests/
# Type check
mypy openshock_autoflasher/The codebase is modular and organized as follows:
openshock_autoflasher/- Main packageconstants.py- Configuration constantsstyles.py- Terminal styling and colorsflasher.py- Core AutoFlasher class with flashing logiccli.py- Command-line interface and argument parsing__init__.py- Package initialization__main__.py- Module entry point
tests/- Test suitetest_constants.py- Tests for constants moduletest_styles.py- Tests for styles moduletest_flasher.py- Tests for flasher moduletest_cli.py- Tests for CLI module
The project uses GitHub Actions for CI/CD:
- Tests Workflow - Runs tests on Ubuntu, Windows, and macOS with Python 3.12-3.14
- Publish Workflow - Publishes to PyPI on release
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). See LICENSE) file for details.
Contributions are welcome! Please feel free to submit issues or pull requests.
This tool is provided as-is. Use at your own risk. Always ensure you have backups of any important configurations before flashing firmware.