Skip to content

Commit 2d64093

Browse files
authored
Merge pull request #351 from gojimmypi/PR-Espressif
Initial Infineon I2C TPM support for Espressif ESP32
2 parents 705c29d + 5aff694 commit 2d64093

21 files changed

Lines changed: 3238 additions & 2 deletions

IDE/Espressif/CMakeLists.txt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# wolfTPM Espressif Example Project CMakeLists.txt
2+
# v1.0
3+
#
4+
# The following lines of boilerplate have to be in your project's
5+
# CMakeLists in this exact order for cmake to work correctly
6+
cmake_minimum_required(VERSION 3.16)
7+
8+
# The wolfTPM CMake file should be able to find the source code.
9+
# Otherwise, assign an environment variable or set it here:
10+
#
11+
# set(WOLFTPM_ROOT "~/workspace/wolftpm-other-source")
12+
#
13+
# Optional WOLFSSL_CMAKE_SYSTEM_NAME detection to find
14+
# USE_MY_PRIVATE_CONFIG path for my_private_config.h
15+
#
16+
# Expected path varies:
17+
#
18+
# WSL: /mnt/c/workspace
19+
# Linux: ~/workspace
20+
# Windows: C:\workspace
21+
#
22+
if(WIN32)
23+
# Windows-specific configuration here
24+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS")
25+
message("Detected Windows")
26+
endif()
27+
if(CMAKE_HOST_UNIX)
28+
message("Detected UNIX")
29+
endif()
30+
if(APPLE)
31+
message("Detected APPLE")
32+
endif()
33+
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop")
34+
# Windows-specific configuration here
35+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL")
36+
message("Detected WSL")
37+
endif()
38+
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32))
39+
# Windows-specific configuration here
40+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX")
41+
message("Detected Linux")
42+
endif()
43+
if(APPLE)
44+
# Windows-specific configuration here
45+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE")
46+
message("Detected Apple")
47+
endif()
48+
# End optional WOLFSSL_CMAKE_SYSTEM_NAME
49+
50+
# Check that there are no conflicting wolfSSL components.
51+
#
52+
# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl
53+
# The local component wolfSSL directory will be in ./components/wolfssl
54+
if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" )
55+
# These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake'
56+
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL)
57+
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL)
58+
# So we'll error out and let the user decide how to proceed:
59+
message(WARNING "\nFound wolfSSL components in\n"
60+
"./managed_components/wolfssl__wolfssl\n"
61+
"and\n"
62+
"./components/wolfssl\n"
63+
"in project directory: \n"
64+
"${CMAKE_HOME_DIRECTORY}")
65+
message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n"
66+
"If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove "
67+
"or rename the idf_component.yml file typically found in ./main/")
68+
else()
69+
message(STATUS "No conflicting wolfSSL components found.")
70+
endif()
71+
72+
# Check that there are no conflicting wolfTPM components.
73+
#
74+
# The ESP Registry Component will be in ./managed_components/wolfssl__wolftpm
75+
# The local component wolfTPM directory will be in ./components/wolftpm
76+
if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolftpm" )
77+
# These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake'
78+
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm" EXCLUDE_FROM_ALL)
79+
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm/include" EXCLUDE_FROM_ALL)
80+
# So we'll error out and let the user decide how to proceed:
81+
message(WARNING "\nFound wolfTPM components in\n"
82+
"./managed_components/wolfssl__wolftpm\n"
83+
"and\n"
84+
"./components/wolftpm\n"
85+
"in project directory: \n"
86+
"${CMAKE_HOME_DIRECTORY}")
87+
message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfTPM component directory but not both.\n"
88+
"If removing the ./managed_components/wolfssl__wolftpm directory, remember to also remove "
89+
"or rename the idf_component.yml file typically found in ./main/")
90+
else()
91+
message(STATUS "No conflicting wolfTPM components found.")
92+
endif()
93+
94+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
95+
96+
project(wolfTPM_test)

IDE/Espressif/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# wolfTPM for Espressif
2+
3+
Initial minimum memory requirements: 35KB Stack. See `sdkconfig.defaults`.
4+
5+
Current memory assigned: 50960
6+
7+
## Pin assignments
8+
9+
**Note:** The following pin assignments are used by default, you can change these in the `menuconfig` .
10+
11+
| | SDA | SCL |
12+
| ---------------- | -------------- | -------------- |
13+
| ESP I2C Master | I2C_MASTER_SDA | I2C_MASTER_SCL |
14+
| TPM2 Device | SDA | SCL |
15+
16+
For the actual default value of `I2C_MASTER_SDA` and `I2C_MASTER_SCL` see `Example Configuration` in `menuconfig`.
17+
18+
**Note:** There's no need to add an external pull-up resistors for SDA/SCL pin, because the driver will enable the internal pull-up resistors.
19+
20+
## Troubleshooting
21+
22+
If problems are encountered with the I2C module:
23+
24+
- Beware that printing to the UART during an I2C transaction may affect timing and cause errors.
25+
- Ensure the TPM module has been reset after flash updated.
26+
- Check wiring. `SCL` to `SCL`, `SDA` to `SDA`. Probably best to ensure GND is connected. Vcc is 3.3v only.
27+
- Ensure the proper pins are connected on the ESP32. SCL default is `GPIO 19`; SDA default is `GPIO 18`.
28+
- Test with only a single I2C device before testing concurrent with other I2C boards.
29+
- When using multiple I2C boards, check for appropriate pullups. See data sheet.
30+
- Reset TPM device again. Press button on TPM SLB9673 eval board or set TPM pin 17 as appropriate.
31+
-

0 commit comments

Comments
 (0)