mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-09-26 11:21:02 -04:00
fw: Introduce an explicit state machine - changes protocol!
We introduce an explicit state machine (see README). With the new states we: - combine setting size and USS to a single command. - start the device app immediatiely when having receceived the last data chunk and returning the digest. - Loop forever and wait for the stick to be removed if we end up in unknown state. Signed-off-by: Michael Cardell Widerkrantz <mc@tillitis.se>
This commit is contained in:
parent
2fa1ffb8e7
commit
c80dc53027
5 changed files with 243 additions and 191 deletions
|
@ -18,6 +18,54 @@ If your available `objcopy` and `size` commands is anything other than
|
|||
the default `llvm-objcopy` and `llvm-size` define `OBJCOPY` and `SIZE`
|
||||
to whatever they're called on your system.
|
||||
|
||||
## Firmware state machine
|
||||
|
||||
States:
|
||||
|
||||
- `initial` - At start.
|
||||
- `init_loading` - Reset app digest, size, `USS` and load address.
|
||||
- `loading` - Expect more app data or a reset by `LoadApp()`.
|
||||
- `run` - Computes CDI and starts the device app.
|
||||
|
||||
Commands in state `initial`:
|
||||
|
||||
| *command* | *next state* |
|
||||
|--------------------|----------------|
|
||||
| NameVersion() | unchanged |
|
||||
| GetUDI() | unchanged |
|
||||
| LoadApp(size, uss) | `init_loading` |
|
||||
| | |
|
||||
|
||||
Commands in `init_loading`:
|
||||
|
||||
| *command* | *next state* |
|
||||
|--------------------|----------------|
|
||||
| NameVersion() | unchanged |
|
||||
| GetUDI() | unchanged |
|
||||
| LoadApp(size, uss) | `init_loading` |
|
||||
| LoadAppData(data) | `loading` |
|
||||
| | |
|
||||
|
||||
Commands in `loading`:
|
||||
|
||||
| *command* | *next state* |
|
||||
|--------------------|----------------------------------|
|
||||
| NameVersion() | unchanged |
|
||||
| GetUDI() | unchanged |
|
||||
| LoadApp(size, uss) | `init_loading` |
|
||||
| LoadAppData(data) | `loading` or `run` on last chunk |
|
||||
| | |
|
||||
|
||||
Behaviour:
|
||||
|
||||
- NameVersion: identifies stick.
|
||||
- GetUDI: returns the Unique Device ID with vendor id, product id,
|
||||
revision, serial number.
|
||||
- LoadApp(size, uss): Start loading an app with this size and user
|
||||
supplied secret.
|
||||
- LoadAppData(data): Load chunk of data of app. When last data chunk
|
||||
is received we compute and return the digest.
|
||||
|
||||
## Using QEMU
|
||||
|
||||
Checkout the `tk1` branch of [our version of the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue