# Refleks Lite Bootloader and DFU Guide

## Flash layout

| Region | Start address | Size | USB identity |
| --- | ---: | ---: | --- |
| Bootloader / DFU | `0x08000000` | 24 KB | `1209:E667` |
| App1 / XInput | `0x08006000` | 52 KB | `1209:E668` |
| App2 / DInput | `0x08013000` | 52 KB | `1209:E669` |

For initial programming, flash `build/Release/arcadestick_full.hex` with an
ST-Link. This file contains the bootloader and both applications.

## Boot selection

- Hold `START` during reset to keep the device in DFU mode.
- When `PA4` is LOW, the bootloader starts XInput App1.
- When `PA5` is LOW, the bootloader starts DInput App2.
- If the selection is invalid, or the selected application's vector table is
  invalid, the bootloader remains in DFU mode.

## Updating over USB

The bootloader implements standard USB DFU 1.1. It does not use DfuSe address
commands; the alternate interface number selects the destination slot.

```powershell
# XInput App1
dfu-util -d 1209:e667 -a 0 -D build/Release/arcadestick_xinput.bin

# DInput App2
dfu-util -d 1209:e667 -a 1 -D build/Release/arcadestick.bin
```

On Windows, the `1209:E667` device must use the WinUSB driver. `dfu-util` is
not currently installed in this computer's `PATH`.
