Device profiles
A device profile is one YAML file under src/scooterflasher/registry/profiles/,
validated against scooterflasher.domain.models.ScooterProfile on load.
Adding a model or ESC identifier means adding a file here — no application
code changes.
Validate every profile (including one you're adding) with:
scooterflasher devices validate
scooterflasher devices show <model_id>
Schema overview
schema_version: 1
model_id: xiaomi-m365 # lowercase kebab-case slug, globally unique
display_name: "Xiaomi Mi Electric Scooter (M365)"
manufacturer: "Xiaomi"
aliases: [] # other slugs that resolve to this profile
targets: # at least one; usually "-esc" and/or "-ble"
- id: xiaomi-m365-esc # unique within the profile
protocol: swd
description: "ESC (motor controller) target."
mcu:
name: "STM32F1x-compatible ESC MCU (ST/GD32/AT32)"
family: "STM32F1" # must have a mapping in backend/openocd/targets.py
core: "Cortex-M3"
flash_size_bytes: 65536
ram_size_bytes: 32768
page_size_bytes: 1024
regions: # must not overlap; validated at load time
- name: bootloader
kind: bootloader # mbr|bootloader|firmware|softdevice|userdata|uicr|reserved|other
start: 0x08000000 # absolute address; STM32F1 flash starts here
length: 4096
- name: firmware
kind: firmware
start: 0x08001000
length: 59392
- name: userdata
kind: userdata
start: 0x0800F800
length: 1023
detection: [] # optional DetectionSignature list (source + regex)
serial_number_rule: # optional; target_id required (regions can repeat names across targets)
target_id: xiaomi-m365-esc
region: userdata
offset: 32
length: 14
encoding: ascii
pattern: "^[0-9]{5}/[0-9]{8}$"
capabilities: # Capability enum -> SupportStatus
- capability: backup
status: experimental # tested | experimental | unsupported | unknown
adapter_constraints: # AdapterKind -> SupportStatus, optional max_clock_khz
- adapter: raspberrypi-gpio
status: experimental
max_clock_khz: 1000
artifact_constraints: # what firmware/region an artifact must fit
- target_id: xiaomi-m365-esc
region_name: firmware
max_size_bytes: 59392 # optional
support_status: experimental # profile-wide overall status
notes: "..."
Validation rules (enforced at load, not documentation-only)
model_idand every alias must be lowercase kebab-case, and no alias may equal the profile's ownmodel_id.- No two targets in a profile may share an
id; no two regions on the same target may overlap or share aname. serial_number_rule.target_id/region, and everyartifact_constraints[].target_id/region_name, must reference a target and region that actually exist in the profile.- No capability may be listed twice.
- Across the whole registry: no two profiles may share a
model_id, and no alias may collide with another profile'smodel_idor alias (DeviceRegistryraisesDuplicateModelIdError/AliasCollisionError).
Support status
support_status (profile-level) and each capabilities[].status /
adapter_constraints[].status must be one of:
- tested — covered by automated tests and, for anything requiring physical hardware, documented hardware-in-the-loop evidence. Do not set this without both.
- experimental — implemented, but not hardware-verified. This is the correct default for a freshly migrated or newly added profile.
- unsupported — known not to work, or explicitly disabled (e.g. BLE on
the Ninebot G2/F2 family and the Xiaomi V2 family — see
migration-from-scooterflasher.md). - unknown — no information either way.
Contributing a new model
- Add
src/scooterflasher/registry/profiles/<model_id>.yamlfollowing the schema above. Prefer copying a similar existing profile (same MCU family/brand group) as a starting point. - Run
scooterflasher devices validateandscooterflasher devices show <model_id>to check it parses and reads as expected. - Set
support_status: experimental(orunsupportedif you're adding a profile specifically to document something as unsupported) unless you have real hardware-in-the-loop evidence fortested. - Add a golden test asserting the profile's key values (addresses,
serial-number offsets/pattern) the way
tests/unit/registry/test_builtin_profiles.pydoes for the models migrated from the original — this is what stops a future refactor from silently drifting the values. - If any address in the profile came from reverse-engineering rather than
a datasheet, say so in
notes(see the existing profiles for the pattern), and updatesupport-matrix.md.