Open-source toolkit and web suite for analyzing, patching, and flashing MCU firmware on Xiaomi (Brightway, LEQI) and Ninebot electric scooters over UART.
π Live Web Application:
The web suite is publicly deployed and accessible at vivalet.xyz/xiaomi.
Users can patch firmware and flash directly in modern browsers (Chrome, Edge, Opera on Desktop & Android) via the Web Serial API without installing local software.
- Overview & Principles
- Current Versions
- Key Logic & Architecture
- Supported Scooter Models
- Hardware Requirements & Wiring
- Usage Guides
- Testing & Verification
- Safety & Legal Disclaimer
- License & Credits
- Right to Repair & Ownership: You own what you purchase. Manufacturers should not lock you out of hardware you own.
- Knowledge in the Public Domain: Reverse engineering findings and communication protocols belong to the open community to prevent commercial exploitation and black-market software gating.
- Security through Transparency: Obscurity, unauthenticated bootloaders, and weak encryption are flaws, not protection. Documenting them promotes better industry engineering.
- Educational & Research Focus: Intended solely for academic, educational, and personal research.
| Component | Current Version | Release Highlights |
|---|---|---|
| bw-flasher | 0.7.1 |
Modular UART engine, plaintext LEQI body support (Xiaomi 5 Plus), authoritative EU1\0 header tag parsing, BLE dashboard serial number programming. |
| bw-patcher | 1.1.6 |
Dynamic binary header detection, EU1 dynamic firmware sizing, speed limit patching (sls), experimental patch decorator support for Xiaomi 6, 6 Lite, 6 Pro, and reworked 4 Ultra. |
| Web Serial Flasher | 0.7.1 (JS Port) |
Pure client-side Web Serial API implementation mirroring Python flasher logic with connection probing, setup mode, and real-time progress. |
| Web Patcher & Setup | Unified Backend | Python CLI wrapper integration (bwpatcher_cli.py, prepare.php), temp path fallbacks, and multi-language support (EN, DE, PL). |
xiaomi/
βββ flasher/ # Web Serial browser flasher
β βββ assets/js/
β β βββ brightway.js # Brightway protocol (M7, XMODEM transfer, NAK retries)
β β βββ leqi.js # LEQI protocol (M8, plaintext body check, EU1 header)
β β βββ crc.js # Hardware CRC16 algorithms
β β βββ firmware.js # Firmware header detection & container parsing
β β βββ serial.js # Web Serial connection abstraction
β β βββ serialnumber.js # LEQI BLE serial packet builder & UART transmitter
β β βββ flasher-ui.js # Web interface state management
β βββ scripts/
β βββ set_serialnumber.py # Standalone LEQI BLE serial programmer CLI
β
βββ bw/
β βββ bw-flasher-0.7.1/ # Reference standalone Python flasher package
β β βββ bwflasher/
β β β βββ base_flasher.py # Base communication abstraction
β β β βββ brightway_flasher.py# Brightway UART protocol
β β β βββ leqi_flasher.py # LEQI UART protocol
β β β βββ serial_number.py # Serial number NVM write driver
β β β βββ xmodem.py # Robust XMODEM implementation
β β β βββ keygen.py # Dynamic key generation
β β β βββ gui.py # PySide6 desktop interface
β β βββ tests/ # Flasher test suite
β β
β βββ bw-patcher/ # Reference standalone Python patcher package
β βββ bwpatcher/
β β βββ core.py # Patch engine base & binary loader
β β βββ detect.py # Binary model auto-detection heuristics
β β βββ modules/ # Model-specific patch definitions
β β β βββ mi4.py, mi5.py, mi5plus.py, mi6.py, ultra4.py, etc.
β β β βββ leqi_speed.py # LEQI speed limit patching logic
β β βββ core_n32.py, core_lks32.py, core_es32.py # Architecture drivers
β βββ tests/ # Patcher test suite
β
βββ patcher/ # Web patcher endpoint & Python bridge
β βββ patch.php # Server-side upload handler & patch dispatch
β βββ bwpatcher_cli.py # CLI interface for automated web patching
β
βββ setup/ # Interactive guided setup wizard
β βββ prepare.php # Automated stock firmware retrieval & patch generation
β βββ assets/js/setup.js # Step-by-step UI, connection probe & Web Serial flashing
β βββ mi4lite2nd/ # Dedicated utility for 4 Lite 2nd Gen
β
βββ ngfw/ # Ninebot Next-Gen Firmware patcher
β βββ ngfwpatcher/ # AGPL-3.0 patcher engine for Ninebot ESC
β βββ ngfw_cli.py # CLI wrapper
β βββ patch.php # Web patcher endpoint
β
βββ mcu/ # Firmware metadata & binary catalog
β βββ fw/data.json # Central registry of 70+ scooter models & checksums
β βββ fetch_info.php # Firmware information API endpoint
β βββ version_check.php # Update validation
β
βββ inc/
βββ functions.php # Python interpreter resolution & system helpers
βββ lang.php # Internationalization strings (EN, DE, PL)
Runs entirely inside client browsers via Web Serial API:
- Brightway Protocol (
brightway.js): 5-pin M7 interface, handshake negotiation, XMODEM binary block transfer, automatic NAK retry loop (up to 20 retries), and packet verification. - LEQI Protocol (
leqi.js): 5-pin M8 interface, plaintext body verification (0xAAcheck), authoritativeEU1\0header tag parsing at offset0x0A, dynamic 16-bit body sizing, and CRC16 checksum calculation. - Simulation & Debug Modes: Allows testing connection logic, loopbacks, and protocol state transitions without physical hardware risks.
- Cross-platform CLI and PySide6 GUI supporting Windows, Linux, and macOS.
- Auto-detects firmware container types (Brightway vs. LEQI).
- Built-in chiptune audio player, live transfer rate metering, and port auto-discovery.
- Disassembles ARM Cortex-M binaries using Capstone/Keystone.
- Automatically detects scooter model from firmware header
[0x00, 0x80). - Replaces hardcoded speed limit variables (
sls) and patches checksum validation routines (chk). - Architecture support across Nationstech N32, Linko LKS32, and Eastsoft ES32 microcontrollers.
- Handles Next-Gen Ninebot controllers (Xiaomi 4 Pro, 4 Pro Max, 4 Pro Plus).
- Dispatches patching routines via
ngfw_cli.pyand provides ST-Link / ScooterFlasher flashing commands.
- Writes 19-character ASCII product serial numbers to the dashboard BLE module's Non-Volatile Memory (NVM) over UART.
- Accessible via Web UI (
flasher/), Python CLI (flasher/scripts/set_serialnumber.py), orbw-flasher.
setup/: Guides non-technical users through selecting their model, choosing desired speed targets, verifying wiring, and flashing without manual command-line execution.mcu/fw/data.json: Authoritative firmware database matchingmi-fw-info.
| Model | Manufacturer | Connector | Flashing Support | Status |
|---|---|---|---|---|
| Xiaomi Scooter 4 | Brightway | Julet 5-Pin M7 Male | Web Serial / Python | β Verified |
| Xiaomi Scooter 4 Lite | Brightway | Julet 5-Pin M7 Male | Web Serial / Python | β Verified |
| Xiaomi Scooter 4 Ultra | Brightway | Julet 5-Pin M7 Male | Web Serial / Python | |
| Xiaomi Scooter 4 Pro (2nd Gen) | Brightway | Julet 5-Pin M7 Female | Web Serial / Python | β Verified |
| Xiaomi Scooter 5 | Brightway | Julet 5-Pin M7 Female | Web Serial / Python | β Verified |
| Xiaomi Scooter 5 Max | Brightway | Julet 5-Pin M7 Male | Web Serial / Python | β Verified |
| Xiaomi Scooter 5 Pro | Brightway | Julet 5-Pin M7 Male | Web Serial / Python | β Verified |
| Xiaomi Scooter 5 Elite | LEQI | Julet 5-Pin M8 Male | Web Serial / Python | β Verified |
| Xiaomi Scooter 6 | LEQI | Julet 5-Pin M8 Male | Web Serial / Python | |
| Xiaomi Scooter 6 Lite | LEQI | Julet 5-Pin M8 Male | Web Serial / Python | |
| Xiaomi Scooter 6 Pro | LEQI | Julet 5-Pin M8 Male | Web Serial / Python | |
| Xiaomi Scooter 42 / 43 (Navee) | Brightway/Navee | Julet 5-Pin M7 Male | Web Serial / Python | β Verified (Error 43 Fix) |
| Xiaomi Scooter 4 Pro (1st Gen) | Ninebot | Dash / ST-Link | NGFW Patcher | β CFW Supported |
| Xiaomi 4 Lite (2nd Gen) | LEQI | Julet 5-Pin M8 | Setup script / ST-Link |
-
USB to UART Adapter:
- Compatible chipsets: CH340, FT232RL, or CP2102.
- Logic Level: Set to 5V (or 3.3V logic where specified by board revision).
-
Dashboard Cable Connector:
- Brightway controllers: Julet 5-Pin M7 (Male or Female depending on model, see table above).
- LEQI controllers: Julet 5-Pin M8 Male (1:1 identical across 5 Elite and 6th Gen).
-
Pinout Guide:
Julet 5-Pin Cable USB-UART Adapter
ββββββββββββββββββ ββββββββββββββββββ
β Red β βββββββββββ> β 5V / VCC β
β Black β βββββββββββ> β GND β
β Blue / Yellow β βββββββββββ> β RXD β
β Green / White β βββββββββββ> β TXD β
ββββββββββββββββββ ββββββββββββββββββ
(Always double-check pinouts with a digital multimeter before powering on).
- Visit vivalet.xyz/xiaomi (or host locally with Apache/Nginx + PHP 8+ and Python 3.9+).
- Go to Setup or Flasher.
- Connect your USB-UART adapter and click Connect.
- Select your scooter model or upload your
.binfirmware. - Click Flash Firmware to flash directly over Web Serial.
cd bw/bw-flasher-0.7.1
# Install dependencies
pip install -r requirements.txt
# Flash firmware (auto-detects Brightway or LEQI)
python -m bwflasher --port COM3 /path/to/firmware.bin
# Test run in simulation mode
python -m bwflasher --simulation /path/to/firmware.bincd bw/bw-flasher-0.7.1
python -m bwflasher.guicd bw/bw-patcher
# Install requirements
pip install -r requirements.txt
# Auto-detect model and patch speed limit to 25 km/h with checksum recalculation
python -m bwpatcher auto stock_firmware.bin patched_firmware.bin sls=25,chk
# Explicit model patching (e.g. Mi 5 Pro)
python -m bwpatcher mi5pro stock_firmware.bin patched_firmware.bin sls=30,chk# Using the standalone CLI script
python flasher/scripts/set_serialnumber.py COM3 "0539370000000123456"
# Or using bw-flasher 0.7.1
python -m bwflasher set-serial "0539370000000123456" --port COM3Run the automated test suites using pytest:
# Test bw-flasher (9 tests covering detection, CRC, packet formation, simulation)
cd bw/bw-flasher-0.7.1
pytest tests/ -v
# Test bw-patcher (25 tests covering module disassemblers, header heuristics, patches)
cd bw/bw-patcher
pytest tests/ -vModifying scooter firmware alters vehicle behavior, can cause physical injury, and may be illegal in your jurisdiction.
- Modifying vehicle speed or power parameters will void your manufacturer warranty.
- Operating modified electric scooters on public roads or bicycle infrastructure may violate local traffic regulations (e.g., German StVZO / eKFV, EU EN 17128).
- Flashing unverified or corrupted binaries carries risk of bricking the MCU controller.
- This software is provided strictly for educational, security analysis, and research purposes.
- The authors and contributors assume no liability for hardware damage, accidents, bodily harm, or legal consequences resulting from the use of these tools.
- Suite Web Integration & Architecture: Copyright (c) 2026 visoire.
Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). - Core bw-flasher & bw-patcher Engines: Developed by ScooterTeam and community researchers (CC BY-NC-SA 4.0).
- NGFW Patcher Engine: Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
- Community Testers: Special thanks to Ilkan0342567, Gianluxx, Hypersniper_de, encryptize, holow_rt, Lenny5292, Krypz0n, Turbojeet, and everyone contributing to open scooter research.