From 1be5140850575eb69a37ce5671744e4697da685d Mon Sep 17 00:00:00 2001 From: Michael Cardell Widerkrantz Date: Tue, 8 Apr 2025 13:30:05 +0200 Subject: [PATCH] tkey-libs: Optimize for size Optimize tkey-libs for size to fit firmware in ROM --- README.md | 12 +++++++++++- hw/application_fpga/tkey-libs/Makefile | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d182e7..9cd4878 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,17 @@ official version tag. Easiest is probably to just remove the tkey-libs directory and then git clone the desired tag. Use the entire repo, but remove the .-files -like `.git`, `.github`, et cetera. +like `.git`, `.github`, et cetera. Something like: + +``` +$ rm -rf tkey-libs +$ git clone git@github.com:tillitis/tkey-libs.git +$ cd tkey-libs +$ git checkout fw-3 +``` + +Note that you need to change the optimization flag in the tkey-libs' +Makefile to `-Os`. ## Measured boot diff --git a/hw/application_fpga/tkey-libs/Makefile b/hw/application_fpga/tkey-libs/Makefile index 3c1cdf5..9dea0d9 100644 --- a/hw/application_fpga/tkey-libs/Makefile +++ b/hw/application_fpga/tkey-libs/Makefile @@ -17,7 +17,7 @@ INCLUDE=include # either of them. You don't need to recompile tkey-libs. CFLAGS = -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 \ - -mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common \ + -mcmodel=medany -static -std=gnu99 -Os -ffast-math -fno-common \ -fno-builtin-printf -fno-builtin-putchar -nostdlib -mno-relax -flto \ -Wall -Werror=implicit-function-declaration \ -I $(INCLUDE) -I .