Getting started
Better ScooterFlasher reflashes and recovers electric scooter controllers with OpenOCD, straight from a Raspberry Pi's GPIO pins or with a USB programmer. It is a from-scratch rebuild of ScooterFlasher, with a command line, a desktop GUI, automatic backups and verification of every write.
Warning: alpha software. Flashing can permanently brick your scooter. Keep power and wiring stable during an operation, and keep your backups. Use it at your own risk.
Features
- No ST-Link required: SWD over Raspberry Pi GPIO. ST-Link, CMSIS-DAP, J-Link and custom OpenOCD configs are also selectable.
- Safe by default: backup before writing, verification after writing, and explicit confirmation for risky operations.
- Userdata editing: serial number, mileage and activation state.
- Firmware catalog: downloads checked against their SHA-256.
- Interactive or scriptable: guided prompts in a terminal,
--jsonoutput and distinct exit codes for scripts.
Status
| What | State |
|---|---|
| ESC flashing over Raspberry Pi GPIO, with serial number and mileage | Worked on one scooter |
| Other scooter models | Untested |
| ST-Link, CMSIS-DAP, J-Link | Untested |
| BLE (dashboard) flashing | Untested, see limitations |
Known limitations:
- Read-protected chips are not unlocked automatically, and there is no unlock command.
- The original BLE bootloader images do not fit the BLE bootloader region, so a full dashboard reflash does not work.
--mass-erasealso erases the bootloader (and UICR on BLE) and only restores userdata. Avoid it unless you are rewriting those regions yourself.- Bootloader files are not included.
Installation
You need Python 3.11 or newer and OpenOCD (0.12 or newer for Raspberry Pi GPIO). On Raspberry Pi OS:
sudo apt install git openocd python3-venv
git clone https://github.com/Zenoova/better-scooterflasher.git
cd better-scooterflasher
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
scooterflasher doctor
For the desktop GUI:
pip install -e ".[gui]"
scooterflasher-gui
Wiring a Raspberry Pi
| Scooter board | Raspberry Pi (BCM) | Physical pin |
|---|---|---|
| SWDIO | GPIO22 | 15 |
| SWCLK | GPIO23 | 16 |
| GND | GND | any ground pin |
Caution: SWD is 3.3 V. Never connect a 5 V signal.
Your user needs access to the GPIO device:
sudo usermod -aG gpio $USER
Log out and back in afterwards. Pins and chip can be changed with
--gpio-swdio, --gpio-swclk and --gpio-chip.
Usage
Run a command without options in a terminal and it asks for what it needs:
scooterflasher flash
Or pass everything explicitly. Find your model and the available firmware:
scooterflasher devices list
scooterflasher catalogs list
Check the connection, then back up before anything else:
scooterflasher probe --device xiaomi-m365 --target xiaomi-m365-esc --adapter raspberrypi-gpio
scooterflasher backup --device xiaomi-m365 --target xiaomi-m365-esc --adapter raspberrypi-gpio
Flash a cataloged ESC firmware (replace VERSION):
scooterflasher flash --device xiaomi-m365 --target xiaomi-m365-esc --adapter raspberrypi-gpio \
--artifact firmware=drv:VERSION
The command asks you to confirm each risky step. In scripts, pass
--confirm TOKEN for each one; scooterflasher plan lists them.
Add --serial-number or --mileage-km to edit userdata, and --write REGION=PATH to flash a local file. scooterflasher plan previews an operation
without touching the hardware.
To restore a backup:
scooterflasher restore --device xiaomi-m365 --target xiaomi-m365-esc --adapter raspberrypi-gpio \
--backup-dir PATH_TO_BACKUP
Next
- Support matrix: what has been verified.
- Adapters: wiring and permissions of each programmer.
- Backup and recovery: read it before your first flash.
Credits and license
Hardware knowledge (memory maps and protocol quirks) comes from the original ScooterFlasher, itself inspired by ScooterHacking.org's ReFlasher. Cataloged firmware comes from scooterhacking/firmware; it is community-sourced, not issued by the manufacturers. Licensed under GPL-3.0-or-later.