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_id and every alias must be lowercase kebab-case, and no alias may equal the profile's own model_id.
  • No two targets in a profile may share an id; no two regions on the same target may overlap or share a name.
  • serial_number_rule.target_id/region, and every artifact_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's model_id or alias (DeviceRegistry raises DuplicateModelIdError/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

  1. Add src/scooterflasher/registry/profiles/<model_id>.yaml following the schema above. Prefer copying a similar existing profile (same MCU family/brand group) as a starting point.
  2. Run scooterflasher devices validate and scooterflasher devices show <model_id> to check it parses and reads as expected.
  3. Set support_status: experimental (or unsupported if you're adding a profile specifically to document something as unsupported) unless you have real hardware-in-the-loop evidence for tested.
  4. Add a golden test asserting the profile's key values (addresses, serial-number offsets/pattern) the way tests/unit/registry/test_builtin_profiles.py does for the models migrated from the original — this is what stops a future refactor from silently drifting the values.
  5. 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 update support-matrix.md.