首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >U-Boot:尝试包含TPM头文件时出现编译错误

U-Boot:尝试包含TPM头文件时出现编译错误
EN

Stack Overflow用户
提问于 2021-11-07 07:54:48
回答 1查看 31关注 0票数 0

我正在尝试在FIT Image签名验证流程中使用几个TPM。出于同样的原因,我尝试通过以下方式包含TPM头文件:我正在使用Master Branch。

代码语言:javascript
复制
diff --git a/common/image-fit-sig.c b/common/image-fit-sig.c
index 63e5423c92..529da516cc 100644
--- a/common/image-fit-sig.c
+++ b/common/image-fit-sig.c
@@ -18,6 +18,9 @@ DECLARE_GLOBAL_DATA_PTR;
 #include <u-boot/rsa.h>
 #include <u-boot/hash-checksum.h>
 
+#include <tpm-common.h>
+#include <tpm-v2.h>
+
 #define IMAGE_MAX_HASHED_NODES         100
 
 /**

但是,在编译时,我得到以下错误:

代码语言:javascript
复制
$ make -j$(nproc) CROSS_COMPILE=aarch64-linux-gnu- all
UPD     include/generated/timestamp_autogenerated.h
  CFGCHK  u-boot.cfg
  HOSTCC  tools/aisimage.o
  HOSTCC  tools/atmelimage.o
  HOSTCC  tools/fit_image.o
  HOSTCC  tools/fit_common.o
  HOSTCC  tools/image-host.o
  HOSTCC  tools/common/image-fit.o
  HOSTCC  tools/image-sig-host.o
  HOSTCC  tools/common/image-fit-sig.o
  HOSTCC  tools/common/image-cipher.o
In file included from ./tools/../common/image-fit-sig.c:21,
                 from tools/common/image-fit-sig.c:1:
include/tpm-common.h:66:2: error: unknown type name ‘u8’
   66 |  u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)];  /* Max buffer size + addr */
      |  ^~
include/tpm-common.h:66:34: error: ‘u8’ undeclared here (not in a function)
   66 |  u8 buf[TPM_DEV_BUFSIZE + sizeof(u8)];  /* Max buffer size + addr */
      |                                  ^~
include/tpm-common.h:131:44: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
  131 |  int (*send)(struct udevice *dev, const u8 *sendbuf, size_t send_size);
      |                                            ^
include/tpm-common.h:144:35: error: expected declaration specifiers or ‘...’ before ‘u8’
  144 |  int (*recv)(struct udevice *dev, u8 *recvbuf, size_t max_size);
      |                                   ^~
include/tpm-common.h:173:44: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
  173 |  int (*xfer)(struct udevice *dev, const u8 *sendbuf, size_t send_size,
      |                                            ^
include/tpm-common.h:259:44: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
  259 | int tpm_xfer(struct udevice *dev, const u8 *sendbuf, size_t send_size,
      |                                            ^
In file included from ./tools/../common/image-fit-sig.c:22,
                 from tools/common/image-fit-sig.c:1:
include/tpm-v2.h:117:2: error: unknown type name ‘u16’
  117 |  u16 hash;
      |  ^~~
include/tpm-v2.h:118:2: error: expected specifier-qualifier-list before ‘u8’
  118 |  u8 size_of_select;
      |  ^~
include/tpm-v2.h:120:3: error: conflicting types for ‘__packed’
  120 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:126:3: error: conflicting types for ‘__packed’
  126 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:132:3: error: conflicting types for ‘__packed’
  132 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:142:3: error: conflicting types for ‘__packed’
  142 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:148:3: error: conflicting types for ‘__packed’
  148 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:162:2: error: expected specifier-qualifier-list before ‘u8’
  162 |  u8 digest[TPM2_SHA1_DIGEST_SIZE];
      |  ^~
include/tpm-v2.h:165:3: error: conflicting types for ‘__packed’
  165 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:171:2: error: expected specifier-qualifier-list before ‘u8’
  171 |  u8 sha1[TPM2_SHA1_DIGEST_SIZE];
      |  ^~
include/tpm-v2.h:176:3: error: conflicting types for ‘__packed’
  176 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:185:2: error: unknown type name ‘u16’
  185 |  u16 hash_alg;
      |  ^~~
include/tpm-v2.h:187:3: error: conflicting types for ‘__packed’
  187 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:198:3: error: conflicting types for ‘__packed’
  198 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:214:2: error: expected specifier-qualifier-list before ‘u8’
  214 |  u8 event[];
      |  ^~
include/tpm-v2.h:215:3: error: conflicting types for ‘__packed’
  215 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:113:3: note: previous declaration of ‘__packed’ was here
  113 | } __packed;
      |   ^~~~~~~~
include/tpm-v2.h:469:14: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
  469 |     const u8 *nv_policy, size_t nv_policy_size);
      |              ^
include/tpm-v2.h:483:16: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
  483 |       const u8 *digest, u32 digest_len);
      |                ^
make[1]: *** [scripts/Makefile.host:112: tools/common/image-fit-sig.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1804: tools] Error 2

似乎可以通过添加类型定义来绕过'u8‘和'u16’,但是我不确定像lib/tpm-v2.c和lib/tpm_api.c这样的文件如何包含这些头文件而不出现编译错误。

如果我在上面的内容中遗漏了一些微不足道的东西,或者我如何才能包含tpm-v2头文件,请告诉我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-07 14:41:18

一些文件,如common/image-fit-sig.c,在U-Boot本身和我们的运行在主机上的工具之间共享。在这些情况下,当添加新代码/头文件时,需要格外小心。您需要在文件顶部的非USE_HOSTCC用例下添加这些头文件,并且您的代码也需要在后面和#ifdef后面。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69870655

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档