mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-07 06:02:22 -04:00
Add fw state and fw cmd to trigger a start of a preloaded app
This commit is contained in:
parent
bdc4351480
commit
9330b9b5bb
4 changed files with 32 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include "blake2s/blake2s.h"
|
#include "blake2s/blake2s.h"
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "partition_table.h"
|
#include "partition_table.h"
|
||||||
|
#include "preload_app.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
|
@ -248,6 +249,13 @@ static enum state initial_commands(const struct frame_header *hdr,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case FW_CMD_LOAD_APP_FLASH:
|
||||||
|
rsp[0] = STATUS_OK;
|
||||||
|
fwreply(*hdr, FW_RSP_LOAD_APP_FLASH, rsp);
|
||||||
|
|
||||||
|
state = FW_STATE_LOAD_APP_FLASH;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
htif_puts("Got unknown firmware cmd: 0x");
|
htif_puts("Got unknown firmware cmd: 0x");
|
||||||
htif_puthex(cmd[0]);
|
htif_puthex(cmd[0]);
|
||||||
|
@ -421,8 +429,6 @@ int main(void)
|
||||||
/*@+mustfreeonly@*/
|
/*@+mustfreeonly@*/
|
||||||
ctx.use_uss = false;
|
ctx.use_uss = false;
|
||||||
|
|
||||||
readbyte();
|
|
||||||
|
|
||||||
scramble_ram();
|
scramble_ram();
|
||||||
|
|
||||||
part_table_read(&part_table);
|
part_table_read(&part_table);
|
||||||
|
@ -447,6 +453,23 @@ int main(void)
|
||||||
state = loading_commands(&hdr, cmd, state, &ctx);
|
state = loading_commands(&hdr, cmd, state, &ctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FW_STATE_LOAD_APP_FLASH:
|
||||||
|
if (preload_start(&part_table) == -1) {
|
||||||
|
state = FW_STATE_FAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*app_size = part_table.pre_app_data.size;
|
||||||
|
|
||||||
|
int digest_err = compute_app_digest(ctx.digest);
|
||||||
|
assert(digest_err == 0);
|
||||||
|
print_digest(ctx.digest);
|
||||||
|
ctx.use_uss = false;
|
||||||
|
|
||||||
|
state = FW_STATE_RUN;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case FW_STATE_RUN:
|
case FW_STATE_RUN:
|
||||||
run(&ctx);
|
run(&ctx);
|
||||||
break; // This is never reached!
|
break; // This is never reached!
|
||||||
|
|
|
@ -108,6 +108,10 @@ void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf)
|
||||||
len = LEN_32;
|
len = LEN_32;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FW_RSP_LOAD_APP_FLASH:
|
||||||
|
len = LEN_1;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
htif_puts("fwreply(): Unknown response code: 0x");
|
htif_puts("fwreply(): Unknown response code: 0x");
|
||||||
htif_puthex(rspcode);
|
htif_puthex(rspcode);
|
||||||
|
|
|
@ -37,6 +37,8 @@ enum fwcmd {
|
||||||
FW_CMD_GET_UDI = 0x08,
|
FW_CMD_GET_UDI = 0x08,
|
||||||
FW_RSP_GET_UDI = 0x09,
|
FW_RSP_GET_UDI = 0x09,
|
||||||
FW_CMD_MAX = 0x0a,
|
FW_CMD_MAX = 0x0a,
|
||||||
|
FW_CMD_LOAD_APP_FLASH = 0xF0,
|
||||||
|
FW_RSP_LOAD_APP_FLASH = 0xF1,
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ enum state {
|
||||||
FW_STATE_LOADING,
|
FW_STATE_LOADING,
|
||||||
FW_STATE_RUN,
|
FW_STATE_RUN,
|
||||||
FW_STATE_FAIL,
|
FW_STATE_FAIL,
|
||||||
|
FW_STATE_LOAD_APP_FLASH,
|
||||||
FW_STATE_MAX,
|
FW_STATE_MAX,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue