Skip to content

Commit

Permalink
Merge pull request wolfSSL#8076 from gojimmypi/pr-update-espressif-ex…
Browse files Browse the repository at this point in the history
…amples

Update Espressif Examples
  • Loading branch information
JacobBarthelmeh authored Oct 21, 2024
2 parents ef063aa + a13f48a commit efff8e0
Show file tree
Hide file tree
Showing 97 changed files with 9,475 additions and 1,522 deletions.
37 changes: 29 additions & 8 deletions IDE/Espressif/ESP-IDF/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# ESP-IDF Port

These Espressif examples have been created and tested with the latest stable release branch of
[ESP-IDF V5.2](https://docs.espressif.com/projects/esp-idf/en/release-v5.2/esp32/get-started/index.html).
ESP-IDF v5.2, v5.3 and the master branch

The prior version 4.4 ESP-IDF is still supported, however version 5.2 or greater is recommended.
Espressif has [a list of all ESP-IDF versions](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/versions.html).
Espressif has [a list of all ESP-IDF versions](Espressifversions.html).

See the latest [Espressif Migration Guides](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/index.html).
See the latest Espressif Migration Guides.

## Examples

Expand Down Expand Up @@ -34,7 +35,7 @@ looks for the wolfSSL `user_settings.h` in the project as described below.
### File: `sdkconfig.h`

The Espressif `sdkconfig.h`, generated automatically from your `sdkconfig`
file at [build](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html)
file at [build](Espressif api-guides/build-system.html)
time, should be included before any other files.

### File: `user_settings.h`
Expand Down Expand Up @@ -101,7 +102,7 @@ of your source code, particularly before the `#include <wolfssl/wolfcrypt/settin

## Requirements

1. [ESP-IDF development framework](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/)
1. [ESP-IDF development framework](https://github.com/espressif/esp-idf)

## wolfSSL as an Espressif component

Expand All @@ -113,7 +114,7 @@ There are various methods available for using wolfSSL as a component:

## Espressif Managed Components

Visit https://components.espressif.com/components/wolfssl/wolfssl and see the instructions. Typically:
Visit https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/ and see the instructions. Typically:

```
idf.py add-dependency "wolfssl/wolfssl^5.6.0-stable"
Expand Down Expand Up @@ -144,6 +145,14 @@ This is an alternate method for installation. It is recommended to use the new `
2. Find Wolfssl files at _/path/to/esp_`/esp-idf/components/wolfssl/`
3. Find [Example Programs](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples) under _/path/to/esp_`/esp-idf/examples/protocols/wolfssl_xxx` (where xxx is the project name)


```
WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2
. $WRK_IDF_PATH/export.sh
./setup.sh
```

## Setup for Windows

This is an alternate method for installation. It is recommended to use the new `CMakeLists.txt` to point to wolfSSL source code.
Expand Down Expand Up @@ -188,8 +197,8 @@ C:\SysGCC\esp32\esp-idf>git clone -b v5.0.2 --recursive https://github.com/espre
- Microsoft Windows 10 Pro 10.0.19041 / Windows 11 Pro 22H2 22621.2715
- Visual Studio 2022 17.7.6 with VisualGDB 5.6R9 (build 4777)
- WSL 1 Ubuntu 22.04.3 LTS
- ESP-IDF: ESP-IDF v5.1
- SoC Module : all those supported in ESP-IDF v5.1
- ESP-IDF: ESP-IDF v5.2
- SoC Module : all those supported in ESP-IDF v5.2

## JTAG Debugging Notes

Expand Down Expand Up @@ -226,3 +235,15 @@ ftdi layout_signal nSRST -data 0x0020
reset_config srst_push_pull trst_push_pull
```

## Windows long paths

Check "Long Paths Enabled" in Windows registry.

Please set registry HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled to 1.

The operation requires Administrator privileges. Command:

```powershell
powershell -Command "&{ Start-Process -FilePath reg 'ADD HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f' -Verb runAs}"
```
2 changes: 1 addition & 1 deletion IDE/Espressif/ESP-IDF/README_32se.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Including the following examples:
The `user_settings.h` file enables some of the hardened settings.

## Requirements
1. ESP-IDF development framework: https://docs.espressif.com/projects/esp-idf/en/latest/get-started/
1. ESP-IDF development framework: https://github.com/espressif/esp-idf

2. Microchip CryptoAuthentication Library: https://github.com/MicrochipTech/cryptoauthlib

Expand Down
7 changes: 2 additions & 5 deletions IDE/Espressif/ESP-IDF/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ wolfSSL to be installed.
If you want to install wolfSSL, see the setup for [wolfSSL](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF#setup-for-linux)
and [wolfSSH](https://github.com/wolfSSL/wolfssh/tree/master/ide/Espressif#setup-for-linux).

The [Espressif Managed Component for wolfSSL](https://components.espressif.com/components/wolfssl/wolfssl)
The [Espressif Managed Component for wolfSSL](https://www.wolfssl.com/wolfssl-now-available-in-espressif-component-registry/)
also installs source code locally, instead of pointing to a source repository.

## VisualGDB
Expand Down Expand Up @@ -114,7 +114,4 @@ It may be helpful to also delete the `sdkconfig` file. (Save a backup if you've

- esp32.com: [GPIO6,GPIO7,GPIO8,and GPIO9 changed for ESP32-WROOM-32E](https://esp32.com/viewtopic.php?t=29058)

See also [this ESP-FAQ Handbook](https://docs.espressif.com/projects/esp-faq/en/latest/esp-faq-en-master.pdf).



See also the `ESP-FAQ Handbook`.
8 changes: 6 additions & 2 deletions IDE/Espressif/ESP-IDF/examples/template/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# wolfSSL Espressif Example Project CMakeLists.txt
# v1.2
# v1.3
#
# 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)

# Optional no watchdog typically used for test & benchmark
# add_compile_options(-DWOLFSSL_ESP_NO_WATCHDOG=1)
add_compile_options(-DWOLFSSL_ESP_NO_WATCHDOG=1)

# The wolfSSL CMake file should be able to find the source code.
# Otherwise, assign an environment variable or set it here:
Expand Down Expand Up @@ -71,6 +71,10 @@ else()
message(STATUS "No conflicting wolfSSL components found.")
endif()

# Ensure the this wolfSSL component directory is included
set(WOLFSSL_PATH "${CMAKE_HOME_DIRECTORY}/components/wolfssl")
list(APPEND EXTRA_COMPONENT_DIRS ${WOLFSSL_PATH})

# Not only is a project-level "set(COMPONENTS" not needed here, this will cause
# an unintuitive error about Unknown CMake command "esptool_py_flash_project_args".
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
Expand Down
10 changes: 5 additions & 5 deletions IDE/Espressif/ESP-IDF/examples/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For general information on [wolfSSL examples for Espressif](../README.md), see t

### Prerequisites

It is assumed the [ESP-IDF environment](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/) has been installed.
It is assumed the [ESP-IDF environment](Espressifget-started/) has been installed.

### Files Included

Expand All @@ -19,7 +19,7 @@ It is assumed the [ESP-IDF environment](https://docs.espressif.com/projects/esp-

- The [components/wolfssl/CMakeLists.txt](./components/wolfssl/CMakeLists.txt) typically does not need to be changed.

- Optional [VisualGDB Project](./VisualGDB/wolfssl_template_IDF_v5.1_ESP32.vgdbproj) for Visual Studio using ESP32 and ESP-IDF v5.1.
- Optional [VisualGDB Project](./VisualGDB/README.md) for Visual Studio using ESP32 and ESP-IDF v5.2. See also [template](../template/VisualGDB/README.md) for other devices.

- Edit the project [CMakeLists.txt](./CMakeLists.txt) to optionally point this project's wolfSSL component source code at a different directory:

Expand All @@ -30,12 +30,12 @@ set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source")

## Getting Started:

Here's an example using the command-line [idf.py](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-py.html).
Here's an example using the command-line [idf.py](Espressifapi-guides/tools/idf-py.html).

Edit your `WRK_IDF_PATH`to point to your ESP-IDF install directory.

```
WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.1
WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2
echo "Run export.sh from ${WRK_IDF_PATH}"
. ${WRK_IDF_PATH}/export.sh
Expand All @@ -53,7 +53,7 @@ idf.py flash -p /dev/ttyS19 -b 115200
idf.py flash -p /dev/ttyS19 -b 115200 monitor
```

Press `Ctrl+]` to exit `idf.py monitor`. See [additional monitor keyboard commands](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-monitor.html).
Press `Ctrl+]` to exit `idf.py monitor`. See [additional monitor keyboard commands](Espressifapi-guides/tools/idf-monitor.html).

## Other Examples:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ cmake_minimum_required(VERSION 3.16)

set(VERBOSE_COMPONENT_MESSAGES 1)

# Optional requires include:
# set(THIS_ESP_TLS "esp-tls")
set(THIS_ESP_TLS "")

# function: IS_ESP_IDF_COMPONENT
# output: RESULT = 1 (true) if this component is located in the ESP-IDF components
Expand Down Expand Up @@ -153,7 +156,7 @@ if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_
message(STATUS "Not including lwip for ${CMAKE_PROJECT_NAME}")
else()
# benchmark and test do not need wifi, everything else probably does:
set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component
set(COMPONENT_REQUIRES lwip "${THIS_ESP_TLS}") # we typically don't need lwip directly in wolfssl component
endif()

# find the user name to search for possible "wolfssl-username"
Expand Down Expand Up @@ -404,22 +407,28 @@ endif()

if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") )
# There's no esp_timer, no driver components for the ESP8266
message(STATUS "Early expansion EXCLUDES esp_timer: ${THIS_INCLUDE_TIMER}")
message(STATUS "Early expansion EXCLUDES driver: ${THIS_INCLUDE_DRIVER}")
message(STATUS "Early expansion EXCLUDES esp_timer for esp8266: ${THIS_INCLUDE_TIMER}")
message(STATUS "Early expansion EXCLUDES driver for esp8266: ${THIS_INCLUDE_DRIVER}")
set(THIS_INCLUDE_TIMER "")
set(THIS_INCLUDE_DRIVER "")
set(THIS_ESP_TLS "")
else()
message(STATUS "Early expansion includes esp_timer: ${THIS_INCLUDE_TIMER}")
message(STATUS "Early expansion includes driver: ${THIS_INCLUDE_DRIVER}")
set(THIS_INCLUDE_TIMER "esp_timer")
set(THIS_INCLUDE_DRIVER "driver")
set(THIS_ESP_TLS "esp-tls")
# Let the app know that we've included the esp-tls component requirement.
# This is critical for use the the esp-tls component. See wolfssl esp_crt_bundle.c file.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_CMAKE_REQUIRED_ESP_TLS=1")
endif()

if(CMAKE_BUILD_EARLY_EXPANSION)
message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:")
idf_component_register(
REQUIRES "${COMPONENT_REQUIRES}"
PRIV_REQUIRES # esp_hw_support
"${THIS_ESP_TLS}"
"${THIS_INCLUDE_TIMER}"
"${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark
)
Expand Down Expand Up @@ -757,6 +766,7 @@ else()
REQUIRES "${COMPONENT_REQUIRES}"
EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}"
PRIV_REQUIRES
"${THIS_ESP_TLS}"
"${THIS_INCLUDE_TIMER}"
"${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark
)
Expand All @@ -768,7 +778,10 @@ else()
endif()

# function(WOLFSSL_INIT_CERT_BUNDLE)
if(CONFIG_WOLFSSL_CERTIFICATE_BUNDLE AND NOT CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE)
if( CONFIG_WOLFSSL_CERTIFICATE_BUNDLE
AND NOT CONFIG_WOLFSSL_CERTIFICATE_BUNDLE_DEFAULT_NONE
AND NOT ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266")
)
if (CMAKE_BUILD_EARLY_EXPANSION)
message(ERROR "Bundle Cert initialization must occur during CMAKE_BUILD_EARLY_EXPANSION")
endif()
Expand Down Expand Up @@ -1001,10 +1014,13 @@ if(WOLFSSL_ROOT)
set(ENV{PIO_WOLFSSL_ROOT} "${WOLFSSL_ROOT}")
message(STATUS "PIO_WOLFSSL_ROOT = $ENV{PIO_WOLFSSL_ROOT}")
message(STATUS "PLATFORMIO_BUILD_DIR = $ENV{PLATFORMIO_BUILD_DIR}")
file(WRITE "tada.txt" "${WOLFSSL_ROOT}\n")
# See esp-tls Kconfig; menu "ESP-TLS", ESP_TLS_LIBRARY_CHOOSE
if(CONFIG_ESP_TLS_USING_WOLFSSL)
message(STATUS "wolfSSL will be used for ESP-TLS")
if ( ("${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") OR ("${IDF_TARGET}" STREQUAL "esp8266") )
message(STATUS "This version of wolfSSL is not supported on the ESP8266 esp-tls at this time. Check ESP-TLS config")
else()
message(STATUS "wolfSSL will be used for ESP-TLS")
endif()
else()
message(STATUS "WARNING: wolfSSL NOT selected for ESP-TLS. Features and performance will be limited.")
endif()
Expand Down
25 changes: 25 additions & 0 deletions IDE/Espressif/ESP-IDF/examples/template/components/wolfssl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,24 @@ menu "wolfSSL"
Hardware acceleration enabled by default.
Select this option to force disable: NO_HW_RSA_PRI_EXPTMOD

config ESP_WOLFSSL_DEBUG_ESP_HW_MULTI_RSAMAX_BITS
bool "Enable debugging of RSA Multiplication operand length"
default n
help
Prints an esp log warning to the default console UART when one of the
multiplication operands exceeds the maximum size supported by hardware,
requiring fallback to software. This can be helpful to pick key sizes
when performance is critical. See also metrics for counting instances.

config ESP_WOLFSSL_DEBUG_ESP_HW_MOD_RSAMAX_BITS
bool "Enable debugging of RSA Modular operand length"
default n
help
Prints an esp log warning to the default console UART when one of the
modular math operands exceeds the maximum size supported by hardware,
requiring fallback to software. This can be helpful to pick key sizes
when performance is critical. See also metrics for counting instances.

endmenu # wolfSSL Hardware Acceleration
# -----------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -410,6 +428,13 @@ menu "wolfSSL"
default n
help
Enable debugging messages for wolfSSL. See user_settings.h for additional debug options.

config ESP_WOLFSSL_TEST_LOOP
bool "Run test apps in a loop until failure"
default y
help
Enable a loop wrapper for benchmark, http_client, and wolfssl test apps.

endmenu # wolfSSL Debug Options
# -----------------------------------------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit efff8e0

Please sign in to comment.