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:
Michael Cardell Widerkrantz 2022-11-03 11:30:00 +01:00
parent 2fa1ffb8e7
commit c80dc53027
No known key found for this signature in database
GPG key ID: D3DB3DDF57E704E5
5 changed files with 243 additions and 191 deletions

View file

@ -71,12 +71,7 @@ void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf)
nbytes = 32;
break;
case FW_RSP_LOAD_USS:
len = LEN_4;
nbytes = 4;
break;
case FW_RSP_LOAD_APP_SIZE:
case FW_RSP_LOAD_APP:
len = LEN_4;
nbytes = 4;
break;
@ -86,12 +81,7 @@ void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf)
nbytes = 4;
break;
case FW_RSP_RUN_APP:
len = LEN_4;
nbytes = 4;
break;
case FW_RSP_GET_APP_DIGEST:
case FW_RSP_LOAD_APP_DATA_READY:
len = LEN_128;
nbytes = 128;
break;