Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@

[![ci](https://github.com/tillitis/tkey-devtools/actions/workflows/ci.yaml/badge.svg?branch=main&event=push)](https://github.com/tillitis/tkey-devtools/actions/workflows/ci.yaml)

# tkey-tools
# tkey-devtools

This repository contains some development tools for the
[Tillitis](https://tillitis.se/) TKey USB security stick.
Some development tools for the [Tillitis](https://tillitis.se/) TKey
USB security stick.

- `tkey-runapp`: A simple development tool to load and start any TKey
device app.

- `run-tkey-qemu`: Script around our
[TKey emulator](https://github.com/tillitis/qemu) OCI image
`ghcr.io/tillitis/tkey-qemu-tk1-23.03.1`.
- Source to build and run OCI images for apps development in C
(device) and Go (client): tkey-app-builder. See `contrib`.

- Source to build an OCI image of the QEMU-based [TKey
emulator](https://github.com/tillitis/qemu). See `contrib`.

- `run-tkey-qemu`: A script to run the above in a container and export
the the serial port as a pty outside the container.

See the [TKey Developer Handbook](https://dev.tillitis.se/) for how to
develop your own apps, how to run and debug them in the emulator or on
Expand All @@ -35,23 +39,18 @@ $ make
If you want to use podman and you have `make` you can run:

```
$ podman pull ghcr.io/tillitis/tkey-builder:2
$ podman pull ghcr.io/tillitis/tkey-builder
$ make podman
```

or run podman directly with

```
$ podman run --rm --mount type=bind,source=.,target=/src -w /src -it ghcr.io/tillitis/tkey-builder:2 make -j
```

To install:
To install under Linux:

```
sudo make install
```

If you want to reload the udev rules to access the TKey use:
Note that this installs Linux udev rules to enable you to access the
TKey. If you want to reload the udev rules to access the TKey use:

```
sudo make reload-rules
Expand Down
49 changes: 49 additions & 0 deletions contrib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (C) 2022, 2023 - Tillitis AB
# SPDX-License-Identifier: GPL-2.0-only

# image produced by build-image targets
BUILDQEMUIMAGE=qemu-local
BUILDAPPIMAGE=tkey-app-builder-local

# default images used when running a container
APPIMAGE=tkey-app-builder-local
EMUIMAGE=ghcr.io/tillitis/tkey-qemu-tk1-23.03.1

help: all

all:
@echo "Targets:"
@echo "run-app Run a shell using image '$(APPIMAGE)' for app development"
@echo "pull-app Pull down the image '$(APPIMAGE)'"
@echo "build-app-image Build a development image named '$(BUILDAPPIMAGE)'"
@echo " A newly built image can be used like: make IMAGE=$(BUILDAPPIMAGE) run"


@echo "run-emu Run a shell using image '$(EMUIMAGE)' for the TKey emulator"
@echo "pull-emu Pull down the image '$(EMUIMAGE)'"
@echo "build-emu-image Build a toolchain image named '$(BUILDEMUIMAGE)'"
@echo " A newly built image can be used like: make IMAGE=$(BUILDEMUIMAGE) run"

.PHONY: run-app
run-app:
podman run --rm --mount type=bind,source="`pwd`/../",target=/build -w /build -it $(BUILDAPPIMAGE)

.PHONY: pull-app
pull-app:
podman pull $(APPIMAGE)

.PHONY: build-app-image
build-app-image:
podman build -t $(BUILDAPPIMAGE) -f tkey-app-builder.dockerfile

.PHONY: run-emu
run-emu:
podman run --rm --mount type=bind,source="`pwd`/../",target=/build -w /build -it $(EMUIMAGE)

.PHONY: pull-emu
pull-emu:
podman pull $(EMUIMAGE)

.PHONY: build-emu-image
build-emu-image:
podman build -t $(EMUIMAGE) -f tkey-qemu.dockerfile
12 changes: 12 additions & 0 deletions contrib/tkey-app-builder.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2024 Tillitis AB
# SPDX-License-Identifier: GPL-2.0-only

FROM alpine:3.20

RUN apk add --no-cache \
clang \
clang-extra-tools \
go \
lld \
llvm \
make
29 changes: 15 additions & 14 deletions tkey-qemu.dockerfile → contrib/tkey-qemu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
# Copyright (C) 2023 Tillitis AB
# SPDX-License-Identifier: GPL-2.0-only

# This is the tag in the https://github.com/tillitis/tillitis-key1 repo with
# the firmware that our TKey/QEMU will run. The published tkey-qemu image will
# have this as part of its name, the tag is then used for versioning the image
# (could be updates to the TKey QEMU machine).
ARG TKEYREPO_TAG=TK1-23.03.1
ARG TKEYREPO_TAG=TK1-23.03.2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could be the current release version?

Suggested change
ARG TKEYREPO_TAG=TK1-23.03.2
ARG TKEYREPO_TAG=TK1-24.03


# This is what we'll actually checkout when building the firmware. It
# really is the firmware as of the TK1-tag above, but a couple of
# commits later where the firmware checksum was committed!
ARG TKEYREPO_TREEISH=444ee3d26c3acf651ff1bbb12023034ccee6ed68
#ARG TKEYREPO_TREEISH=444ee3d26c3acf651ff1bbb12023034ccee6ed68

# Using tkey-builder image for building since it has the deps.
FROM ghcr.io/tillitis/tkey-builder:2 AS builder
#FROM ghcr.io/tillitis/tkey-builder:2 AS builder
FROM tkey-app-builder-local AS builder

ARG TKEYREPO_TREEISH

# Cleaning up /usr/local since we will later COPY all from there
RUN rm -rf \
/usr/local/bin/* \
/usr/local/pico-sdk \
/usr/local/repo-commit-* \
/usr/local/share/icebox \
/usr/local/share/yosys
RUN apk add --no-cache \
bash \
git \
glib-dev \
ninja \
python3 \
py3-virtualenv

RUN git clone -b tk1 --depth=1 https://github.com/tillitis/qemu /src/qemu \
&& mkdir /src/qemu/build
WORKDIR /src/qemu/build
RUN ../configure --target-list=riscv32-softmmu --disable-werror \
&& make -j "$(nproc --ignore=2)" \
&& make -j "$(nproc --ignore=2)" qemu-system-riscv32 \
&& make install \
&& git >/usr/local/repo-commit-tillitis--qemu describe --all --always --long --dirty

RUN git clone https://github.com/tillitis/tillitis-key1 /src/tkey
WORKDIR /src/tkey/hw/application_fpga
# QEMU needs the .elf, but we build .bin to check sum
RUN git checkout ${TKEYREPO_TREEISH} \
RUN git checkout ${TKEYREPO_TAG} \
&& make firmware.bin && sha512sum -c firmware.bin.sha512 \
&& make firmware.elf && cp -af firmware.elf firmware-noconsole.elf \
&& make clean \
Expand Down
1 change: 0 additions & 1 deletion tools/spdx-ensure
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ missingok_files=(
LICENSE
Makefile
README.md
tkey-qemu.dockerfile
go.mod
go.sum
gon.hcl
Expand Down
Loading