Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation on embedded platforms #2676

Merged

Conversation

AndreasFuchsTPM
Copy link
Member

@AndreasFuchsTPM AndreasFuchsTPM commented Aug 8, 2023

Fixes: #2692

The use of uint32_t require %PRIx32 instead of %x on
non-32-bit-platforms.
Changed the FormatStrings accordingly for ESYS, MU and RC.
Missing FAPI and tests.

Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
@AndreasFuchsTPM AndreasFuchsTPM force-pushed the fix_formatstrings branch 2 times, most recently from 71195ed to 80bfebf Compare August 8, 2023 09:20
@wxleong
Copy link
Member

wxleong commented Sep 27, 2023

Could you please update the configure.ac and Makefile.am so that it's possible to exclude libutilio from the build? This is essential because embedded platforms are unable to build libutilio.

I have tested the following on your fork (AndreasFuchsTPM:fix_formatstrings) and it builds ok:

diff --git a/Makefile.am b/Makefile.am
index 03c5340d..12de494f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -249,9 +249,11 @@ libutil = libutil.la
 noinst_LTLIBRARIES += $(libutil)
 libutil_la_SOURCES = $(UTIL_SRC)
 
+if ENABLE_UTIL_IO
 libutilio = libutil-io.la
 noinst_LTLIBRARIES += $(libutilio)
 libutil_io_la_SOURCES = $(UTIL_IO_SRC)
+endif
 
 ### TCG TSS Marshaling/Unmarshaling spec library ###
 libtss2_mu = src/tss2-mu/libtss2-mu.la
diff --git a/configure.ac b/configure.ac
index f198bb96..717dcef8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -226,6 +226,13 @@ AC_CHECK_LIB([curl], [curl_url_strerror], [AC_DEFINE([HAVE_CURL_URL_STRERROR],[1
 AS_IF([test "x$enable_fapi" = xyes -o "x$enable_policy" = xyes ],
       [PKG_CHECK_MODULES([UUID], [uuid])])
 
+AC_ARG_ENABLE([util-io],
+              [AS_HELP_STRING([--disable-util-io],
+              [don't build the util-io])],,
+              [enable_util_io=yes])
+
+AM_CONDITIONAL(ENABLE_UTIL_IO, test "x$enable_util_io" = "xyes")
+
 AC_ARG_WITH([tctidefaultmodule],
             [AS_HELP_STRING([--with-tctidefaultmodule],
 [The default TCTI module for ESYS. (Default: libtss2-tcti-default.so)])],

AndreasFuchsTPM and others added 5 commits October 10, 2023 11:22
In order to allow building on embedded platforms (without any
TCTIs) the IO functions from util have been separated out into
their own library

Co-authored-by: wenxin.leong <wenxin.leong@infineon.com>
Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
Instead of relying on the endian.h functions (which are not
available on all platforms) use the tss2_engian.h file which
includes also a customer implementation.

Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
tctildr (dl and nodl) will attempt to load some tctis in a certain
order by default. If the project is compiled without said tctis, it
would fail so far.
Fix this and provide a runtime error instead of compile time.

Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #2676 (80bfebf) into master (86949f7) will decrease coverage by 0.01%.
Report is 4 commits behind head on master.
The diff coverage is 92.30%.

❗ Current head 80bfebf differs from pull request most recent head 8276939. Consider uploading reports for the commit 8276939 to get more accurate results

@@            Coverage Diff             @@
##           master    #2676      +/-   ##
==========================================
- Coverage   82.54%   82.54%   -0.01%     
==========================================
  Files         368      368              
  Lines       42941    42941              
==========================================
- Hits        35447    35445       -2     
- Misses       7494     7496       +2     
Files Coverage Δ
src/tss2-esys/api/Esys_StartAuthSession.c 95.28% <ø> (ø)
src/tss2-esys/esys_iutil.c 87.01% <100.00%> (ø)
src/tss2-esys/esys_tr.c 89.25% <ø> (ø)
src/tss2-mu/tpmu-types.c 74.03% <ø> (ø)
src/tss2-policy/tss2_policy.c 78.91% <ø> (ø)
src/tss2-sys/api/Tss2_Sys_Execute.c 77.14% <ø> (ø)
src/tss2-tcti/tcti-device.c 71.57% <ø> (ø)
src/tss2-tcti/tcti-i2c-ftdi.c 76.66% <ø> (ø)
src/tss2-tcti/tcti-i2c-helper.c 83.28% <100.00%> (ø)
src/tss2-tcti/tcti-pcap-builder.c 88.74% <ø> (ø)
... and 9 more

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@AndreasFuchsTPM
Copy link
Member Author

Could you please update the configure.ac and Makefile.am so that it's possible to exclude libutilio from the build? This is essential because embedded platforms are unable to build libutilio.

Updated

Copy link
Member

@wxleong wxleong left a comment

Choose a reason for hiding this comment

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

The Cirrus CI is failing due to the new usage limitations imposed on its free tier, read here

@AndreasFuchsTPM AndreasFuchsTPM merged commit d0632da into tpm2-software:master Oct 11, 2023
26 of 27 checks passed
@AndreasFuchsTPM AndreasFuchsTPM deleted the fix_formatstrings branch October 11, 2023 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does not compile on non-32-Bit embedded Platforms
2 participants