mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-07-22 14:40:56 -04:00
fw/defaultapp: Introduce simple default app
To retain the default behaviour from Bellatrix, we introduce a simple default app. If used on flash app slot 0 we get the same behaviour as in Bellatrix, that is, waiting for an app from the client.
This commit is contained in:
parent
d83d659284
commit
8cf2cd08b7
3 changed files with 95 additions and 0 deletions
|
@ -794,6 +794,9 @@ $ picocom /dev/ttyACM1
|
||||||
|
|
||||||
or similar.
|
or similar.
|
||||||
|
|
||||||
|
- `fw/defaultapp`: Immediately resets the TKey with the intention to
|
||||||
|
start an app from the client, replicating the behaviour of earlier
|
||||||
|
generations.
|
||||||
- `fw/testapp`: Runs through a couple of tests that are now impossible
|
- `fw/testapp`: Runs through a couple of tests that are now impossible
|
||||||
to do in the `testfw`.
|
to do in the `testfw`.
|
||||||
- `fw/reset_test`: Interactively test different reset scenarios.
|
- `fw/reset_test`: Interactively test different reset scenarios.
|
||||||
|
|
73
hw/application_fpga/fw/defaultapp/Makefile
Normal file
73
hw/application_fpga/fw/defaultapp/Makefile
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
P := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
|
LIBDIR ?= ../../tkey-libs
|
||||||
|
OBJCOPY ?= llvm-objcopy
|
||||||
|
CC = clang
|
||||||
|
CFLAGS = \
|
||||||
|
-target riscv32-unknown-none-elf \
|
||||||
|
-march=rv32iczmmul \
|
||||||
|
-mabi=ilp32 \
|
||||||
|
-mcmodel=medany \
|
||||||
|
-static \
|
||||||
|
-std=gnu99 \
|
||||||
|
-Os \
|
||||||
|
-ffast-math \
|
||||||
|
-fno-common \
|
||||||
|
-fno-builtin-printf \
|
||||||
|
-fno-builtin-putchar \
|
||||||
|
-fno-builtin-memcpy \
|
||||||
|
-nostdlib \
|
||||||
|
-mno-relax \
|
||||||
|
-Wall \
|
||||||
|
-Wpedantic \
|
||||||
|
-Wno-language-extension-token \
|
||||||
|
-Werror \
|
||||||
|
-flto \
|
||||||
|
-g \
|
||||||
|
-I $(LIBDIR)/include \
|
||||||
|
-I $(LIBDIR)
|
||||||
|
|
||||||
|
AS = clang
|
||||||
|
|
||||||
|
ASFLAGS = \
|
||||||
|
-target riscv32-unknown-none-elf \
|
||||||
|
-march=rv32iczmmul \
|
||||||
|
-mabi=ilp32 \
|
||||||
|
-mno-relax
|
||||||
|
|
||||||
|
LDFLAGS = \
|
||||||
|
-T $(LIBDIR)/app.lds \
|
||||||
|
-L $(LIBDIR) -lcrt0 -lcommon -lmonocypher -lblake2s
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: defaultapp.bin
|
||||||
|
|
||||||
|
# Turn elf into bin for device
|
||||||
|
%.bin: %.elf
|
||||||
|
$(OBJCOPY) --input-target=elf32-littleriscv --output-target=binary $^ $@
|
||||||
|
chmod a-x $@
|
||||||
|
|
||||||
|
.PHONY: tkey-libs
|
||||||
|
tkey-libs:
|
||||||
|
make -C $(LIBDIR)
|
||||||
|
|
||||||
|
DEFAULTAPP_FMTFILES = *.[ch]
|
||||||
|
|
||||||
|
DEFAULTAPP_OBJS = \
|
||||||
|
$(P)/main.o \
|
||||||
|
../testapp/syscall.o \
|
||||||
|
|
||||||
|
defaultapp.elf: tkey-libs $(DEFAULTAPP_OBJS)
|
||||||
|
$(CC) $(CFLAGS) $(DEFAULTAPP_OBJS) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
clang-format --dry-run --ferror-limit=0 $(DEFAULTAPP_FMTFILES)
|
||||||
|
clang-format --verbose -i $(DEFAULT_FMTFILES)
|
||||||
|
|
||||||
|
.PHONY: checkfmt
|
||||||
|
checkfmt:
|
||||||
|
clang-format --dry-run --ferror-limit=0 --Werror $(DEFAULT_FMTFILES)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -f defaultapp.* $(DEFAULTAPP_OBJS)
|
19
hw/application_fpga/fw/defaultapp/main.c
Normal file
19
hw/application_fpga/fw/defaultapp/main.c
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (C) 2025 - Tillitis AB
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
#include <tkey/debug.h>
|
||||||
|
#include <tkey/led.h>
|
||||||
|
|
||||||
|
#include "../testapp/syscall.h"
|
||||||
|
#include "../tk1/reset.h"
|
||||||
|
#include "../tk1/syscall_num.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
struct reset rst = {0};
|
||||||
|
|
||||||
|
led_set(LED_BLUE);
|
||||||
|
|
||||||
|
rst.type = START_CLIENT;
|
||||||
|
syscall(TK1_SYSCALL_RESET, (uint32_t)&rst, 0, 0);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue