-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #351 from gojimmypi/PR-Espressif
Initial Infineon I2C TPM support for Espressif ESP32
- Loading branch information
Showing
21 changed files
with
3,238 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# wolfTPM Espressif Example Project CMakeLists.txt | ||
# v1.0 | ||
# | ||
# The following lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
# The wolfTPM CMake file should be able to find the source code. | ||
# Otherwise, assign an environment variable or set it here: | ||
# | ||
# set(WOLFTPM_ROOT "~/workspace/wolftpm-other-source") | ||
# | ||
# Optional WOLFSSL_CMAKE_SYSTEM_NAME detection to find | ||
# USE_MY_PRIVATE_CONFIG path for my_private_config.h | ||
# | ||
# Expected path varies: | ||
# | ||
# WSL: /mnt/c/workspace | ||
# Linux: ~/workspace | ||
# Windows: C:\workspace | ||
# | ||
if(WIN32) | ||
# Windows-specific configuration here | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS") | ||
message("Detected Windows") | ||
endif() | ||
if(CMAKE_HOST_UNIX) | ||
message("Detected UNIX") | ||
endif() | ||
if(APPLE) | ||
message("Detected APPLE") | ||
endif() | ||
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND EXISTS "/proc/sys/fs/binfmt_misc/WSLInterop") | ||
# Windows-specific configuration here | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_WSL") | ||
message("Detected WSL") | ||
endif() | ||
if(CMAKE_HOST_UNIX AND (NOT APPLE) AND (NOT WIN32)) | ||
# Windows-specific configuration here | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_LINUX") | ||
message("Detected Linux") | ||
endif() | ||
if(APPLE) | ||
# Windows-specific configuration here | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_SYSTEM_NAME_APPLE") | ||
message("Detected Apple") | ||
endif() | ||
# End optional WOLFSSL_CMAKE_SYSTEM_NAME | ||
|
||
# Check that there are no conflicting wolfSSL components. | ||
# | ||
# The ESP Registry Component will be in ./managed_components/wolfssl__wolfssl | ||
# The local component wolfSSL directory will be in ./components/wolfssl | ||
if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl" ) | ||
# These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' | ||
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl" EXCLUDE_FROM_ALL) | ||
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolfssl/include" EXCLUDE_FROM_ALL) | ||
# So we'll error out and let the user decide how to proceed: | ||
message(WARNING "\nFound wolfSSL components in\n" | ||
"./managed_components/wolfssl__wolfssl\n" | ||
"and\n" | ||
"./components/wolfssl\n" | ||
"in project directory: \n" | ||
"${CMAKE_HOME_DIRECTORY}") | ||
message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfSSL component directory but not both.\n" | ||
"If removing the ./managed_components/wolfssl__wolfssl directory, remember to also remove " | ||
"or rename the idf_component.yml file typically found in ./main/") | ||
else() | ||
message(STATUS "No conflicting wolfSSL components found.") | ||
endif() | ||
|
||
# Check that there are no conflicting wolfTPM components. | ||
# | ||
# The ESP Registry Component will be in ./managed_components/wolfssl__wolftpm | ||
# The local component wolfTPM directory will be in ./components/wolftpm | ||
if( EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm" AND EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolftpm" ) | ||
# These exclude statements don't seem to be honored by the $ENV{IDF_PATH}/tools/cmake/project.cmake' | ||
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm" EXCLUDE_FROM_ALL) | ||
# add_subdirectory("${CMAKE_HOME_DIRECTORY}/managed_components/wolfssl__wolftpm/include" EXCLUDE_FROM_ALL) | ||
# So we'll error out and let the user decide how to proceed: | ||
message(WARNING "\nFound wolfTPM components in\n" | ||
"./managed_components/wolfssl__wolftpm\n" | ||
"and\n" | ||
"./components/wolftpm\n" | ||
"in project directory: \n" | ||
"${CMAKE_HOME_DIRECTORY}") | ||
message(FATAL_ERROR "\nPlease use either the ESP Registry Managed Component or the wolfTPM component directory but not both.\n" | ||
"If removing the ./managed_components/wolfssl__wolftpm directory, remember to also remove " | ||
"or rename the idf_component.yml file typically found in ./main/") | ||
else() | ||
message(STATUS "No conflicting wolfTPM components found.") | ||
endif() | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
|
||
project(wolfTPM_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# wolfTPM for Espressif | ||
|
||
Initial minimum memory requirements: 35KB Stack. See `sdkconfig.defaults`. | ||
|
||
Current memory assigned: 50960 | ||
|
||
## Pin assignments | ||
|
||
**Note:** The following pin assignments are used by default, you can change these in the `menuconfig` . | ||
|
||
| | SDA | SCL | | ||
| ---------------- | -------------- | -------------- | | ||
| ESP I2C Master | I2C_MASTER_SDA | I2C_MASTER_SCL | | ||
| TPM2 Device | SDA | SCL | | ||
|
||
For the actual default value of `I2C_MASTER_SDA` and `I2C_MASTER_SCL` see `Example Configuration` in `menuconfig`. | ||
|
||
**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. | ||
|
||
## Troubleshooting | ||
|
||
If problems are encountered with the I2C module: | ||
|
||
- Beware that printing to the UART during an I2C transaction may affect timing and cause errors. | ||
- Ensure the TPM module has been reset after flash updated. | ||
- Check wiring. `SCL` to `SCL`, `SDA` to `SDA`. Probably best to ensure GND is connected. Vcc is 3.3v only. | ||
- Ensure the proper pins are connected on the ESP32. SCL default is `GPIO 19`; SDA default is `GPIO 18`. | ||
- Test with only a single I2C device before testing concurrent with other I2C boards. | ||
- When using multiple I2C boards, check for appropriate pullups. See data sheet. | ||
- Reset TPM device again. Press button on TPM SLB9673 eval board or set TPM pin 17 as appropriate. | ||
- |
Oops, something went wrong.