diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_template/CMakeLists.txt b/ide/Espressif/ESP-IDF/examples/wolfssh_template/CMakeLists.txt index 1def9d0be..58fa04c86 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_template/CMakeLists.txt +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_template/CMakeLists.txt @@ -1,19 +1,34 @@ +# wolfSSL 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.5) +cmake_minimum_required(VERSION 3.16) # enable wolfssl user_settings.h project-wide set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +set(WOLFSSL_USER_SETTINGS ON) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSH_TERM") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG_WOLFSSH") +# The wolfSSL CMake file should be able to find the source code. +# Otherwise, assign an environment variable or set it here: +# # set(WOLFSSL_ROOT "~/workspace/wolfssl-other-source") +# set(WOLFSSH_ROOT "~/workspace/wolfssh-other-source") +# set(WOLFSSL_ROOT "C:/workspace/wolfssl-master") # 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") diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_template/components/wolfssl/CMakeLists.txt b/ide/Espressif/ESP-IDF/examples/wolfssh_template/components/wolfssl/CMakeLists.txt index 7f482a4f8..59fe55b3a 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_template/components/wolfssl/CMakeLists.txt +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_template/components/wolfssl/CMakeLists.txt @@ -19,6 +19,8 @@ # # cmake for wolfssl Espressif projects # +# Version 5.6.0.012 for improved manual setting of WOLFSSL_ROOT +# # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html # @@ -27,6 +29,26 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") set(CMAKE_CURRENT_SOURCE_DIR ".") set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl component +if ( "${WOLFSSL_ROOT}" STREQUAL "") + set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) +endif() + +# find the user name to search for possible "wolfssl-username" +message(STATUS "USERNAME = $ENV{USERNAME}") +if( "$ENV{USER}" STREQUAL "" ) # the bash user + if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user + message(STATUS "could not find USER or USERNAME") + else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USERNAME}") + endif() +else() + # the bash user is not blank, so we'll use it. + set(THIS_USER "$ENV{USER}") +endif() +message(STATUS "THIS_USER = ${THIS_USER}") + + # COMPONENT_NAME = wolfssl # The component name is the directory name. "No feature to change this". # See https://github.com/espressif/esp-idf/issues/8978#issuecomment-1129892685 @@ -41,145 +63,159 @@ set(COMPONENT_REQUIRES lwip) # we typically don't need lwip directly in wolfssl # We are typically in [root]/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl # The root of wolfSSL is 7 directories up from here: -if(CMAKE_BUILD_EARLY_EXPANSION) - message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:") - idf_component_register( - REQUIRES "${COMPONENT_REQUIRES}" - PRIV_REQUIRES esp_timer driver # this will typically only be needed for wolfSSL benchmark - ) +# function: IS_WOLFSSL_SOURCE +# parameter: DIRECTORY_PARAMETER - the directory to test +# output: RESULT = contains contents of DIRECTORY_PARAMETER for wolfssl directory, otherwise blank. +function(IS_WOLFSSL_SOURCE DIRECTORY_PARAMETER RESULT) + if (EXISTS "${DIRECTORY_PARAMETER}/wolfcrypt/src") + set(${RESULT} "${DIRECTORY_PARAMETER}" PARENT_SCOPE) + else() + set(${RESULT} "" PARENT_SCOPE) + endif() +endfunction() -else() - # not CMAKE_BUILD_EARLY_EXPANSION - message(STATUS "************************************************************************************************") - message(STATUS "wolfssl component config:") - message(STATUS "************************************************************************************************") +# function: FIND_WOLFSSL_DIRECTORY +# parameter: OUTPUT_FOUND_WOLFSSL_DIRECTORY contains root of source code, otherwise blank +# +function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) + message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") - # Check to see if we're already in wolfssl, and only if WOLFSSL_ROOT not specified - if ("${WOLFSSL_ROOT}" STREQUAL "") - # wolfssl examples are 7 directories deep from wolfssl repo root - # 1 2 3 4 5 6 7 - set(THIS_RELATIVE_PATH "../../../../../../..") - get_filename_component(THIS_SEARCH_PATH "${THIS_RELATIVE_PATH}" ABSOLUTE) - message(STATUS "Searching in path = ${THIS_SEARCH_PATH}") - - if (EXISTS "${THIS_SEARCH_PATH}/wolfcrypt/src") - # we're already in wolfssl examples! - get_filename_component(WOLFSSL_ROOT "${THIS_SEARCH_PATH}" ABSOLUTE) - message(STATUS "Using wolfSSL example with root ${WOLFSSL_ROOT}") + if ( "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" STREQUAL "" ) + set(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}") + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "The WOLFSSL_ROOT environment variable is not set. Searching...") else() - # We're in some other repo such as wolfssh, so we'll search for an - # adjacent-level directory for wolfssl. (8 directories up, then down one) - # - # For example wolfSSL examples: - # C:\workspace\wolfssl-gojimmypi\IDE\Espressif\ESP-IDF\examples\wolfssl_benchmark\components\wolfssl - # - # For example wolfSSH examples: - # C:\workspace\wolfssh-gojimmypi\ide\Espressif\ESP-IDF\examples\wolfssh_benchmark\components\wolfssl - # - # 1 2 3 4 5 6 7 8 - set(THIS_RELATIVE_PATH "../../../../../../../..") - get_filename_component(THIS_SEARCH_PATH "${THIS_RELATIVE_PATH}" ABSOLUTE) - message(STATUS "Searching next in path = ${THIS_SEARCH_PATH}") + get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSL_ROOT}" ABSOLUTE) + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) + if( FOUND_WOLFSSL ) + message(STATUS "Found WOLFSSL_ROOT via Environment Variable:") + else() + message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:") + message(STATUS "$ENV{WOLFSSL_ROOT}") + endif() + endif() + else() + get_filename_component(CURRENT_SEARCH_DIR "${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}" ABSOLUTE) + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) + if( FOUND_WOLFSSL ) + message(STATUS "Found WOLFSSL_ROOT via prior specification.") + else() + message(FATAL_ERROR "WOLFSSL_ROOT Variable defined, but path not found: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") endif() endif() - # search other possible locations - if ("${WOLFSSL_ROOT}" STREQUAL "") - # there's not a hard-coded WOLFSSL_ROOT value above, so let's see if we can find it. - if( "$ENV{WOLFSSL_ROOT}" STREQUAL "" ) - message(STATUS "Environment Variable WOLFSSL_ROOT not set. Will search common locations.") - - message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") - get_filename_component(THIS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) - message(STATUS "THIS_DIR = ${THIS_DIR}") - - # find the user name to search for possible "wolfssl-username" - message(STATUS "USERNAME = $ENV{USERNAME}") - if( "$ENV{USER}" STREQUAL "" ) # the bash user - if( "$ENV{USERNAME}" STREQUAL "" ) # the Windows user - message(STATUS "could not find USER or USERNAME") - else() - # the bash user is not blank, so we'll use it. - set(THIS_USER "$ENV{USERNAME}") - endif() - else() - # the bash user is not blank, so we'll use it. - set(THIS_USER "$ENV{USER}") - endif() - message(STATUS "THIS_USER = ${THIS_USER}") - - # This same makefile is used for both the wolfssl component, and other - # components that may depend on wolfssl, such as wolfssh. Therefore - # we need to determine if this makefile is in the wolfssl repo, or - # some other repo. - - if( "{THIS_USER}" STREQUAL "" ) - # This is highly unusual to not find a user name. - # In this case, we'll just search for a "wolfssl" directory: - message(STATUS "No username found!") - get_filename_component(WOLFSSL_ROOT "${THIS_RELATIVE_PATH}/wolfssl" ABSOLUTE) - else() - # We found an environment USER name! - # The first place to look for wolfssl will be in a user-clone called "wolfssl-[username]" - message(STATUS "Using [THIS_USER = ${THIS_USER}] to see if there's a [relative path]/wolfssl-${THIS_USER} directory.") - get_filename_component(WOLFSSL_ROOT "${THIS_RELATIVE_PATH}/wolfssl-${THIS_USER}" ABSOLUTE) - if( EXISTS "${WOLFSSL_ROOT}" ) - message(STATUS "Found wolfssl in user-suffix ${WOLFSSL_ROOT}") - else() - # If there's not a user-clone called "wolfssl-[username]", - # perhaps there's simply a git clone called "wolfssl"? - message(STATUS "Did not find wolfssl-${THIS_USER}; continuing search...") - get_filename_component(WOLFSSL_ROOT "${THIS_RELATIVE_PATH}/wolfssl" ABSOLUTE) + # we'll start in the CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssl + message(STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE) + message(STATUS "CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + + # loop through all the parents, looking for wolfssl + while(NOT CURRENT_SEARCH_DIR STREQUAL "/" AND NOT CURRENT_SEARCH_DIR STREQUAL "" ) + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + # wolfSSL may simply be in a parent directory, such as for local examples in wolfssl repo + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSL) + if( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() - if( EXISTS "${WOLFSSL_ROOT}" ) - message(STATUS "Found wolfssl in standard ${WOLFSSL_ROOT}") - else() - # Things are looking pretty bleak. We'll likely not be able to compile. - message(STATUS "Did not find wolfssl in ${WOLFSSL_ROOT}") - endif() - endif() + if( THIS_USER ) + # Check for "wolfssl-[username]" subdirectory as we recurse up the directory tree + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl-${THIS_USER}) + message(STATUS "Looking in ${CURRENT_SEARCH_DIR}") + + #if(EXISTS ${CURRENT_SEARCH_DIR_ALT} AND IS_DIRECTORY ${CURRENT_SEARCH_DIR_ALT} AND EXISTS "${CURRENT_SEARCH_DIR_ALT}/wolfcrypt/src") + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR_ALT} PARENT_SCOPE) + return() endif() + endif() - else() - # there's an environment variable, so use it. - set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}") + # Next check for no user suffix "wolfssl" subdirectory as we recurse up the directory tree + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssl) + # if(EXISTS ${CURRENT_SEARCH_DIR} AND IS_DIRECTORY ${CURRENT_SEARCH_DIR} AND EXISTS "${CURRENT_SEARCH_DIR}/wolfcrypt/src") + IS_WOLFSSL_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSL ) + if ( FOUND_WOLFSSL ) + message(STATUS "Found wolfssl in CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() - if( EXISTS "${WOLFSSL_ROOT}" ) - get_filename_component(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ABSOLUTE) - message(STATUS "Found WOLFSSL_ROOT via Environment Variable:") - else() - message(FATAL_ERROR "WOLFSSL_ROOT Environment Variable defined, but path not found:") - message(STATUS "$ENV{WOLFSSL_ROOT}") - endif() + # Move up one directory level + set(PRIOR_SEARCH_DIR "${CURRENT_SEARCH_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${CURRENT_SEARCH_DIR}" DIRECTORY) + message(STATUS "Next CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + if( "${PRIOR_SEARCH_DIR}" STREQUAL "${CURRENT_SEARCH_DIR}" ) + # when the search directory is empty, we'll give up + set(CURRENT_SEARCH_DIR "") endif() - # end of search for wolfssl component root - else() - # There's already a value assigned; we won't search for anything else. - message(STATUS "Found user-specified WOLFSSL_ROOT value.") - endif() # WOLFSSL_ROOT user defined + endwhile() + + # If not found, set the output variable to empty before exiting + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} "" PARENT_SCOPE) +endfunction() + + +# Example usage: + + + + +if(CMAKE_BUILD_EARLY_EXPANSION) + message(STATUS "wolfssl component CMAKE_BUILD_EARLY_EXPANSION:") + idf_component_register( + REQUIRES "${COMPONENT_REQUIRES}" + PRIV_REQUIRES # esp_hw_support + esp_timer + driver # this will typically only be needed for wolfSSL benchmark + ) + +else() + # not CMAKE_BUILD_EARLY_EXPANSION + message(STATUS "************************************************************************************************") + message(STATUS "wolfssl component config:") + message(STATUS "************************************************************************************************") - # After all the logic above, does our WOLFSSL_ROOT actually exist? - if( EXISTS "${WOLFSSL_ROOT}" ) - message(STATUS "WOLFSSL_ROOT = ${WOLFSSL_ROOT}") + # search for wolfSSL + FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) + if(WOLFSSL_ROOT) + message(STATUS "NEW Found wolfssl directory at: ${WOLFSSL_ROOT}") else() + message(STATUS "NEW wolfssl directory not found.") # Abort. We need wolfssl _somewhere_. - message(FATAL_ERROR "Could not find wolfssl in ${WOLFSSL_ROOT}. Try setting environment variable or git clone.") + message(FATAL_ERROR "Could not find wolfssl in ${WOLFSSL_ROOT}.\n" + "Try setting WOLFSSL_ROOT environment variable or git clone.") endif() - set(INCLUDE_PATH ${WOLFSSL_ROOT}) + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/src/") + + if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_benchmark" ) + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( ${CMAKE_PROJECT_NAME} STREQUAL "wolfssl_test" ) + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + endif() + set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/atmel\"" - # "\"${WOLFSSL_ROOT}/wolfcrypt/benchmark\"" # the benchmark application - # "\"${WOLFSSL_ROOT}/wolfcrypt/test\"" # the test application - ) # COMPONENT_SRCDIRS + "\"${WOLFSSL_EXTRA_PROJECT_DIR}\"" + ) # COMPONENT_SRCDIRS + message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl") + add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${WOLFSSL_PROJECT_DIR}/include/user_settings.h") + # Espressif may take several passes through this makefile. Check to see if we found IDF string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSL_FOUND_IDF) @@ -267,10 +303,10 @@ else() # we won't overwrite an existing user settings file, just note that we already have one: if( EXISTS "${WOLFSSL_PROJECT_DIR}/include/user_settings.h" ) message(STATUS "Using existing wolfSSL user_settings.h in " - "${WOLFSSL_PROJECT_DIR}/include/user_settings.h") + "${WOLFSSL_PROJECT_DIR}/include/user_settings.h") else() message(STATUS "Installing wolfSSL user_settings.h to " - "${WOLFSSL_PROJECT_DIR}/include/user_settings.h") + "${WOLFSSL_PROJECT_DIR}/include/user_settings.h") file(COPY "${WOLFSSL_ROOT}/IDE/Espressif/ESP-IDF/user_settings.h" DESTINATION "${CMAKE_HOME_DIRECTORY}/wolfssl/include/") endif() @@ -278,7 +314,12 @@ else() # next check if there's a [root]/include/config.h if( EXISTS "${WOLFSSL_ROOT}/include/config.h" ) - message(FATAL_ERROR "Found stray wolfSSL config.h in ${WOLFSSL_ROOT}/include/config.h (please move it to ${WOLFSSL_PROJECT_DIR}/include/config.h") + message(STATUS "******************************************************************************") + message(STATUS "******************************************************************************") + message(STATUS "Found stray wolfSSL config.h in ${WOLFSSL_ROOT}/include/config.h" ) + message(STATUS " Please move it to ${WOLFSSL_PROJECT_DIR}/include/config.h" ) + message(STATUS "******************************************************************************") + message(STATUS "******************************************************************************") else() # we won't overwrite an existing user settings file, just note that we already have one: if( EXISTS "${WOLFSSL_PROJECT_DIR}/include/config.h" ) @@ -353,13 +394,22 @@ else() "\"${WOLFSSL_ROOT}/src/misc.c\"" "\"${WOLFSSL_ROOT}/src/pk.c\"" "\"${WOLFSSL_ROOT}/src/ssl_asn1.c\"" # included by ssl.c - "\"${WOLFSSL_ROOT}/src/ssl_certman.c\"" # included by ssl.c "\"${WOLFSSL_ROOT}/src/ssl_bn.c\"" # included by ssl.c + "\"${WOLFSSL_ROOT}/src/ssl_certman.c\"" # included by ssl.c + "\"${WOLFSSL_ROOT}/src/ssl_crypto.c\"" # included by ssl.c "\"${WOLFSSL_ROOT}/src/ssl_misc.c\"" # included by ssl.c "\"${WOLFSSL_ROOT}/src/x509.c\"" "\"${WOLFSSL_ROOT}/src/x509_str.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c\"" "\"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm32.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_arm64.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_armthumb.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_c32.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_c64.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_cortexm.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64.c\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/sp_sm2_x86_64_asm.S\"" "\"${EXCLUDE_ASM}\"" ) @@ -404,6 +454,7 @@ else() endif() # target_sources(wolfssl PRIVATE "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt\"") + endif() # CMAKE_BUILD_EARLY_EXPANSION diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_template/main/CMakeLists.txt b/ide/Espressif/ESP-IDF/examples/wolfssh_template/main/CMakeLists.txt index 2b6768f84..50d6995ef 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_template/main/CMakeLists.txt +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_template/main/CMakeLists.txt @@ -1,11 +1,34 @@ -# This tag is used to include this file in the ESP Component Registry: -# __ESP_COMPONENT_SOURCE__ - -# -# wolfssl client test +# wolfSSL wolfSSH Espressif Example Project/main/CMakeLists.txt +# v1.0 # -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +message(STATUS "main cmake found WOLFSSL_COMPONENT_NAME = ${WOLFSSL_COMPONENT_NAME}") +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() set (git_cmd "git") if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) @@ -18,6 +41,37 @@ if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PA set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") endif() +if( "$ENV{IDF_COMPONENT_REGISTRY_URL}" STREQUAL "https://components-staging.espressif.com" ) + if( ("${managed_components}" STREQUAL "") AND ("${component_manager_interface_version}" STREQUAL "") ) + # We've found a staging component, but did not detect the component manager + if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../components/mywolfssh/CMakeLists.txt) + # This is typically during publish-time build test + message(STATUS "Set name mywolfssh (1)") + set(WOLFSSL_COMPONENT_NAME "mywolfssl") + set(WOLFSSH_COMPONENT_NAME "mywolfssh") + else() + if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../managed_components/gojimmypi__mywolfmqtt/CMakeLists.txt) + # This is typically upon creating a project from managed component examples + message(STATUS "Set name mywolfssh (2)") + set(WOLFSSL_COMPONENT_NAME "mywolfssl") + set(WOLFSSH_COMPONENT_NAME "mywolfssh") + else() + message(STATUS "Set name wolfmqtt (1) CMAKE_CURRENT_LIST_DIR = ${CMAKE_CURRENT_LIST_DIR}") + set(WOLFSSL_COMPONENT_NAME "wolfssl") + set(WOLFSSH_COMPONENT_NAME "wolfssh") + endif() + endif() + else() + message(STATUS "Set name mywolfssh (3)") + set(WOLFSSL_COMPONENT_NAME "mywolfssl") + set(WOLFSSH_COMPONENT_NAME "mywolfssh") + endif() +else() + message(STATUS "Set name wolfssh (2)") + set(WOLFSSL_COMPONENT_NAME "wolfssl") + set(WOLFSSH_COMPONENT_NAME "wolfssh") +endif() + ## register_component() idf_component_register(SRCS main.c INCLUDE_DIRS "." "./include") diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_template/partitions_singleapp_large.csv b/ide/Espressif/ESP-IDF/examples/wolfssh_template/partitions_singleapp_large.csv new file mode 100644 index 000000000..a9c373bec --- /dev/null +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_template/partitions_singleapp_large.csv @@ -0,0 +1,31 @@ +# to view: idf.py partition-table +# +# ESP-IDF Partition Table +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 24K, +phy_init,data, phy, 0xf000, 4K, +factory, app, factory, 0x10000, 1500K, + + +# For other settings, see: +# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#creating-custom-tables +# +# Here is the summary printed for the "Single factory app, no OTA" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x6000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# +# +# Here is the summary printed for the "Factory app, two OTA definitions" configuration: +# +# # ESP-IDF Partition Table +# # Name, Type, SubType, Offset, Size, Flags +# nvs, data, nvs, 0x9000, 0x4000, +# otadata, data, ota, 0xd000, 0x2000, +# phy_init, data, phy, 0xf000, 0x1000, +# factory, app, factory, 0x10000, 1M, +# ota_0, app, ota_0, 0x110000, 1M, +# ota_1, app, ota_1, 0x210000, 1M, diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_template/sdkconfig.defaults b/ide/Espressif/ESP-IDF/examples/wolfssh_template/sdkconfig.defaults index 2842aa34e..109246181 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_template/sdkconfig.defaults +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_template/sdkconfig.defaults @@ -1,3 +1,6 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration + CONFIG_FREERTOS_HZ=1000 CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y @@ -21,3 +24,15 @@ CONFIG_COMPILER_HIDE_PATHS_MACROS=y CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y CONFIG_COMPILER_STACK_CHECK=y +# +# Partition Table +# +# CONFIG_PARTITION_TABLE_SINGLE_APP is not set +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y +# CONFIG_PARTITION_TABLE_TWO_OTA is not set +# CONFIG_PARTITION_TABLE_CUSTOM is not set +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp_large.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y +# end of Partition Table