# QT Py SAMD21 Firmware: Flash + Smoke Test

## Current status

The firmware now builds for `thumbv6m-none-eabi` and includes:
- USB HID OUT report polling
- HID packet parser
- DRV2605L command dispatch over I2C

## Build

Use:
- `tools/scripts/build_firmware.ps1`

## Flashing options

### Option A (recommended for convenience): UF2 bootloader drag-and-drop

1. Build release firmware.
2. Convert ELF to UF2 (requires `cargo-binutils` + `llvm-tools` + `uf2conv.py` or equivalent).
3. Double-tap reset on QT Py to mount `QTPYBOOT`.
4. Copy UF2 file to the mounted drive.

> Note: This repository does not yet include a pinned UF2 conversion tool script.

### Option B: SWD + probe-rs

If you have SWD access, flash directly with probe tooling.

## Host smoke test

After board reconnects as USB HID, run:
- `tools/scripts/host_hid_smoke_test.ps1`

Default smoke packet:
- Command `0x01` (`SET_INTENSITY`)
- Intensity `64`
- VID/PID `0x35bd` / `0xfe01`

## Next recommended firmware increments

1. DRV2605L init sequence (mode exit standby, optional calibration)
2. Better error handling/recovery for I2C bus faults
3. Optional HID IN status report path (ack/error counters)
4. Real waveform/time semantics for ROM effect + duration handling
