435 Commits

Author SHA1 Message Date
Michael Cardell Widerkrantz
98f852b27b
fw: testloadapp: Add reset to client loading 2025-04-11 09:37:55 +02:00
Michael Cardell Widerkrantz
dc9f2c6750
fw: Simplify state machine
- Remove state FW_STATE_CDI.
- Add CDI calculation to FW_STATE_START.
- Go directly to FW_STATE_START from both _LOAD_FLASH and _LOADING.
2025-04-11 09:37:55 +02:00
Michael Cardell Widerkrantz
557031aadc
fw: Re-arrange check for free app slot
- Check explicitly for free app slot. Remove function call.
- Add checks for slot number overflow to preload_store().
2025-04-11 09:37:55 +02:00
Michael Cardell Widerkrantz
9608c95931
fw: Pass length of next_app_data to syscall reset 2025-04-11 09:37:54 +02:00
Mikael Ågren
6d76bdeafd
fw: Read pre loaded app 0 size from flash 2025-04-11 09:37:54 +02:00
Mikael Ågren
da275acebc
Optionally add size of pre loaded app 0 when generating partition table 2025-04-11 09:37:54 +02:00
Michael Cardell Widerkrantz
8347ae7c8e
fw: Add status syscall for flash status
Add a way of reporting invalid partition table copy through a new
syscall for TKey status.
2025-04-11 09:37:53 +02:00
Michael Cardell Widerkrantz
e1d25f6d74
fw: Indicate which partition table used by return value when reading
- Return 0: Slot 0 used.
- Return 1: Slot 1 used, indicating slot 0 broken!
2025-04-11 09:37:53 +02:00
Michael Cardell Widerkrantz
2eee630649
fw: Load default partition table image when installing preloaded app 2025-04-11 09:37:53 +02:00
Michael Cardell Widerkrantz
4c29de23dc
Update length and digest of testloadapp 2025-04-11 09:37:52 +02:00
Michael Cardell Widerkrantz
1636b40c71
fw: Implement redundancy of partition table 2025-04-11 09:37:52 +02:00
Michael Cardell Widerkrantz
03625b312d
Remove commented out code about creating partition table 2025-04-11 09:37:51 +02:00
Mikael Ågren
f24c7ea515
fw: Add checksum to partition table
Refuse to boot if blake2s digest over the partition table does not match
digest stored on flash
2025-04-11 09:37:51 +02:00
Michael Cardell Widerkrantz
75dd726998
tool: Introduce b2s tool to help compute BLAKE2s digests 2025-04-11 09:37:51 +02:00
Mikael Ågren
caa06dcc4a
testapp: Fix illegal TK1_SYSCALL_RESET call 2025-04-11 09:37:50 +02:00
Mikael Ågren
fba6e04c7f
fw: Only allow sector aligned erase ops 2025-04-11 09:37:50 +02:00
Mikael Ågren
930d204e9f
fw: Remove storage area address and size from partition table
Instead we calculate start addresses from area index and use fixed size.
2025-04-11 09:37:50 +02:00
Mikael Ågren
b837eec9e6
fw: Remove TK1_SYSCALL_REG_MGMT
Validate preload API access using the fixed, pre-calculated app digest
instead of letting an app register itself as a management app.
2025-04-11 09:37:49 +02:00
Mikael Ågren
715d792d86
fw: Remove pre loaded app auth and status from partition table 2025-04-11 09:37:49 +02:00
Mikael Ågren
f590f423a3
Add tool to inspect partition table dump 2025-04-11 09:37:49 +02:00
Michael Cardell Widerkrantz
29638a99a0
fw: Only allow a specific app to start from first flash
Store size and app digest in ROM and compare to what we are booting.
2025-04-11 09:37:48 +02:00
Mikael Ågren
d9a9e22074
testloadapp: Delete any existing preloaded app before installing 2025-04-11 09:37:48 +02:00
Mikael Ågren
ff472b0c1f
WIP: verify pre loaded app 2 2025-04-11 09:37:48 +02:00
Mikael Ågren
76b7ba7d73
testloadapp: Use blake2s from tkey-libs 2025-04-11 09:37:47 +02:00
Mikael Ågren
ea6b755699
Add tool to create a flash image containing a preloaded app at slot 0 2025-04-11 09:37:47 +02:00
Mikael Ågren
12916f9736
Do not hardcode preloaded app 1 size
Hardcoding it causes preload_check_valid_app and therefore preload_store
to assume there already is an app installed. Causing the
TK1_SYSCALL_PRELOAD_STORE syscall to fail.
2025-04-11 09:37:47 +02:00
Mikael Ågren
04d54c9396
Add QEMU_SYSCALL to enable Qemu syscalls
Enable Qemu syscall handling by defining QEMU_SYSCALL instead of
QEMU_DEBUG. That way we can select either or.
2025-04-11 09:37:46 +02:00
Michael Cardell Widerkrantz
7cd1f03933
Add start of test app for installing and verifying flash app
Currently needs LIBDIR set to tkey-libs with blake2s().
2025-04-11 09:37:46 +02:00
Mikael Ågren
099fe46e1f
Do note delete or corrupt preloaded app 0 when storing preloaded app 1 2025-04-11 09:37:46 +02:00
Mikael Ågren
90da452f80
Delete app digest and signature when preloaded app is deleted 2025-04-11 09:37:45 +02:00
Mikael Ågren
9018ae5b33
Store app digest and signature for each app slot 2025-04-11 09:37:45 +02:00
Michael Cardell Widerkrantz
93a49f50c2
Introduce syscalls to change preloaded app
Introduce syscalls:

- TK1_SYSCALL_PRELOAD_STORE
- TK1_SYSCALL_PRELOAD_STORE_FIN
- TK1_SYSCALL_PRELOAD_DELETE
- TK1_SYSCALL_REG_MGMT = 11

Change preload_store_finalize() not to take USS arg. Unused for
preloaded apps.
2025-04-11 09:37:45 +02:00
Mikael Ågren
ac5c2aef86
fw: Add second pre-loaded app slot in flash 2025-04-11 09:37:44 +02:00
Mikael Ågren
1c4d11f49e
fw: When requested, verify app digest before running 2025-04-11 09:37:44 +02:00
Mikael Ågren
e4028d9a86
Handle reset info in reset syscall
Disabling debug printouts to get firmware to fit in ROM
2025-04-11 09:37:44 +02:00
Jonas Thörnblad
ba211212f0
Add resetinfo testapp
Co-authored-by: Mikael Ågren <mikael@tillitis.se>
Co-authored-by: Michael Cardell Widerkrantz <mc@tillitis.se>
2025-04-11 09:37:43 +02:00
Michael Cardell Widerkrantz
ba9e08fcdb
Add resetinfo handling
Decide where to start from with data from resetinfo part of FW_RAM.

Co-authored-by: Jonas Thörnblad <jonas@tillitis.se>
Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-04-11 08:43:41 +02:00
Michael Cardell Widerkrantz
76b25bc121
Document state machine
Golden path not updated
2025-04-11 08:43:41 +02:00
Michael Cardell Widerkrantz
ab12c201c4
Experiment with new state machine 2025-04-11 08:43:41 +02:00
Michael Cardell Widerkrantz
6ef1b1c659
Experiment with state machine when starting from flash
- Move around code to start an app from flash.
- Mark experimental stuff and debug stuff more clearly.
2025-04-11 08:43:40 +02:00
Michael Cardell Widerkrantz
9316886c88
Introduce symbolic names for present and present & authenticated
A preloaded app can be:

- present and not yet authenticated (0x01)
- present and authenticated (0x02)

Let's use symbolic names for these.
2025-04-11 08:43:40 +02:00
Michael Cardell Widerkrantz
a20bcdab29
Make run_flash() and run() both call jump_to_app() 2025-04-11 08:43:40 +02:00
Michael Cardell Widerkrantz
820c273e7f
Add hardcoded preloaded app size
- Enable TKEY_DEBUG
- Wait for something on CDC before continuing
2025-04-11 08:43:39 +02:00
Mikael Ågren
a1acbe7cd7
Add script to load pre-loaded app into flash 2025-04-08 11:01:00 +02:00
Mikael Ågren
c273727c7b
fw: Replace custom picorv32 instructions in qemu target 2025-04-08 11:00:59 +02:00
Michael Cardell Widerkrantz
f2b78be4cb
Add start of pre-loaded app from flash
Based on earlier code by Daniel Jobson <jobson@tillitis.se> now
integrated into the new world order.

Co-authored-by: Mikael Ågren <mikael@tillitis.se>
Co-authored-by: Daniel Jobson <jobson@tillitis.se>
2025-04-08 11:00:59 +02:00
Michael Cardell Widerkrantz
20b008d20e
Add filesystem code and storage syscalls
Adds syscalls:

- ALLOCATE_AREA
- DEALLOCATE_AREA
- WRITE_DATA
- READ_DATA

and code to access the filesystem and the flash over SPI.

Based on original work by Daniel Jobson <jobson@tillitis.see> for
these files:

- auth_app.[ch]
- flash.[ch]
- spi.[ch]
- partition_table.[ch]
- rng.[ch]
- storage.[ch]

which are used with small changes to integrate with the new syscall
method.

Co-authored-by: Daniel Jobson <jobson@tillitis.se>
Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-04-08 11:00:59 +02:00
Michael Cardell Widerkrantz
bd2df9bd3f
Update firmware state machine
Include flash apps and states in firmware state machine description
and diagram.
2025-04-08 11:00:58 +02:00
Michael Cardell Widerkrantz
3ef1dade37
Clarify golden path
- Clarify what the default behaviour is.
- Clarify when we should halt CPU.
- Move common things when booting from flash and UART to its own
  section.
2025-04-08 11:00:58 +02:00
Michael Cardell Widerkrantz
aa9335691f
doc: Add description on how firmware starts app from flash
A first attempt at describing how to start an app from flash and how
to handle information left in resetinfo from the previous app in the
chain.
2025-04-08 11:00:54 +02:00