tillitis-key/hw/application_fpga/fw/mta1_mkdf
Michael Cardell Widerkrantz 490571b6c0
Clear all RAM during start
Since SRAM has some data remanence even without power it seems good
hygien to clear all RAM when starting the device so as not to leak
potential sensitive data between device apps.
2022-10-24 11:52:52 +02:00
..
blake2s Pass the blake2s_ctx to blake2s() as arg 2022-10-18 14:51:26 +02:00
firmware.lds Make initial public release 2022-09-19 08:51:11 +02:00
lib.c Make initial public release 2022-09-19 08:51:11 +02:00
lib.h Make initial public release 2022-09-19 08:51:11 +02:00
main.c Use the new firmware-only RAM for CDI computation 2022-10-18 14:51:30 +02:00
Makefile Make fmt output changes that will be made 2022-09-21 10:13:39 +02:00
proto.c Receive USS and hash into CDI 2022-09-29 14:58:23 +02:00
proto.h Receive USS and hash into CDI 2022-09-29 14:58:23 +02:00
README.md Doc how qemu needs to be built; nits 2022-09-30 11:34:09 +02:00
start.S Clear all RAM during start 2022-10-24 11:52:52 +02:00
types.h Make initial public release 2022-09-19 08:51:11 +02:00

Tillitis Key firmware

Build the firmware

You need Clang with 32 bit RISC-V support. You can check this with:

$ llc --version | grep riscv32
    riscv32    - 32-bit RISC-V

or just try building.

Build the FPGA bitstream with the firmware using make in the hw/application_fpga directory.

If your available objcopy and size commands is anything other than the default llvm-objcopy-14 and llvm-size-14 define OBJCOPY and SIZE to whatever they're called on your system.

Using QEMU

Checkout the mta1 branch of our version of the qemu and build:

$ git clone -b mta1 https://github.com/tillitis/qemu
$ mkdir qemu/build
$ cd qemu/build
$ ../configure --target-list=riscv32-softmmu --disable-werror
$ make -j $(nproc)

(Built with warnings-as-errors disabled, see this issue.)

Run it like this:

$ /path/to/qemu/build/qemu-system-riscv32 -nographic -M mta1_mkdf,fifo=chrid -bios firmware.elf \
  -chardev pty,id=chrid

This attaches the FIFO to a tty, something like /dev/pts/16 which you can use with host software to talk to the firmware.

To quit QEMU you can use: Ctrl-a x (see Ctrl-a ? for other commands).

Debugging? Use the HTIF console by removing -DNOCONSOLE from the CFLAGS and using the helper functions in lib.c for printf-like debugging.

You can also use the qemu monitor for debugging, e.g. info registers, or run qemu with -d in_asm or -d trace:riscv_trap.

Happy hacking!