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 committed by Joachim Strömbergson
parent 21a69de093
commit 18433df357
5 changed files with 243 additions and 191 deletions

View file

@ -26,21 +26,15 @@ enum cmdlen {
// clang-format off
enum fwcmd {
FW_CMD_NAME_VERSION = 0x01,
FW_RSP_NAME_VERSION = 0x02,
FW_CMD_LOAD_APP_SIZE = 0x03,
FW_RSP_LOAD_APP_SIZE = 0x04,
FW_CMD_LOAD_APP_DATA = 0x05,
FW_RSP_LOAD_APP_DATA = 0x06,
FW_CMD_RUN_APP = 0x07,
FW_RSP_RUN_APP = 0x08,
FW_CMD_GET_APP_DIGEST = 0x09,
FW_CMD_LOAD_USS = 0x0a,
FW_RSP_LOAD_USS = 0x0b,
FW_CMD_GET_UDI = 0x0c,
FW_RSP_GET_UDI = 0x0d,
/* ... */
FW_RSP_GET_APP_DIGEST = 0x10, // encoded as 0x10 for backwards compatibility
FW_CMD_NAME_VERSION = 0x01,
FW_RSP_NAME_VERSION = 0x02,
FW_CMD_LOAD_APP = 0x03,
FW_RSP_LOAD_APP = 0x04,
FW_CMD_LOAD_APP_DATA = 0x05,
FW_RSP_LOAD_APP_DATA = 0x06,
FW_RSP_LOAD_APP_DATA_READY = 0x07,
FW_CMD_GET_UDI = 0x08,
FW_RSP_GET_UDI = 0x09,
};
// clang-format on