Commit graph

471 commits

Author SHA1 Message Date
Daniel Jobson
ea82b0c1fd Update application_fpga.bin.sha256 2025-10-28 08:40:06 +01:00
Daniel Jobson
1a47a2266f uart: Make CTS active low, as per the standard 2025-10-28 08:40:06 +01:00
Daniel Jobson
74e3d74c11 fpga: Update next-pnr seed to reach 24 MHz 2025-10-27 15:13:12 +01:00
Daniel Jobson
6104356892 tb: uart add framing error test
- Adds option to test invalid stop bit
- Adds a test that simulates an always low rx line
2025-10-27 08:54:34 +01:00
Daniel Jobson
395d241ed3 uart: add framing error handling
- Checks the stop bit, if it is not valid the data is discarded and
  enters a error state. Only checks first stop bit.
- Adds an error state to the RX FSM. The core starts in this state to
  not assume a valid idle rx line on start up. Prevents accepting
  frames on a constant low rx line and filling the fifo.
- bugfix: always reset bitrate_ctr when leaving state ERX_BITS and
  remove unused bitrate_ctr counter in ERX_STOP
2025-10-27 08:54:31 +01:00
Michael Cardell Widerkrantz
aa04cf068f
doc: Add LICENSE file for picorv32 custom ops 2025-09-02 11:09:15 +02:00
Michael Cardell Widerkrantz
34e9f0a314
tkey-libs: Import tag fw-5 of tkey-libs
Use tag fw-5 from https://github.com/tillitis/tkey-libs/
2025-09-02 11:09:12 +02:00
Michael Cardell Widerkrantz
17e5e77187
build: Always rebuild firmware if any header file changes 2025-09-01 18:19:54 +02:00
Michael Cardell Widerkrantz
18386b4865
build: Remove all built qemu artefacts when cleaning 2025-09-01 18:19:54 +02:00
Michael Cardell Widerkrantz
90a91ba1ba
build: Create and use a complete filesystem image
- Create a flash image in flash_image.bin, useful for both a real TKey
  and QEMU.

- Use flash_image.bin directly in prog_flash for a real TKey, which
  also flashes the bitstream.

- Remove building of tools/default_partition.bin.

- Update documentation about the tool use.

- We keep the load_preloaded_app.sh for development purposes,
  but it's no longer used in the build.
2025-09-01 18:19:54 +02:00
Michael Cardell Widerkrantz
65ff0a5d61
doc: Document the filesystem 2025-09-01 18:19:54 +02:00
Michael Cardell Widerkrantz
6fc4d264cc
build: Introduce DEFAULT_APP with automatic builds
Introduce the Makefile variable DEFAULT_APP which should be the path
to the device app binary to include in the obliagory slot 0.

Build automatically: the default app, the new digest file
mgmt_app_digest.h for the firmware which contains the digest of
DEFAULT_APP, the default partition table, and all the tools necessary
to generate this.
2025-09-01 18:19:54 +02:00
Michael Cardell Widerkrantz
d3492e2a34
tool: Change b2s to output exact variable used
- Use correct name.
- Don't declare it as static.
- Lose the toolchain
- Use only basename of path in the b2s comment
2025-09-01 18:19:53 +02:00
Jonas Thörnblad
13767ee7df
Add loopbackapp for app debugging using physical TKey with QEMU
This app takes data coming in on any of the normal USB endpoints
like CDC and FIDO (or CCID) and outputs the data on the DEBUG
endpoint.

Using the scripts (tkey_to_udp_linux.py, tkey_to_udp_win.py) in
QEMU (tk1 branch) under tools/tk1, the data from the DEBUG
endpoint can be read and sent over the network to the script
udp_to_qemu_linux.py that feeds it to QEMU.
2025-08-28 17:01:07 +02:00
Jonas Thörnblad
1926d19146
fw: Change loader app
- Change loader app from testloadapp to defaultapp
- Update default_partition.bin to contain defaultapp.bin
2025-08-22 15:11:01 +02:00
Jonas Thörnblad
1a904e8857
Fix allowed_app_digest formatting
Fix formating of BLAKE2s digest of app allowed to start from
flash slot 0.
2025-06-27 15:01:29 +02:00
Jonas Thörnblad
03d96c3e96
tool: Fix b2s BLAKE2s digest zero padding 2025-06-24 18:18:17 +02:00
Mikael Ågren
460d310c73
fw: Fix qemu_firmware build warnings 2025-06-19 08:50:13 +02:00
Michael Cardell Widerkrantz
f5d2cfef15
doc: Mention the tkeyimage tool in firmware README 2025-05-23 14:12:36 +02:00
Michael Cardell Widerkrantz
9a93da087d
doc: Document how to flash with filesystem 2025-05-23 14:12:36 +02:00
Mikael Ågren
e8acc7aee2
build: Flash partition table when running make prog_flash
Changes make targets:

- prog_flash in hw/application/Makefile which flashes only the
  bitstream is renamed to prog_flash_bs.

- prog_flash in hw/application/Makefile is modified to flash the
  bitstream, the testloadapp.bin in app slot 0, and the partition table.

- flash in contrib/Makefile is modified to use prog_flash from
  hw/application/Makefile
2025-05-22 15:24:45 +02:00
Mikael Ågren
4172db8dfb
build: Do not use sudo when running tillitis-iceprog 2025-05-22 15:06:39 +02:00
Mikael Ågren
7b1c1e5076
testapp: Update to 24 MHz clock 2025-05-22 09:31:54 +02:00
Michael Cardell Widerkrantz
1fec28ff0d
doc: Complete copyright and licenses
- Point out licensing terms in docs.
- Add missing SPDX tags
- Update the SPDX checker to check all the files we want to check.
- Include spdx-ensure in CI.
2025-05-22 09:31:54 +02:00
Mikael Ågren
07e487733b
build: Check app code formatting from application_fpga/Makefile 2025-05-22 09:31:54 +02:00
Michael Cardell Widerkrantz
ba17a2b29e
build: Use only one Makefile for apps
- Use one common Makefile for all test device apps.
- Use a single copy of syscall.[Sh].
- Update docs for building.
2025-05-22 09:31:50 +02:00
Michael Cardell Widerkrantz
6e3034c3ce
build: Move .clang-format to top level 2025-05-21 09:44:17 +02:00
Michael Cardell Widerkrantz
e302910f4d
Remove superfluous file __init__.py 2025-05-20 17:41:18 +02:00
Michael Cardell Widerkrantz
13641cb18b
build: Move test applications and the defaultapp
Instead of having the test apps under fw we create a new directory for
them.
2025-05-20 17:37:58 +02:00
Michael Cardell Widerkrantz
69940d2c64
doc: Link to firmware docs from TKey hardware design 2025-05-20 17:28:01 +02:00
Michael Cardell Widerkrantz
4ec58ce04c
tools: Prune and document tools
Add a tools/README.md.

Remove:

- create_flash_image.py: role now overtaken by tkeyimage which does
  more.
- reset-tk1: Leftover from when production_test was removed.

Rename:

- makehex.py: Moved up one level.
2025-05-20 17:12:46 +02:00
Michael Cardell Widerkrantz
a1f37d17c9
tool: Rename partition_table to tkeyimage 2025-05-20 13:50:55 +02:00
Michael Cardell Widerkrantz
fab126b695
tool: Add docs to partition_table
Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-05-20 13:50:55 +02:00
Michael Cardell Widerkrantz
9a17aa6bdb
tool: Add SPDX tag to partition_table 2025-05-20 13:50:55 +02:00
Michael Cardell Widerkrantz
0d6e1d9ba5
fw: Add debug print when reading partition table fails 2025-05-20 13:50:55 +02:00
Michael Cardell Widerkrantz
ea29843037
tool: Make partition_table able to produce flash file
Usage:

  ./partition_table -o flash.bin -f -app0 path/to/app

Will produce a flash.bin that can be used for qemu.

- Adjust the size of the partition table.
- Refactor and rename genPartitionFile().
2025-05-20 13:50:51 +02:00
Mikael Ågren
6afdc114b8
Update binary hashes for bitstream 2025-05-20 11:59:44 +02:00
Mikael Ågren
2556f61f5a
fpga: Bump tk1 core version to 6 2025-05-20 11:27:07 +02:00
Mikael Ågren
b144cdfbdb
fpga: Use Castor specific VID/PID in UDI
Allows an app to determine which type of device it is running on.

- Reserve vendor ID 0x7357 for people using Unlocked.
- Use Castor product ID.
- Serial number is just nonsense, as before.
2025-05-20 11:25:54 +02:00
Michael Cardell Widerkrantz
8965fea947
Reset USB controller endpoints when starting
When starting, reset the USB controller to only enable the USB CDC
endpoint and the internal command channel. If the app resets firmware,
but had differend endpoints enabled, we want to go back to a known
state.
2025-05-16 17:09:13 +02:00
Mikael Ågren
daa7807c0f
Update binary hashes for bitstream & firmware 2025-05-15 16:15:14 +02:00
Mikael Ågren
53bc2d5fa0
fw: Update flash_write_data() to handle sizes larger than 4096 bytes 2025-05-15 16:13:30 +02:00
Mikael Ågren
5a9b77806f
fw: Return 0 on sys_alloc success, -1 on error
It is left to the app to keep track of whether it has had access to the
allocated area before.
2025-05-15 16:13:30 +02:00
Mikael Ågren
887883c8db
fw: Allow last storage area sector to be erased 2025-05-15 16:13:29 +02:00
Mikael Ågren
2dce9828ea
Update binary hashes for bitstream & firmware 2025-05-15 14:14:52 +02:00
Mikael Ågren
a2b77ec348
fw: Return reset() return value in TK1_SYSCALL_RESET 2025-05-15 14:14:39 +02:00
Mikael Ågren
9a3b4b9dca
fw: Use sizeof(resetinfo->app_digest) instead of hardcoded value 2025-05-15 14:14:38 +02:00
Michael Cardell Widerkrantz
48108cb3a2
fw: Build qemu_firmware with different linker script
The qemu_firmware is too large for the real hardware's 8k of ROM. The
emulator, however, has lots of ROM. Use a different linker script for
to reflect this.
2025-05-15 14:03:04 +02:00
Michael Cardell Widerkrantz
e935195846
fw: Add syscall TK1_SYSCALL_GET_APP_DATA
Add a new syscall to enable an app to get the data left for it by the
previous app in chain.

- Change testloadapp to leave some data for the next app to read.
- Call system call with:

  uint8_t next_app_data[RESET_DATA_SIZE];

  syscall(TK1_SYSCALL_GET_APP_DATA, (uint32_t)next_app_data, 0, 0);
2025-05-15 14:03:04 +02:00
Jonas Thörnblad
ec9ef31140
doc: Fix endpoint info 2025-05-07 10:22:29 +02:00