diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e17acfc --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ + +# Visual Studio Code Workspace Files +*.vscode +*.userprefs +*.exe +*.dll +.vs +Backup +UpgradeLog.htm +*.aps +*.VC.db +*.filters + + +# Espressif sdk config default should be saved in sdkconfig.defaults +# we won't track the actual working sdkconfig files +/Espressif/**/sdkconfig +/Espressif/**/sdkconfig.old + +# VisualGDB +**/.visualgdb + +# auto-created CMake backups +**/CMakeLists.txt.old + +# CMake build directory +/out +/out_temp + +# Visual Studio +**/.vs +**/build diff --git a/Espressif/ESP32/ESP32-SSH-Server/CMakeLists.txt b/Espressif/ESP32/ESP32-SSH-Server/CMakeLists.txt index 52b1376..ed66ba9 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/CMakeLists.txt +++ b/Espressif/ESP32/ESP32-SSH-Server/CMakeLists.txt @@ -1,164 +1,199 @@ -# -# Copyright (C) 2014-2022 wolfSSL Inc. -# -# This file is part of wolfSSH. -# -# wolfSSH is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# wolfSSH is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with wolfSSH. If not, see . -# - -# 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) - -#standard build -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") - -# less debugging -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA -DWOLFSSH_SHELL") -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_SHELL -DDEBUG_WOLFSSL") - -# full debugging; NO_RSA needed to RNG. See https://github.com/wolfSSL/wolfssh/pull/417 -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA -DWOLFSSH_SHELL -DDEBUG_WOLFSSL") - -# hardware encryption -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA -DWOLFSSH_SHELL -DDEBUG_WOLFSSL -DWOLFSSL_ESP32WROOM32_CRYPT -DWOLFSSL_ESP32WROOM32_CRYPT_RSA_PRI -DWOLFSSL_ESP32WROOM32_CRYPT_DEBUG -DNO_WOLFSSL_ESP32WROOM32_CRYPT_HASH") - -# we'll look for a my_private_config.h in various environments -# we also assume that the file is added to the local .gitignore -# to ensure it is never inadvertently shared - -if(EXISTS "/c/workspace/my_private_config.h") - message(STATUS "found SYSPROGS_MY_PRIVATE_CONFIG") - add_definitions( -DSYSPROGS_MY_PRIVATE_CONFIG="/c/workspace/my_private_config.h" ) -endif() - -if(EXISTS "/workspace/my_private_config.h") - message(STATUS "found WINDOWS_MY_PRIVATE_CONFIG") - add_definitions( -DWINDOWS_MY_PRIVATE_CONFIG="/workspace/my_private_config.h" ) -endif() - -if(EXISTS "/mnt/c/workspace/my_private_config.h") - message(STATUS "found WSL_MY_PRIVATE_CONFIG") - add_definitions( -DWSL_MY_PRIVATE_CONFIG="/mnt/c/workspace/my_private_config.h" ) -endif() - -if(EXISTS "(~/my_private_config.h") - message(STATUS "found LINUX_MY_PRIVATE_CONFIG") - add_definitions( -DWSL_MY_PRIVATE_CONFIG="~/my_private_config.h" ) -endif() - -# end of search for my_private_config.h - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) - - -# copy enc28j60 component. This section can be removed if never using the enc28j60 -if(EXISTS "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") - message(STATUS "Found directory ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") -else() - message(STATUS "Making directory ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") - make_directory( "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") -endif() - - -if(EXISTS "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/enc28j60.h") - message(STATUS "Found ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/enc28j60.h") - -elseif(EXISTS "$ENV{IDF_PATH}/examples/ethernet/enc28j60/components/eth_enc28j60/") - message(STATUS "Copying files ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") - file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/components/eth_enc28j60/" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/" FILES_MATCHING PATTERN "*") - -elseif (EXISTS "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/") - # some versions of the ESP-IDF (typically prior to 4.4) don't have the eth_enc28j60 in a component directory,rather just an example - file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/enc28j60.h" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") - file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/esp_eth_enc28j60.h" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") - file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/esp_eth_mac_enc28j60.c" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") - file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/esp_eth_phy_enc28j60.c" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") -endif() -# END OF enc28j60 - -project(ESP32-SSH-Server) - - -# check to see if there's both a local copy and EDP-IDF copy of the wolfssl and/or wolfssh components -if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) - message(STATUS "") - message(STATUS "WARNING: Found components/wolfssl in both local project and IDF_PATH") - message(STATUS "") -endif() - -if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssh/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssh/" ) - message(STATUS "") - message(STATUS "WARNING: Found components/wolfssh in both local project and IDF_PATH") - message(STATUS "") -endif() -# end multiple component check - -# some checks on wolfSSL and wolfSSH user settings. -# Note the components could live in either ESP IDF or local project component directory -# for sanity, choose only one location. - -if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/include/user_settings.h" ) - message("user_settings.h found in ${CMAKE_HOME_DIRECTORY}/components/wolfssl/ ") - - if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssh/include/user_settings.h" ) - message("user_settings.h found in ${CMAKE_HOME_DIRECTORY}/components/wolfssh/ ") - - execute_process( COMMAND ${CMAKE_COMMAND} -E compare_files "${CMAKE_HOME_DIRECTORY}/components/wolfssl/include/user_settings.h" "${CMAKE_HOME_DIRECTORY}/components/wolfssh/include/user_settings.h" RESULT_VARIABLE WOLFSSH_WOLFSSL_COMPARE ) - - if( WOLFSSH_WOLFSSL_COMPARE EQUAL 0) - message("Confirmed wolfSSL and wolfSSH user_settings.h match in local project.") - elseif( WOLFSSH_WOLFSSL_COMPARE EQUAL 1) - message( "" ) - message("WARNING: wolfSSL and wolfSSH user_settings.h DO NOT MATCH in local project.") - message( "" ) - else() - message("Error while comparing wolfSSL and wolfSSH user_settings.h files in local project.") - endif() - else() - message( "" ) - message("WARNING: wolfSSH user_settings.h not found inlocal project.") - message( "" ) - endif() - -endif() - -if( EXISTS "$ENV{IDF_PATH}/components/wolfssl/include/user_settings.h" ) - message("user_settings.h found in $ENV{IDF_PATH}/components/wolfssl/ ") - - if( EXISTS "$ENV{IDF_PATH}/components/wolfssh/include/user_settings.h" ) - message("user_settings.h found in $ENV{IDF_PATH}/components/wolfssh/ ") - - execute_process( COMMAND ${CMAKE_COMMAND} -E compare_files "$ENV{IDF_PATH}/components/wolfssl/include/user_settings.h" "$ENV{IDF_PATH}/components/wolfssh/include/user_settings.h" RESULT_VARIABLE WOLFSSH_WOLFSSL_COMPARE ) - - if( WOLFSSH_WOLFSSL_COMPARE EQUAL 0) - message("Confirmed wolfSSL and wolfSSH user_settings.h match in ESP-IDF.") - elseif( WOLFSSH_WOLFSSL_COMPARE EQUAL 1) - message( "" ) - message("WARNING: wolfSSL and wolfSSH user_settings.h DO NOT MATCH in ESP-IDF.") - message( "" ) - else() - message("Error while comparing wolfSSL and wolfSSH user_settings.h files in ESP-IDF.") - endif() - else() - message( "" ) - message("WARNING: wolfSSH user_settings.h not found in ESP-IDF.") - message( "" ) - endif() -endif() -# end checks on wolfSSL and wolfSSH user settings. - - - -# END +# [wolfSSH Project]/CMakeLists.txt +# +# Copyright (C) 2006-2023 WOLFSSL Inc. +# +# This file is part of WOLFSSH. +# +# WOLFSSH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# WOLFSSH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# + +# 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) + + +# Optionall set location of your wolfssl and wolfssh repository source: +# set(WOLFSSL_ROOT "C:/workspace/wolfssl") +# set(WOLFSSH_ROOT "C:/workspace/wolfssh") + +#standard build +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") + +# less debugging +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA -DWOLFSSH_SHELL") +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_SHELL -DDEBUG_WOLFSSL") + +# full debugging; NO_RSA needed to RNG. See https://github.com/wolfSSL/wolfssh/pull/417 + +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA -DWOLFSSH_SHELL -DDEBUG_WOLFSSL") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_SHELL -DDEBUG_WOLFSSL") + +# hardware encryption +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA -DWOLFSSH_SHELL -DDEBUG_WOLFSSL -DWOLFSSL_ESP32WROOM32_CRYPT -DWOLFSSL_ESP32WROOM32_CRYPT_RSA_PRI -DWOLFSSL_ESP32WROOM32_CRYPT_DEBUG -DNO_WOLFSSL_ESP32WROOM32_CRYPT_HASH") + +# we'll look for a my_private_config.h in various environments +# we also assume that the file is added to the local .gitignore +# to ensure it is never inadvertently shared + +if(EXISTS "/c/workspace/my_private_config.h") + message(STATUS "found SYSPROGS_MY_PRIVATE_CONFIG") + add_definitions( -DSYSPROGS_MY_PRIVATE_CONFIG="/c/workspace/my_private_config.h" ) +endif() + +# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection. +set (PROTOCOL_EXAMPLES_DIR $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + +if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") +else() + message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +endif() +if(EXISTS "/workspace/my_private_config.h") + message(STATUS "found WINDOWS_MY_PRIVATE_CONFIG") + add_definitions( -DWINDOWS_MY_PRIVATE_CONFIG="/workspace/my_private_config.h" ) +endif() + +if(EXISTS "/mnt/c/workspace/my_private_config.h") + message(STATUS "found WSL_MY_PRIVATE_CONFIG") + add_definitions( -DWSL_MY_PRIVATE_CONFIG="/mnt/c/workspace/my_private_config.h" ) +endif() + +if(EXISTS "(~/my_private_config.h") + message(STATUS "found LINUX_MY_PRIVATE_CONFIG") + add_definitions( -DWSL_MY_PRIVATE_CONFIG="~/my_private_config.h" ) +endif() + +# end of search for my_private_config.h + + + +# copy enc28j60 component. This section can be removed if never using the enc28j60 +if(EXISTS "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") + message(STATUS "Found directory ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") +else() + message(STATUS "Making directory ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") + make_directory( "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") +endif() + + +if(EXISTS "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/enc28j60.h") + message(STATUS "Found ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/enc28j60.h") + +elseif(EXISTS "$ENV{IDF_PATH}/examples/ethernet/enc28j60/components/eth_enc28j60/") + message(STATUS "Copying files ${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60") + # file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/components/eth_enc28j60/" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/" FILES_MATCHING PATTERN "*") + +elseif (EXISTS "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/") + # some versions of the ESP-IDF (typically prior to 4.4) don't have the eth_enc28j60 in a component directory,rather just an example + # file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/enc28j60.h" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") + # file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/esp_eth_enc28j60.h" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") + # file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/esp_eth_mac_enc28j60.c" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") + # file(COPY "$ENV{IDF_PATH}/examples/ethernet/enc28j60/main/esp_eth_phy_enc28j60.c" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/eth_enc28j60/") +endif() +# END OF enc28j60 + + + +# check to see if there's both a local copy and EDP-IDF copy of the wolfssl and/or wolfssh components +if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) + message(STATUS "") + message(STATUS "WARNING: Found components/wolfssl in both local project and IDF_PATH") + message(STATUS "") +endif() + +if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssh/" AND EXISTS "$ENV{IDF_PATH}/components/wolfssh/" ) + message(STATUS "") + message(STATUS "WARNING: Found components/wolfssh in both local project and IDF_PATH") + message(STATUS "") +endif() +# end multiple component check + +# some checks on wolfSSL and wolfSSH user settings. +# Note the components could live in either ESP IDF or local project component directory +# for sanity, choose only one location. + +if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssl/include/user_settings.h" ) + message("user_settings.h found in ${CMAKE_HOME_DIRECTORY}/components/wolfssl/ ") + + if( EXISTS "${CMAKE_HOME_DIRECTORY}/components/wolfssh/include/user_settings.h" ) + message("user_settings.h found in ${CMAKE_HOME_DIRECTORY}/components/wolfssh/ ") + + execute_process( COMMAND ${CMAKE_COMMAND} -E compare_files "${CMAKE_HOME_DIRECTORY}/components/wolfssl/include/user_settings.h" "${CMAKE_HOME_DIRECTORY}/components/wolfssh/include/user_settings.h" RESULT_VARIABLE WOLFSSH_WOLFSSL_COMPARE ) + + if( WOLFSSH_WOLFSSL_COMPARE EQUAL 0) + message("Confirmed wolfSSL and wolfSSH user_settings.h match in local project.") + elseif( WOLFSSH_WOLFSSL_COMPARE EQUAL 1) + message( "" ) + message("WARNING: wolfSSL and wolfSSH user_settings.h DO NOT MATCH in local project.") + message( "" ) + # file(COPY "${CMAKE_HOME_DIRECTORY}/components/wolfssl/include/user_settings.h" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/wolfssh/include" ) + # message( "" ) + # message("WARNING: copied user_settings.h from wolfssl to wolfssh.") + # message( "" ) + else() + message("Error while comparing wolfSSL and wolfSSH user_settings.h files in local project.") + endif() + else() + message( "" ) + # Although wolSSH in general may need user_settings for both components, we don't want that for Espressif. + # For reference: + # file(COPY "${CMAKE_HOME_DIRECTORY}/components/wolfssl/include/user_settings.h" DESTINATION "${CMAKE_HOME_DIRECTORY}/components/wolfssh/include/user_settings.h" ) + # message("WARNING: wolfSSH user_settings.h not found in local project, copied from wolfssl.") + # message( "" ) + endif() + +endif() +if (EXISTS "${PROTOCOL_EXAMPLES_DIR}") + message("Found PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") + set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFOUND_PROTOCOL_EXAMPLES_DIR") +else() + message("NOT FOUND: PROTOCOL_EXAMPLES_DIR=${PROTOCOL_EXAMPLES_DIR}") +endif() + +if( EXISTS "$ENV{IDF_PATH}/components/wolfssl/include/user_settings.h" ) + message("user_settings.h found in $ENV{IDF_PATH}/components/wolfssl/ ") + + if( EXISTS "$ENV{IDF_PATH}/components/wolfssh/include/user_settings.h" ) + message("user_settings.h found in $ENV{IDF_PATH}/components/wolfssh/ ") + + execute_process( COMMAND ${CMAKE_COMMAND} -E compare_files "$ENV{IDF_PATH}/components/wolfssl/include/user_settings.h" "$ENV{IDF_PATH}/components/wolfssh/include/user_settings.h" RESULT_VARIABLE WOLFSSH_WOLFSSL_COMPARE ) + + if( WOLFSSH_WOLFSSL_COMPARE EQUAL 0) + message("Confirmed wolfSSL and wolfSSH user_settings.h match in ESP-IDF.") + elseif( WOLFSSH_WOLFSSL_COMPARE EQUAL 1) + message( "" ) + message("WARNING: wolfSSL and wolfSSH user_settings.h DO NOT MATCH in ESP-IDF.") + message( "" ) + else() + message("Error while comparing wolfSSL and wolfSSH user_settings.h files in ESP-IDF.") + endif() + else() + message( "" ) + message("WARNING: wolfSSH user_settings.h not found in ESP-IDF.") + message( "" ) + endif() +endif() +# end checks on wolfSSL and wolfSSH user settings. + + + +# END + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +project(ESP32-SSH-Server) diff --git a/Espressif/ESP32/ESP32-SSH-Server/ESP32-SSH-Server.sln b/Espressif/ESP32/ESP32-SSH-Server/ESP32-SSH-Server.sln deleted file mode 100644 index 26dff24..0000000 --- a/Espressif/ESP32/ESP32-SSH-Server/ESP32-SSH-Server.sln +++ /dev/null @@ -1,87 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31729.503 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{803FD0C6-D64E-4E16-9DC3-1DAEC859A3D2}") = "ESP32-SSH-Server", "ESP32-SSH-Server.vgdbproj", "{728C8318-BF85-4301-B284-65C18C401679}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A4406E39-586C-411E-B4A7-52E03034EF56}" - ProjectSection(SolutionItems) = preProject - CMakeLists.txt = CMakeLists.txt - README.md = README.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wolfSSH", "wolfSSH", "{321B8A01-BBCB-4F97-94A7-4895EA1E0C50}" - ProjectSection(SolutionItems) = preProject - components\wolfssh\CMakeLists.txt = components\wolfssh\CMakeLists.txt - components\wolfssh\component.mk = components\wolfssh\component.mk - components\wolfssh\include\config.h = components\wolfssh\include\config.h - components\wolfssh\wolfssh\settings.h = components\wolfssh\wolfssh\settings.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wolfSSL", "wolfSSL", "{B49CD6BD-202F-4958-9841-08480C15F1D8}" - ProjectSection(SolutionItems) = preProject - components\wolfssl\CMakeLists.txt = components\wolfssl\CMakeLists.txt - components\wolfssl\component.mk = components\wolfssl\component.mk - components\wolfssl\include\config.h = components\wolfssl\include\config.h - components\wolfssl\wolfssl\options.h = components\wolfssl\wolfssl\options.h - components\wolfssl\include\user_settings.h = components\wolfssl\include\user_settings.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "main", "main", "{D743A727-34E4-4B25-A06A-C4ACFE57F974}" - ProjectSection(SolutionItems) = preProject - main\CMakeLists.txt = main\CMakeLists.txt - main\component.mk = main\component.mk - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "openocd", "openocd", "{68AE1391-9701-4920-BEE8-D2163474C23D}" - ProjectSection(SolutionItems) = preProject - openocd\scripts\interface\README.md = openocd\scripts\interface\README.md - openocd\scripts\interface\tigard.cfg = openocd\scripts\interface\tigard.cfg - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "enc28j60", "enc28j60", "{98FA323D-E2DE-458E-8571-5F418454BFBE}" - ProjectSection(SolutionItems) = preProject - components\eth_enc28j60\CMakeLists.txt = components\eth_enc28j60\CMakeLists.txt - components\eth_enc28j60\component.mk = components\eth_enc28j60\component.mk - components\eth_enc28j60\README.md = components\eth_enc28j60\README.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "include", "include", "{431C46B7-E036-4E15-BFB8-F522A7EFC090}" - ProjectSection(SolutionItems) = preProject - components\wolfssh\include\README.md = components\wolfssh\include\README.md - components\wolfssh\include\user_settings.h = components\wolfssh\include\user_settings.h - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|VisualGDB = Debug|VisualGDB - Release|VisualGDB = Release|VisualGDB - Tests (Debug)|VisualGDB = Tests (Debug)|VisualGDB - Tests (Release)|VisualGDB = Tests (Release)|VisualGDB - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {728C8318-BF85-4301-B284-65C18C401679}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB - {728C8318-BF85-4301-B284-65C18C401679}.Debug|VisualGDB.Build.0 = Debug|VisualGDB - {728C8318-BF85-4301-B284-65C18C401679}.Release|VisualGDB.ActiveCfg = Release|VisualGDB - {728C8318-BF85-4301-B284-65C18C401679}.Release|VisualGDB.Build.0 = Release|VisualGDB - {728C8318-BF85-4301-B284-65C18C401679}.Tests (Debug)|VisualGDB.ActiveCfg = Tests (Debug)|VisualGDB - {728C8318-BF85-4301-B284-65C18C401679}.Tests (Debug)|VisualGDB.Build.0 = Tests (Debug)|VisualGDB - {728C8318-BF85-4301-B284-65C18C401679}.Tests (Release)|VisualGDB.ActiveCfg = Tests (Release)|VisualGDB - {728C8318-BF85-4301-B284-65C18C401679}.Tests (Release)|VisualGDB.Build.0 = Tests (Release)|VisualGDB - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {321B8A01-BBCB-4F97-94A7-4895EA1E0C50} = {A4406E39-586C-411E-B4A7-52E03034EF56} - {B49CD6BD-202F-4958-9841-08480C15F1D8} = {A4406E39-586C-411E-B4A7-52E03034EF56} - {D743A727-34E4-4B25-A06A-C4ACFE57F974} = {A4406E39-586C-411E-B4A7-52E03034EF56} - {68AE1391-9701-4920-BEE8-D2163474C23D} = {A4406E39-586C-411E-B4A7-52E03034EF56} - {98FA323D-E2DE-458E-8571-5F418454BFBE} = {A4406E39-586C-411E-B4A7-52E03034EF56} - {431C46B7-E036-4E15-BFB8-F522A7EFC090} = {321B8A01-BBCB-4F97-94A7-4895EA1E0C50} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B966C21F-D281-4250-A450-1915EC531B0A} - EndGlobalSection -EndGlobal diff --git a/Espressif/ESP32/ESP32-SSH-Server/README.md b/Espressif/ESP32/ESP32-SSH-Server/README.md index 802a570..5b28fb5 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/README.md +++ b/Espressif/ESP32/ESP32-SSH-Server/README.md @@ -1,726 +1,749 @@ -# ESP32 SSH Server - -Connect to Tx/Rx pins on [Espressif ESP32](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/index.html) -UART via remote SSH. -There's also an [ESP8266 Version](../../ESP8266/ESP8266-SSH-Server/README.md). - -This particular example utilizes the sample application for the [Espressif Wired ENC28J60 Ethernet](https://github.com/espressif/esp-idf/tree/master/examples/ethernet/enc28j60) -as well as the [Getting Started - Wi-Fi Station Example](https://github.com/espressif/esp-idf/tree/master/examples/wifi/getting_started/station) -and includes the [wolfSSH library](https://github.com/wolfssl/wolfssh) from [wolfSSL](https://www.wolfssl.com/). -Additional information is available in [wolfSSL INSTALL](https://github.com/wolfSSL/wolfssl/blob/master/INSTALL). - -See [tweet thread](https://twitter.com/gojimmypi/status/1510703484886085633?s=20&t=SuiFcn672jlhXtCVh0lRRw). - -There's an [ESP-IDF wolfSSH component install in IDE/Espressif/ESP-IDF](https://github.com/wolfSSL/wolfssh/blob/master/ide/Espressif/ESP-IDF/setup_win.bat) for Windows. -and [an install for Linux](https://github.com/wolfSSL/wolfssh/blob/master/ide/Espressif/ESP-IDF/setup.sh). - -See also the related [ESP-IDF wolfSSL component install](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF) for both Windows and bash scripts -as well as the [wolfcrypt port to Espressif](https://github.com/wolfSSL/wolfssl/blob/master/wolfcrypt/src/port/Espressif/README.md). - -[wolfSSL ESP32 Hardware Acceleration Support](https://www.wolfssl.com/wolfssl-esp32-hardware-acceleration-support/) - - -## Linux Quick Start - -This project does not yet work with ESP-IDF Version 5.x. - -``` -#!/bin/bash - -# Make sure you re-login to enable read and write permissions for the serial port. -sudo usermod -a -G dialout $USER - -# get ESP-IDF version 4.1.1 -mkdir -p ~/esp -cd ~/esp -git clone -b v4.4.1 --recursive https://github.com/espressif/esp-idf.git --depth 1 - -cd ~/esp/esp-idf -./install.sh esp32 - -. ./export.sh - -# get wolfssl and wolfssh -mkdir -p ~/workspace -cd ~/workspace -git clone --recursive https://github.com/wolfssl/wolfssl.git --depth 1 -git clone --recursive https://github.com/wolfssl/wolfssh.git --depth 1 - -git clone https://github.com/wolfssl/wolfssh-examples.git --depth 1 - -cd ~/workspace/wolfssl/IDE/Espressif/ESP-IDF -./setup.sh - -cd ~/workspace/wolfssh/ide/Espressif/ESP-IDF -./setup.sh - -cd ~/workspace/wolfssh-examples/Espressif/ESP32/ESP32-SSH-Server -idf.py build - -# Reminder that WSL USB devices are called /dev/ttySn and not /dev/TTYUSBn -# For example, on Windows, COM15 is ttyS15 in WSL. -idf.py -p /dev/ttyUSB0 flash - -``` - -config files needed: - -``` -components/wolfssh/include/user_settings.h -components/wolfssl/include/user_settings.h -components/wolfssl/wolfssl/options.h -``` - - -## Requirements - -[ESP-IDF Version 4.x](https://docs.espressif.com/projects/esp-idf/en/v4.4.1/esp32/index.html) - -Any ESP32 with available UART pins other than USB / Console. The default is -`U2TXD` = `TXD_PIN` = `GPIO_NUM_17` -and -`U2RXD` = `RXD_PIN` = `GPIO_NUM_16` -defined in the [main/ssh_server_config.h](./main/ssh_server_config.h) file. - -Although there's no notion of a "speed" setting in SSH, our UART bridge needs to have one set. -The `BAUD_RATE` for the target board is defined in [main/ssh_server_config.h](./main/ssh_server_config.h) -and is typically: `#define BAUD_RATE (57600)`. -Serial port console monitoring port is typically 74800 baud, 8N1. - -For more details on the UARTs and the ESP32 in general, refer to the -[ESP32 Technical Reference Manual](https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf) - - - -## Private Config - -It is usually best to not publish private SSID names and passwords to GitHub. -As such the project [CMakeLists.txt](./CMakeLists.txt) looks for one of these files, in this order: - -``` -# VisualGDB default -/c/workspace/my_private_config.h - -# Windows -/workspace/my_private_config.h - -# WSL -/mnt/c/workspace/my_private_config.h - -# Linux -~/my_private_config.h -``` - -If no `my_private_config.h` file is found, default values are used. See [my_config.h](./main/my_config.h) - - -## Building - -The [project](ESP32-SSH-Server.vgdbproj) -was developed in Visual Studio with the [Sysprogs VisualGDB](https://visualgdb.com/) extension. -Just open the solution file in the [wolfssl-examples/ESP32-SSH-Server](./README.md) directory. -Right-click the project and "Build...": - -![ssh_uart_ESP32_VisualGDB_build.png](./images/ssh_uart_ESP32_VisualGDB_build.png) - -Alternatively, the code can be built via the [ESP-IDF for ESP32](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/index.html). - -VisualGDB will typically use the `sdkconfig-debug` (and possibly `sdkconfig-release`), -but the ESP-IDF commandline will use `sdkconfig`. - -Note for wired ethernet, the ENC28J60 component make not be available in some versions of the ESP-IDF. See below: [Wired Ethernet Notes](#wired-ethernet-enc28j60-notes). - - - -## ESP32 Toolchain - -This section is only needed for users not using VisualGDB. Otherwise, see the [VisualGDB Tutorials](https://visualgdb.com/w/tutorials/tag/esp32/). - -This project does not yet work with ESP-IDF Version 5.x. - -Install Version 4.4 of [ESP32 ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32/get-started/index.html). - -*NOTE:* This project has NOT yet been migrated to Version 5.0 ofthe ESP-IDF. -See the [Migration Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/build-system.html) - -To use a dual Windows/Linux (WSL) option, consider a shared directory such as `C:\ESP32\esp\` -which would be `/mnt/c/ESP32/esp/` in WSL. - -Note there may be an old version of wolfSSL in `ESP32\components\esp-wolfssl` that should be deleted. - -Windows/DOS - -Note the `IDF_PATH` may alrteady be set if calling from the installed shortcut -(typically in `C:\Users\%USERNAME%\.espressif\idf_cmd_init.bat`) - -```batch -SET IDF_PATH=C:\Users\%username%\Desktop\esp-idf -SET WORKSPACE=C:\workspace -``` -WSL - -```bash -export IDF_PATH=/mnt/c/Users/$USER/Desktop/esp-idf -export WORKSPACE=/mnt/c/workspace -``` - -Linux - -```bash -export IDF_PATH=~/esp-idf -export WORKSPACE=~/workspace -``` - - -## Configuration - -See the [ssh_server_config.h](./main/ssh_server.h) files for various configuration settings. - -For a wired ethernet connection, see `#define USE_ENC28J60`. When not defined, WiFi is assumed. - -Currently 3 specific target boards confirmed to be working: -a default [ESP32-WROOM board](https://www.espressif.com/en/producttype/esp32-wroom-32), -the [Radiona ULX3S](https://www.crowdsupply.com/radiona/ulx3s), -and the [M5Stack Stick-C](https://shop.m5stack.com/products/stick-c) - -``` -#undef ULX3S -#undef M5STICKC -#ifdef M5STICKC - /* reminder GPIO 34 to 39 are input only */ - #define TXD_PIN (GPIO_NUM_26) /* orange */ - #define RXD_PIN (GPIO_NUM_36) /* yellow */ -#elif ULX3S - /* reminder GPIO 34 to 39 are input only */ - #define TXD_PIN (GPIO_NUM_32) /* orange */ - #define RXD_PIN (GPIO_NUM_33) /* yellow */ -#else - #define TXD_PIN (GPIO_NUM_17) /* orange */ - #define RXD_PIN (GPIO_NUM_16) /* yellow */ -#endif -``` - -#### RSA - -RSA is enabled unless otherwise specified. RSA is disabled for this project. - -To enable RSA, remove both definitions `WOLFSSH_NO_RSA` and `NO_RSA` at compile time. -See the [CMakeLists.txt](./CMakeLists.txt) and [main/CMakeLists.txt](./main/CMakeLists.txt): - -``` -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA") -``` - - - -## Defaults - -The default users and passwords are the same as in the [linux server.c example](https://github.com/wolfSSL/wolfssh/blob/8a714b2864e6b5c623da2851af5b5c2d0f9b186b/examples/server/server.c#L412): - -User: `jill` password: `upthehill` -User: `jack` password: `fetchapail` - -When using ECC or RSA keys, the users are `hansel` and `gretel`. (see `samplePublicKeyEccBuffer`) - -When in AP mode, the demo SSID is `TheBucketHill` and the wifi password is `jackorjill`. -Unlike the STA mode, where the device needs to get an IP address from DHCP, in AP mode -the IP address is `192.168.4.1`. The computer connecting will likely get an address of `192.168.4.2`. -See the [main/ssh_server_config.h](./main/ssh_server_config.h) -to define `WOLFSSH_SERVER_IS_AP` or `WOLFSSH_SERVER_IS_STA`. - -The default SSH port for this demo is `22222` and is defined in [main/ssh_server_config.h](./main/ssh_server_config.h). - - - - -## Connecting - -Example to connect from Linux with a password: - -```bash -ssh jill@192.168.75.39 -p 22222 -``` - -If the SSH Server is configured for RSA Algorithm but you've turned that off in favor -or more modern and secure algorithms, you'll need to use something like this to connect: - -```bash -ssh -o"PubkeyAcceptedAlgorithms +ssh-rsa" -o"HostkeyAlgorithms +ssh-rsa" -p22222 jill@192.168.4.2 -``` - -When using ecc, this sample app uses the key `static const unsigned char ecc_key_der_256[]` found -in [components/wolfssh/wolfssh/certs_test.h](https://github.com/wolfSSL/wolfssh/blob/master/wolfssh/certs_test.h) -See `load_key()` in [main/ssh_server.c](./main/ssh_server.c). See also the sample keys in -[wolfssl/certs_test.h](https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h) which are -[generated](https://github.com/wolfSSL/wolfssl/blob/master/scripts/dertoc.pl) from -[wolfssl/certs](https://github.com/wolfSSL/wolfssl/tree/master/certs) - -There's currently no capability of saving new user keys, so `ssh-copy-id` will not work. - -Linux users note [this resource](http://sensornodeinfo.rockingdlabs.com/blog/2016/01/19/baud74880/) may be helpful for connecting at 74800 baud: - -```bash -git clone https://gist.github.com/3f1a984533556cf890d9.git anybaud -cd anybaud -gcc gistfile.c -o anybaud -anybaud /dev/ttyUSB0 74880 -``` - - -## Quick Start - -For convenience ONLY, there's a [static copy of wolfSSL components](https://github.com/gojimmypi/wolfssh/tree/ESP32_Development/examples/ESP32-SSH-Server/components/). - -DO NOT USE those static components for anything other than this demo. -At some point, the code could contain critical, unresolved CVEs that are fixed -in the current release. To ensure robust security, -install recent code into the Espressif components directory and -delete your local copy found in `examples/ESP32-SSH-Server/components/` - -WSL Quick Start - -```bash -# change to whatever directory you use for projects - -if [ "$WORKSPACE" == "" ]; then read -p "WORKSPACE not set?"; fi -cd $WORKSPACE - -git clone https://github.com/wolfssl/wolfssh-examples.git -cd ./wolfssh-examples/Espressif/ESP32-SSH-Server - -# Reminder that WSL USB devices are called /dev/ttySn and not /dev/TTYUSBn -# For example, on Windows, COM15 is ttyS15 in WSL. -idf.py -p /dev/ttyS15 -baud 460800 flash - -``` - - -## Wired Ethernet ENC28J60 Notes - -The Espressif ENC28J60 library may not be included in the [components/esp_eth/include](https://github.com/espressif/esp-idf/tree/master/components/esp_eth/include) directory, -depending on the latest release install, but the [example component](https://github.com/espressif/esp-idf/tree/master/examples/ethernet/enc28j60/components/eth_enc28j60) -can be copied to the ESP-IDF. - -The earliest release that [includes that directory is Version 4.4](https://github.com/espressif/esp-idf/tree/release/v4.4/examples/ethernet/enc28j60/components/eth_enc28j60). - -The [CMakeLists.txt](./CMakeLists.txt) should be able to copy the components when running `cmake .` in the project directory. Otherwise, the files may need to be manually copied -to the local ESP-IDF `components` directory. - -Note some early versions may not properly get an IP address, so it is best to use the most recent even if the files need to be manually copied into an older ESP-IDF. - -## Operational Status - -Unlike the ESP8266 that needs to have a [shell game of UARTs](https://gojimmypi.github.io/SSH-to-ESP8266/), -the ESP32 is much more graceful. The console port at boot time should look like this: - - -```text -ets Jun 8 2016 00:22:57 - -rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) -configsip: 0, SPIWP:0xee -clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 -mode:DIO, clock div:2 -load:0x3fff0030,len:6628 -load:0x40078000,len:14780 -load:0x40080400,len:3792 -entry 0x40080694 -I (26) boot: ESP-IDF v4.4-263-g000d3823bb-dirty 2nd stage bootloader -I (26) boot: compile time 20:42:35 -I (26) boot: chip revision: 1 -I (31) boot_comm: chip revision: 1, min. bootloader chip revision: 0 -I (38) boot.esp32: SPI Speed : 40MHz -I (43) boot.esp32: SPI Mode : DIO -I (47) boot.esp32: SPI Flash Size : 4MB -I (52) boot: Enabling RNG early entropy source... -I (57) boot: Partition Table: -I (61) boot: ## Label Usage Type ST Offset Length -I (68) boot: 0 nvs WiFi data 01 02 00009000 00006000 -I (75) boot: 1 phy_init RF data 01 01 0000f000 00001000 -I (83) boot: 2 factory factory app 00 00 00010000 00100000 -I (90) boot: End of partition table -I (95) boot_comm: chip revision: 1, min. application chip revision: 0 -I (102) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1d850h (120912) map -I (154) esp_image: segment 1: paddr=0002d878 vaddr=3ffb0000 size=027a0h ( 10144) load -I (158) esp_image: segment 2: paddr=00030020 vaddr=400d0020 size=93314h (602900) map -I (378) esp_image: segment 3: paddr=000c333c vaddr=3ffb27a0 size=05ed0h ( 24272) load -I (388) esp_image: segment 4: paddr=000c9214 vaddr=40080000 size=15148h ( 86344) load -I (423) esp_image: segment 5: paddr=000de364 vaddr=50000000 size=00010h ( 16) load -I (435) boot: Loaded app from partition at offset 0x10000 -I (435) boot: Disabling RNG early entropy source... -I (447) cpu_start: Pro cpu up. -I (447) cpu_start: Starting app cpu, entry point is 0x4008127c -I (0) cpu_start: App cpu up. -I (461) cpu_start: Pro cpu start user code -I (461) cpu_start: cpu freq: 160000000 -I (461) cpu_start: Application information: -I (466) cpu_start: Project name: ESP32-SSH-Server -I (471) cpu_start: App version: v1.4.7-stable-166-g4555602-dirt -I (478) cpu_start: Compile time: May 4 2022 21:43:35 -I (484) cpu_start: ELF file SHA256: 84344e5745864c4b... -I (490) cpu_start: ESP-IDF: v4.4-263-g000d3823bb-dirty -I (497) heap_init: Initializing. RAM available for dynamic allocation: -I (504) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM -I (510) heap_init: At 3FFBD360 len 00022CA0 (139 KiB): DRAM -I (517) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM -I (523) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM -I (529) heap_init: At 40095148 len 0000AEB8 (43 KiB): IRAM -I (537) spi_flash: detected chip: generic -I (540) spi_flash: flash io: dio -I (545) cpu_start: Starting scheduler on PRO CPU. -I (0) cpu_start: Starting scheduler on APP CPU. -I (555) SSH Server main: Begin main init. -I (555) SSH Server main: wolfSSH debugging on. -I (565) SSH Server main: wolfSSL debugging on. -I (575) wolfssl: Debug ON -I (575) SSH Server main: Begin init_UART. -I (575) SSH Server main: End init_UART. -I (585) SSH Server main: Setting up nvs flash for WiFi. -I (625) SSH Server main: Begin setup WiFi Soft AP. -I (635) wifi:wifi driver task: 3ffd3c74, prio:23, stack:6656, core=0 -I (635) system_api: Base MAC address is not set -I (635) system_api: read default base MAC address from EFUSE -I (655) wifi:wifi firmware version: 71cb2c8 -I (655) wifi:wifi certification version: v7.0 -I (655) wifi:config NVS flash: enabled -I (655) wifi:config nano formating: disabled -I (665) wifi:Init data frame dynamic rx buffer num: 32 -I (665) wifi:Init management frame dynamic rx buffer num: 32 -I (675) wifi:Init management short buffer num: 32 -I (675) wifi:Init dynamic tx buffer num: 32 -I (685) wifi:Init static rx buffer size: 1600 -I (685) wifi:Init static rx buffer num: 10 -I (685) wifi:Init dynamic rx buffer num: 32 -I (695) wifi_init: rx ba win: 6 -I (695) wifi_init: tcpip mbox: 32 -I (705) wifi_init: udp mbox: 6 -I (705) wifi_init: tcp mbox: 6 -I (705) wifi_init: tcp tx win: 5744 -I (715) wifi_init: tcp rx win: 5744 -I (715) wifi_init: tcp mss: 1440 -I (715) wifi_init: WiFi IRAM OP enabled -I (725) wifi_init: WiFi RX IRAM OP enabled -I (735) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07 -I (835) wifi:mode : softAP (7c:9e:bd:65:5d:dd) -I (835) wifi:Total power save buffer number: 16 -I (835) wifi:Init max length of beacon: 752/752 -I (845) wifi:Init max length of beacon: 752/752 -I (845) wifi station: wifi_init_softap finished. SSID:TheBucketHill password:jackorjill channel:1 -I (855) SSH Server main: End setup WiFi Soft AP. -I (855) wolfssl: sntp_setservername: -I (865) wolfssl: pool.ntp.org -I (865) wolfssl: time.nist.gov -I (865) wolfssl: utcnist.colorado.edu -I (875) wolfssl: sntp_init done. -I (875) wolfssl: inet_pton -I (875) wolfssl: wolfSSL Entering wolfCrypt_Init -I (885) wolfssl: wolfSSH Server main loop heartbeat! -I (895) wolfssl: InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled -I (895) wolfssl: InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled -I (905) wolfssl: Debug ON v0.2b -I (935) wolfssl: socket creation successful -I (945) wolfssl: setsockopt re-use addr successful -I (945) wolfssl: SO_REUSEPORT not configured for setsockopt to re-use port - -I (945) wolfssl: socket bind successful. -I (945) wolfssl: socket listen successful - -I (965) wolfssl: wolfSSL Entering GetAlgoId - -``` - -Upon a successful remote connection to our embedded SSH Server as a WiFi Access Point, -the console monitoring port should show something like this: - -```text - -I (945) wolfssl: socket bind successful. -I (945) wolfssl: socket listen successful - -I (945) wolfssl: wolfSSL Entering GetAlgoId -I (10895) wolfssl: wolfSSH Server main loop heartbeat! -I (20895) wolfssl: wolfSSH Server main loop heartbeat! -I (30895) wolfssl: wolfSSH Server main loop heartbeat! -I (40895) wolfssl: wolfSSH Server main loop heartbeat! -I (50895) wolfssl: wolfSSH Server main loop heartbeat! -I (60895) wolfssl: wolfSSH Server main loop heartbeat! -I (68565) wifi:new:<1,1>, old:<1,1>, ap:<1,1>, sta:<255,255>, prof:1 -I (68565) wifi:station: [mac address] join, AID=1, bgn, 40U -I (68585) wifi station: station [mac address] join, AID=1 -I (68995) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4 .2 -W (70505) wifi:idx:2 (ifx:1, [mac address]), tid:0, ssn:61, winSize: 64 -I (70895) wolfssl: wolfSSH Server main loop heartbeat! -I (80895) wolfssl: wolfSSH Server main loop heartbeat! -I (90895) wolfssl: wolfSSH Server main loop heartbeat! -I (100895) wolfssl: wolfSSH Server main loop heartbeat! -I (104865) wolfssl: server_worker started. -I (104865) wolfssl: Start NonBlockSSH_accept -I (104905) wolfssl: wolfSSL Entering GetAlgoId -I (105225) wolfssl: wolfSSL Entering wc_ecc_shared_secret_gen_sync -I (105515) wolfssl: wolfSSL Leaving wc_ecc_shared_secret_gen_sync, return 0 -I (105515) wolfssl: wolfSSL Leaving wc_ecc_shared_secret_ex, return 0 -I (110895) wolfssl: wolfSSH Server main loop heartbeat! -I (116395) wolfssl: Exit NonBlockSSH_accept -I (116395) wolfssl: InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled -I (116415) wolfssl: Tx UART! -I (120895) wolfssl: wolfSSH Server main loop heartbeat! - -``` - -When the SSH server is running, but nothing interesting is happening, the main thread will continue to periodically -show a message: - -```text -I (2621868) wolfssl: wolfSSH Server main loop heartbeat! -``` - - - - - -# ENC28J60 Example -(See the README.md file in the upper level 'examples' [directory](https://github.com/espressif/esp-idf/tree/master/examples) for more information about examples.) - -## Overview - -ENC28J60 is a standalone Ethernet controller with a standard SPI interface. This example demonstrates how to drive this controller as an SPI device and then attach to TCP/IP stack. - -This is also an example of how to integrate a new Ethernet MAC driver into the `esp_eth` component, without needing to modify the ESP-IDF component. - -If you have a more complicated application to go (for example, connect to some IoT cloud via MQTT), you can always reuse the initialization codes in this example. - -## How to use ENC28J60example - -### Hardware Required - -To run this example, you need to prepare following hardwares: -* [ESP32 board](https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards.html) (e.g. ESP32-PICO, ESP32 DevKitC, etc) -* ENC28J60 module (the latest revision should be 6) -* **!! IMPORTANT !!** Proper input power source since ENC28J60 is quite power consuming device (it consumes more than 200 mA in peaks when transmitting). If improper power source is used, input voltage may drop and ENC28J60 may either provide nonsense response to host controller via SPI (fail to read registers properly) or it may enter to some strange state in the worst case. There are several options how to resolve it: - * Power ESP32 board from `USB 3.0`, if board is used as source of power to ENC board. - * Power ESP32 board from external 5V power supply with current limit at least 1 A, if board is used as source of power to ENC board. - * Power ENC28J60 from external 3.3V power supply with common GND to ESP32 board. Note that there might be some ENC28J60 boards with integrated voltage regulator on market and so powered by 5 V. Please consult documentation of your board for details. - - If a ESP32 board is used as source of power to ENC board, ensure that that particular board is assembled with voltage regulator capable to deliver current up to 1 A. This is a case of ESP32 DevKitC or ESP-WROVER-KIT, for example. Such setup was tested and works as expected. Other boards may use different voltage regulators and may perform differently. - **WARNING:** Always consult documentation/schematics associated with particular ENC28J60 and ESP32 boards used in your use-case first. - -#### Pin Assignment - -* ENC28J60 Ethernet module consumes one SPI interface plus an interrupt GPIO. By default they're connected as follows: - -| GPIO | ENC28J60 | -| ------ | ----------- | -| GPIO19 | SPI_CLK | -| GPIO23 | SPI_MOSI | -| GPIO25 | SPI_MISO | -| GPIO22 | SPI_CS | -| GPIO4 | Interrupt | - -### Configure the project - -``` -idf.py menuconfig -``` - -In the `Example Configuration` menu, set SPI specific configuration, such as SPI host number, GPIO used for MISO/MOSI/CS signal, GPIO for interrupt event and the SPI clock rate, duplex mode. - -**Note:** According to ENC28J60 data sheet and our internal testing, SPI clock could reach up to 20MHz, but in practice, the clock speed may depend on your PCB layout/wiring/power source. In this example, the default clock rate is set to 8 MHz since some ENC28J60 silicon revisions may not properly work at frequencies less than 8 MHz. - -### Build, Flash, and Run - -Build the project and flash it to the board, then run monitor tool to view serial output: - -``` -idf.py -p PORT build flash monitor -``` - -(Replace PORT with the name of the serial port to use.) - -(To exit the serial monitor, type ``Ctrl-]``.) - -See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects. - -## Example Output - -```bash -I (0) cpu_start: Starting scheduler on APP CPU. -I (401) enc28j60: revision: 6 -I (411) esp_eth.netif.glue: 00:04:a3:12:34:56 -I (411) esp_eth.netif.glue: ethernet attached to netif -I (421) eth_example: Ethernet Started -I (2421) enc28j60: working in 10Mbps -I (2421) enc28j60: working in half duplex -I (2421) eth_example: Ethernet Link Up -I (2421) eth_example: Ethernet HW Addr 00:04:a3:12:34:56 -I (4391) esp_netif_handlers: eth ip: 192.168.2.34, mask: 255.255.255.0, gw: 192.168.2.2 -I (4391) eth_example: Ethernet Got IP Address -I (4391) eth_example: ~~~~~~~~~~~ -I (4391) eth_example: ETHIP:192.168.2.34 -I (4401) eth_example: ETHMASK:255.255.255.0 -I (4401) eth_example: ETHGW:192.168.2.2 -I (4411) eth_example: ~~~~~~~~~~~ -``` - -Now you can ping your ESP32 in the terminal by entering `ping 192.168.2.34` (it depends on the actual IP address you get). - -**Notes:** -1. ENC28J60 hasn't burned any valid MAC address in the chip, you need to write an unique MAC address into its internal MAC address register before any traffic happened on TX and RX line. -2. It is recommended to operate the ENC28J60 in full-duplex mode since various errata exist to the half-duplex mode (even though addressed in the example) and due to its poor performance in the half-duplex mode (especially in TCP connections). However, ENC28J60 does not support automatic duplex negotiation. If it is connected to an automatic duplex negotiation enabled network switch or Ethernet controller, then ENC28J60 will be detected as a half-duplex device. To communicate in Full-Duplex mode, ENC28J60 and the remote node (switch, router or Ethernet controller) **must be manually configured for full-duplex operation**: - * The ENC28J60 can be set to full-duplex in the `Example Configuration` menu. - * On Ubuntu/Debian Linux distribution use: - ``` - sudo ethtool -s YOUR_INTERFACE_NAME speed 10 duplex full autoneg off - ``` - * On Windows, go to `Network Connections` -> `Change adapter options` -> open `Properties` of selected network card -> `Configure` -> `Advanced` -> `Link Speed & Duplex` -> select `10 Mbps Full Duplex in dropdown menu`. -3. Ensure that your wiring between ESP32 board and the ENC28J60 board is realized by short wires with the same length and no wire crossings. -4. CS Hold Time needs to be configured to be at least 210 ns to properly read MAC and MII registers as defined by ENC28J60 Data Sheet. This is automatically configured in the example based on selected SPI clock frequency by computing amount of SPI bit-cycles the CS should stay active after the transmission. However, if your PCB design/wiring requires different value, please update `cs_ena_posttrans` member of `devcfg` structure per your actual needs. - - - - -## Known Issues - -If improper GPIO lines are selected, say when using the defaults but an M5Stick-C is being used, the UART initialization may hang. - -When plugged into a PC that goes to sleep and powers down the USB power, the ESP32 device seems to sometimes crash and does not always recover when PC power resumes. - -Only one connection is allowed at the time. There may be a delay when an existing connected is unexpecteedly terminated before a new connection can be made. - - - - -## Troubleshooting - -### termios.error: (5, 'Input/output error') - -Try a slower baud rate: - -``` -idf.py -b 115200 -p /dev/ttyS20 flash -``` - - -### fatal error: wolfssl/options.h: No such file or directory - -Many problems can originate in the configuration file. - -The `options.h` typically is not used. This error typically means there's an incorrection user_setting.h, or the `#DEFINE WOLFSSL_USER_SETTINGS` is missing. - -This may be a helpful line to add to the beginning of the [CMakeLists.txt](./CMakeLists.txt): - -``` -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") -``` - - -#### FreeRTOS-Kernel/include/freertos is not a directory - -The error `FreeRTOS-Kernel/include/freertos is not a directory` typically means there's an ESP-IDF component directory for wolfssl and/or woldssh -as well as a local project wolfssl and/or woldssh directory. - -``` -Make Error at /home/[USERNAME]/esp/esp-idf/tools/cmake/component.cmake:306 (message): - Include directory - '/home/[USERNAME]/workspace/wolfssh/examples/ESP32-SSH-Server/components/freertos/FreeRTOS-Kernel/include/freertos' - is not a directory. - -``` - -The wolfssl components should exist in only the ESP-IDF or the local project, but not both. - -#### error: unknown type name 'xSemaphoreHandle' - -There's a known problem with ESP-IDF 5.0 and FreeRTOS. - -``` -home/[USERNAME]/esp/esp-idf/components/wolfssl/wolfssl/wolfcrypt/wc_port.h:199:17: error: unknown type name 'xSemaphoreHandle' - typedef xSemaphoreHandle wolfSSL_Mutex; -``` -Start a new terminal session, otherwise you'll likely see `ERROR: This script was called from a virtual environment, can not create a virtual environment again` - -``` -idf.py --version -cd ~/esp/esp-idf -git branch -a -git checkout release/v4.4 -./install.sh -. ./export.sh -cd ~/workspace/wolfssh/examples/ESP32-SSH-Server -``` - -A more radical approach is to completely replace the ESP-IDF -with [version 4.4.1](https://docs.espressif.com/projects/esp-idf/en/v4.4.1/esp32/get-started/index.html#step-2-get-esp-idf). -``` -mkdir -p ~/esp4.4.1/ -cd ~/esp4.4.1/ -git clone -b v4.4.1 --recursive https://github.com/espressif/esp-idf.git -cd esp-idf -./install.sh esp32 -. ./export.sh -cd /workspace/wolfssh/examples/ESP32-SSH-Server -cd ~/workspace/wolfssh/examples/ESP32-SSH-Server -idf.py build -``` - -#### undefined reference to wc_GenerateSeed - -The error `undefined reference to wc_GenerateSeed` is often caused by a bad or missing `components\wolfssh\include\user_settings.h` file. -It is usually best to ensure the setting here exactly match the wolfssl file in `\components\wolfssl\include` unless there's a -compelling reason to do otherwise. - - -Although [Error -236](https://github.com/wolfSSL/wolfssl/blob/9b5ad6f218f657d8651a56b50b6db1b3946a811c/wolfssl/wolfcrypt/error-crypt.h#L189) -typically means "_RNG required but not provided_", the reality is the time is probably wrong. - -``` -wolfssl: wolfSSL Leaving wc_ecc_shared_secret_gen_sync, return -236 -wolfssl: wolfSSL Leaving wc_ecc_shared_secret_ex, return -236 -``` -If the time is set to a reasonable value, and the `-236` error is still occuring, check the [sdkconfig](sdkconfig) -file for unexpected changes, such as when using the EDP-IDF menuconfig. When in doubt, revert back to repo version. - -#### E (545) uart: uart_set_pin(605): tx_io_num error - -A message such as `E (545) uart: uart_set_pin(605): tx_io_num error` typically means the pins assigned to be a UART -Tx/Rx are either input-only or output-only. see [gpio_types.h_](https://github.com/espressif/esp-idf/blob/master/components/hal/include/hal/gpio_types.h) -for example GPIO Pins [34](https://github.com/espressif/esp-idf/blob/3aeb80acb66038f14fc2a7606e7516a3e2bfa6c9/components/hal/include/hal/gpio_types.h#L108) -to 39 are input only. - -``` -E (545) uart: uart_set_pin(605): tx_io_num error -ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x400870c4 -file: "../main/enc28j60_example_main.c" line 250 -func: init_UART -expression: uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE) - -``` - -If there are a lot of garbage characters on the UART Tx/Rx, ensure the proper baud rate, ground connection, and voltage level match. -The ESP32 is 3.3V and typically not 5V tolerant. No ground connection will often cause garbage characters on the UART. - -The error `serialException: could not open port` typically means that something else is using the COM port on Windows. -Check for running instances of Putty, etc. - -``` - File "C:\SysGCC\esp32\esp-idf\v4.4\python-env\lib\site-packages\serial\serialwin32.py", line 64, in open - raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError())) -serial.serialutil.SerialException: could not open port 'COM9': PermissionError(13, 'Access is denied.', None, 5) -``` - -#### Unexplainable panic_abort Received a SIGTRAP: Trace/breakpoint trap - -If after exhausting all other options, try erasing the ESP32 before reprogramming. - -``` -idf.py -p /dev/ttyS20 erase_flash -b 115200 -``` - - - - -## Support - -For any issues related to wolfSSL or wolfSSH, please open an [issue](https://github.com/wolfssl/wolfssl/issues) on GitHub, -visit the [wolfSSL support forum](https://www.wolfssl.com/forums/), -send an email to [support@wolfssl.com](mailto:support@wolfssl.com), -or [contact us](https://www.wolfssl.com/contact/). +# ESP32 SSH Server + +Connect to Tx/Rx pins on [Espressif ESP32](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/index.html) +UART via remote SSH. +There's also an [ESP8266 Version](../../ESP8266/ESP8266-SSH-Server/README.md). + +This particular example utilizes the sample application for the [Espressif Wired ENC28J60 Ethernet](https://github.com/espressif/esp-idf/tree/master/examples/ethernet/enc28j60) +as well as the [Getting Started - Wi-Fi Station Example](https://github.com/espressif/esp-idf/tree/master/examples/wifi/getting_started/station) +and includes the [wolfSSH library](https://github.com/wolfssl/wolfssh) from [wolfSSL](https://www.wolfssl.com/). +Additional information is available in [wolfSSL INSTALL](https://github.com/wolfSSL/wolfssl/blob/master/INSTALL). + +See [tweet thread](https://twitter.com/gojimmypi/status/1510703484886085633?s=20&t=SuiFcn672jlhXtCVh0lRRw). + +There's an [ESP-IDF wolfSSH component install in IDE/Espressif/ESP-IDF](https://github.com/wolfSSL/wolfssh/blob/master/ide/Espressif/ESP-IDF/setup_win.bat) for Windows. +and [an install for Linux](https://github.com/wolfSSL/wolfssh/blob/master/ide/Espressif/ESP-IDF/setup.sh). + +See also the related [ESP-IDF wolfSSL component install](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF) for both Windows and bash scripts +as well as the [wolfcrypt port to Espressif](https://github.com/wolfSSL/wolfssl/blob/master/wolfcrypt/src/port/Espressif/README.md). + +[wolfSSL ESP32 Hardware Acceleration Support](https://www.wolfssl.com/wolfssl-esp32-hardware-acceleration-support/) + +## Getting Started + +If you are new to wolfSSL on the Espressif ESP32, [this video](https://www.youtube.com/watch?v=CzwA3ZBZBZ8) +can help to get started: + +[![Video Preview](https://img.youtube.com/vi/CzwA3ZBZBZ8/0.jpg)](https://www.youtube.com/watch?v=CzwA3ZBZBZ8) + +See also the [core wolfSSL examples for Espressif](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif). + +## Requirements + +The [wolfSSL library](https://github.com/wolfssl/wolfssl) is needed for this wolfSSH example. Installation +can be either as a local repository or by using the [wolfSSL Managed Component](https://components.espressif.com/components/wolfssl/wolfssl). + +The Espressif development environment is needed: [ESP-IDF Version 4.x](https://docs.espressif.com/projects/esp-idf/en/v4.4.1/esp32/index.html) +or [ESP-IDF Version 5.x](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/). + +Any ESP32 with available UART pins other than USB / Console. The default is +`U2TXD` = `TXD_PIN` = `GPIO_NUM_17` +and +`U2RXD` = `RXD_PIN` = `GPIO_NUM_16` +defined in the [main/ssh_server_config.h](./main/ssh_server_config.h) file. + +Although there's no notion of a "speed" setting in SSH, our UART bridge needs to have one set. +The `BAUD_RATE` for the target board is defined in [main/ssh_server_config.h](./main/ssh_server_config.h) +and is typically: `#define BAUD_RATE (57600)`. +Serial port console monitoring port is typically 74800 baud, 8N1. + +For more details on the UARTs and the ESP32 in general, refer to the +[ESP32 Technical Reference Manual](https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf) + +## Private Config + +It is usually best to not publish private SSID names and passwords to GitHub. +As such the project [CMakeLists.txt](./CMakeLists.txt) looks for one of these files, in this order: + +``` +# VisualGDB default +/c/workspace/my_private_config.h + +# Windows +/workspace/my_private_config.h + +# WSL +/mnt/c/workspace/my_private_config.h + +# Linux +~/my_private_config.h +``` + +If no `my_private_config.h` file is found, default values are used. Use the `ESP-IDF menuconfig` to +set example values. + +## VisualGDB Quick Start + +See the project files in the [VisualGBD directory](./VisualGDB). Simply open the project file and +build. The default JTAG debugger is the [Open Source Tigard]https://github.com/tigard-tools/tigard?tab=readme-ov-file#tigard), +but other JTAG devices are expected to also work. + +## Linux Quick Start + +This updated example version now supports setting `WOLFSSL_ROOT` and `WOLFSSH_ROOT` as either environment +variables or in the project `CMakeLists.txt` like this: + +```cmake +set(WOLFSSL_ROOT "C:/workspace/wolfssl") +set(WOLFSSH_ROOT "C:/workspace/wolfssh") +``` + + +## Linux Quick Start - Installation of local files + +This method, although operational, is no longer recommended. See above for using the in-place +wolfSSL and wolfSSH source that can be used without copying to the local project. + +If you still want to have a local copy of wolfSSL _in_ you project, follow these steps: + +``` +#!/bin/bash + +# Make sure you re-login to enable read and write permissions for the serial port. +sudo usermod -a -G dialout $USER + +# get ESP-IDF version 4.1.1 +mkdir -p ~/esp +cd ~/esp +git clone -b v4.4.1 --recursive https://github.com/espressif/esp-idf.git --depth 1 + +cd ~/esp/esp-idf +./install.sh esp32 + +. ./export.sh + +# get wolfssl and wolfssh +mkdir -p ~/workspace +cd ~/workspace +git clone --recursive https://github.com/wolfssl/wolfssl.git --depth 1 +git clone --recursive https://github.com/wolfssl/wolfssh.git --depth 1 + +git clone https://github.com/wolfssl/wolfssh-examples.git --depth 1 + +cd ~/workspace/wolfssl/IDE/Espressif/ESP-IDF +./setup.sh + +cd ~/workspace/wolfssh/ide/Espressif/ESP-IDF +./setup.sh + +cd ~/workspace/wolfssh-examples/Espressif/ESP32/ESP32-SSH-Server +idf.py build + +# Reminder that WSL USB devices are called /dev/ttySn and not /dev/TTYUSBn +# For example, on Windows, COM15 is ttyS15 in WSL. +idf.py -p /dev/ttyUSB0 flash + +``` + +config files needed: + +``` +components/wolfssh/include/user_settings.h +components/wolfssl/include/user_settings.h +components/wolfssl/wolfssl/options.h +``` + + +## Building + +The [project](ESP32-SSH-Server.vgdbproj) +was developed in Visual Studio with the [Sysprogs VisualGDB](https://visualgdb.com/) extension. +Just open the solution file in the [wolfssl-examples/ESP32-SSH-Server](./README.md) directory. +Right-click the project and "Build...": + +![ssh_uart_ESP32_VisualGDB_build.png](./images/ssh_uart_ESP32_VisualGDB_build.png) + +Alternatively, the code can be built via the [ESP-IDF for ESP32](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/index.html). + +VisualGDB will typically use the `sdkconfig-debug` (and possibly `sdkconfig-release`), +but the ESP-IDF commandline will use `sdkconfig`. + +Note for wired ethernet, the ENC28J60 component make not be available in some versions of the ESP-IDF. See below: [Wired Ethernet Notes](#wired-ethernet-enc28j60-notes). + + + +## ESP32 Toolchain + +This section is only needed for users not using VisualGDB. Otherwise, see the [VisualGDB Tutorials](https://visualgdb.com/w/tutorials/tag/esp32/). + +To use a dual Windows/Linux (WSL) option, consider a shared directory such as `C:\ESP32\esp\` +which would be `/mnt/c/ESP32/esp/` in WSL. + +Note there may be an old version of wolfSSL in `ESP32\components\esp-wolfssl` that should be deleted. + +Windows/DOS + +Note the `IDF_PATH` may alrteady be set if calling from the installed shortcut +(typically in `C:\Users\%USERNAME%\.espressif\idf_cmd_init.bat`) + +```batch +SET IDF_PATH=C:\Users\%username%\Desktop\esp-idf +SET WORKSPACE=C:\workspace +``` +WSL + +```bash +export IDF_PATH=/mnt/c/Users/$USER/Desktop/esp-idf +export WORKSPACE=/mnt/c/workspace +``` + +Linux + +```bash +export IDF_PATH=~/esp-idf +export WORKSPACE=~/workspace +``` + + +## Configuration + +See the [ssh_server_config.h](./main/ssh_server.h) files for various configuration settings. + +For a wired ethernet connection, see `#define USE_ENC28J60`. When not defined, WiFi is assumed. + +Currently 3 specific target boards confirmed to be working: +a default [ESP32-WROOM board](https://www.espressif.com/en/producttype/esp32-wroom-32), +the [Radiona ULX3S](https://www.crowdsupply.com/radiona/ulx3s), +and the [M5Stack Stick-C](https://shop.m5stack.com/products/stick-c) + +``` +#undef ULX3S +#undef M5STICKC +#ifdef M5STICKC + /* reminder GPIO 34 to 39 are input only */ + #define TXD_PIN (GPIO_NUM_26) /* orange */ + #define RXD_PIN (GPIO_NUM_36) /* yellow */ +#elif ULX3S + /* reminder GPIO 34 to 39 are input only */ + #define TXD_PIN (GPIO_NUM_32) /* orange */ + #define RXD_PIN (GPIO_NUM_33) /* yellow */ +#else + #define TXD_PIN (GPIO_NUM_17) /* orange */ + #define RXD_PIN (GPIO_NUM_16) /* yellow */ +#endif +``` + +#### RSA + +RSA is enabled unless otherwise specified. RSA is disabled for this project. + +To enable RSA, remove both definitions `WOLFSSH_NO_RSA` and `NO_RSA` at compile time. +See the [CMakeLists.txt](./CMakeLists.txt) and [main/CMakeLists.txt](./main/CMakeLists.txt): + +``` +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DWOLFSSH_NO_RSA -DNO_RSA") +``` + + + +## Defaults + +The default users and passwords are the same as in the [linux server.c example](https://github.com/wolfSSL/wolfssh/blob/8a714b2864e6b5c623da2851af5b5c2d0f9b186b/examples/server/server.c#L412): + +User: `jill` password: `upthehill` +User: `jack` password: `fetchapail` + +When using ECC or RSA keys, the users are `hansel` and `gretel`. (see `samplePublicKeyEccBuffer`) + +When in AP mode, the demo SSID is `TheBucketHill` and the wifi password is `jackorjill`. +Unlike the STA mode, where the device needs to get an IP address from DHCP, in AP mode +the IP address is `192.168.4.1`. The computer connecting will likely get an address of `192.168.4.2`. +See the [main/ssh_server_config.h](./main/ssh_server_config.h) +to define `WOLFSSH_SERVER_IS_AP` or `WOLFSSH_SERVER_IS_STA`. + +The default SSH port for this demo is `22222` and is defined in [main/ssh_server_config.h](./main/ssh_server_config.h). + + + + +## Connecting + +Example to connect from Linux with a password: + +```bash +ssh jill@192.168.75.39 -p 22222 +``` + +If the SSH Server is configured for RSA Algorithm but you've turned that off in favor +or more modern and secure algorithms, you'll need to use something like this to connect: + +```bash +ssh -o"PubkeyAcceptedAlgorithms +ssh-rsa" -o"HostkeyAlgorithms +ssh-rsa" -p22222 jill@192.168.4.2 +``` + +When using ecc, this sample app uses the key `static const unsigned char ecc_key_der_256[]` found +in [components/wolfssh/wolfssh/certs_test.h](https://github.com/wolfSSL/wolfssh/blob/master/wolfssh/certs_test.h) +See `load_key()` in [main/ssh_server.c](./main/ssh_server.c). See also the sample keys in +[wolfssl/certs_test.h](https://github.com/wolfSSL/wolfssl/blob/master/wolfssl/certs_test.h) which are +[generated](https://github.com/wolfSSL/wolfssl/blob/master/scripts/dertoc.pl) from +[wolfssl/certs](https://github.com/wolfSSL/wolfssl/tree/master/certs) + +There's currently no capability of saving new user keys, so `ssh-copy-id` will not work. + +Linux users note [this resource](http://sensornodeinfo.rockingdlabs.com/blog/2016/01/19/baud74880/) may be helpful for connecting at 74800 baud: + +```bash +git clone https://gist.github.com/3f1a984533556cf890d9.git anybaud +cd anybaud +gcc gistfile.c -o anybaud +anybaud /dev/ttyUSB0 74880 +``` + + +## Quick Start + +For convenience ONLY, there's a [static copy of wolfSSL components](https://github.com/gojimmypi/wolfssh/tree/ESP32_Development/examples/ESP32-SSH-Server/components/). + +DO NOT USE those static components for anything other than this demo. +At some point, the code could contain critical, unresolved CVEs that are fixed +in the current release. To ensure robust security, +install recent code into the Espressif components directory and +delete your local copy found in `examples/ESP32-SSH-Server/components/` + +WSL Quick Start + +```bash +# change to whatever directory you use for projects + +if [ "$WORKSPACE" == "" ]; then read -p "WORKSPACE not set?"; fi +cd $WORKSPACE + +git clone https://github.com/wolfssl/wolfssh-examples.git +cd ./wolfssh-examples/Espressif/ESP32-SSH-Server + +# Reminder that WSL USB devices are called /dev/ttySn and not /dev/TTYUSBn +# For example, on Windows, COM15 is ttyS15 in WSL. +idf.py -p /dev/ttyS15 -baud 460800 flash + +``` + + +## Wired Ethernet ENC28J60 Notes + +The Espressif ENC28J60 library may not be included in the [components/esp_eth/include](https://github.com/espressif/esp-idf/tree/master/components/esp_eth/include) directory, +depending on the latest release install, but the [example component](https://github.com/espressif/esp-idf/tree/master/examples/ethernet/enc28j60/components/eth_enc28j60) +can be copied to the ESP-IDF. + +The earliest release that [includes that directory is Version 4.4](https://github.com/espressif/esp-idf/tree/release/v4.4/examples/ethernet/enc28j60/components/eth_enc28j60). + +The [CMakeLists.txt](./CMakeLists.txt) should be able to copy the components when running `cmake .` in the project directory. Otherwise, the files may need to be manually copied +to the local ESP-IDF `components` directory. + +Note some early versions may not properly get an IP address, so it is best to use the most recent even if the files need to be manually copied into an older ESP-IDF. + +## Operational Status + +Unlike the ESP8266 that needs to have a [shell game of UARTs](https://gojimmypi.github.io/SSH-to-ESP8266/), +the ESP32 is much more graceful. The console port at boot time should look like this: + + +```text +ets Jun 8 2016 00:22:57 + +rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) +configsip: 0, SPIWP:0xee +clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 +mode:DIO, clock div:2 +load:0x3fff0030,len:6628 +load:0x40078000,len:14780 +load:0x40080400,len:3792 +entry 0x40080694 +I (26) boot: ESP-IDF v4.4-263-g000d3823bb-dirty 2nd stage bootloader +I (26) boot: compile time 20:42:35 +I (26) boot: chip revision: 1 +I (31) boot_comm: chip revision: 1, min. bootloader chip revision: 0 +I (38) boot.esp32: SPI Speed : 40MHz +I (43) boot.esp32: SPI Mode : DIO +I (47) boot.esp32: SPI Flash Size : 4MB +I (52) boot: Enabling RNG early entropy source... +I (57) boot: Partition Table: +I (61) boot: ## Label Usage Type ST Offset Length +I (68) boot: 0 nvs WiFi data 01 02 00009000 00006000 +I (75) boot: 1 phy_init RF data 01 01 0000f000 00001000 +I (83) boot: 2 factory factory app 00 00 00010000 00100000 +I (90) boot: End of partition table +I (95) boot_comm: chip revision: 1, min. application chip revision: 0 +I (102) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1d850h (120912) map +I (154) esp_image: segment 1: paddr=0002d878 vaddr=3ffb0000 size=027a0h ( 10144) load +I (158) esp_image: segment 2: paddr=00030020 vaddr=400d0020 size=93314h (602900) map +I (378) esp_image: segment 3: paddr=000c333c vaddr=3ffb27a0 size=05ed0h ( 24272) load +I (388) esp_image: segment 4: paddr=000c9214 vaddr=40080000 size=15148h ( 86344) load +I (423) esp_image: segment 5: paddr=000de364 vaddr=50000000 size=00010h ( 16) load +I (435) boot: Loaded app from partition at offset 0x10000 +I (435) boot: Disabling RNG early entropy source... +I (447) cpu_start: Pro cpu up. +I (447) cpu_start: Starting app cpu, entry point is 0x4008127c +I (0) cpu_start: App cpu up. +I (461) cpu_start: Pro cpu start user code +I (461) cpu_start: cpu freq: 160000000 +I (461) cpu_start: Application information: +I (466) cpu_start: Project name: ESP32-SSH-Server +I (471) cpu_start: App version: v1.4.7-stable-166-g4555602-dirt +I (478) cpu_start: Compile time: May 4 2022 21:43:35 +I (484) cpu_start: ELF file SHA256: 84344e5745864c4b... +I (490) cpu_start: ESP-IDF: v4.4-263-g000d3823bb-dirty +I (497) heap_init: Initializing. RAM available for dynamic allocation: +I (504) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM +I (510) heap_init: At 3FFBD360 len 00022CA0 (139 KiB): DRAM +I (517) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM +I (523) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM +I (529) heap_init: At 40095148 len 0000AEB8 (43 KiB): IRAM +I (537) spi_flash: detected chip: generic +I (540) spi_flash: flash io: dio +I (545) cpu_start: Starting scheduler on PRO CPU. +I (0) cpu_start: Starting scheduler on APP CPU. +I (555) SSH Server main: Begin main init. +I (555) SSH Server main: wolfSSH debugging on. +I (565) SSH Server main: wolfSSL debugging on. +I (575) wolfssl: Debug ON +I (575) SSH Server main: Begin init_UART. +I (575) SSH Server main: End init_UART. +I (585) SSH Server main: Setting up nvs flash for WiFi. +I (625) SSH Server main: Begin setup WiFi Soft AP. +I (635) wifi:wifi driver task: 3ffd3c74, prio:23, stack:6656, core=0 +I (635) system_api: Base MAC address is not set +I (635) system_api: read default base MAC address from EFUSE +I (655) wifi:wifi firmware version: 71cb2c8 +I (655) wifi:wifi certification version: v7.0 +I (655) wifi:config NVS flash: enabled +I (655) wifi:config nano formating: disabled +I (665) wifi:Init data frame dynamic rx buffer num: 32 +I (665) wifi:Init management frame dynamic rx buffer num: 32 +I (675) wifi:Init management short buffer num: 32 +I (675) wifi:Init dynamic tx buffer num: 32 +I (685) wifi:Init static rx buffer size: 1600 +I (685) wifi:Init static rx buffer num: 10 +I (685) wifi:Init dynamic rx buffer num: 32 +I (695) wifi_init: rx ba win: 6 +I (695) wifi_init: tcpip mbox: 32 +I (705) wifi_init: udp mbox: 6 +I (705) wifi_init: tcp mbox: 6 +I (705) wifi_init: tcp tx win: 5744 +I (715) wifi_init: tcp rx win: 5744 +I (715) wifi_init: tcp mss: 1440 +I (715) wifi_init: WiFi IRAM OP enabled +I (725) wifi_init: WiFi RX IRAM OP enabled +I (735) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07 +I (835) wifi:mode : softAP (7c:9e:bd:65:5d:dd) +I (835) wifi:Total power save buffer number: 16 +I (835) wifi:Init max length of beacon: 752/752 +I (845) wifi:Init max length of beacon: 752/752 +I (845) wifi station: wifi_init_softap finished. SSID:TheBucketHill password:jackorjill channel:1 +I (855) SSH Server main: End setup WiFi Soft AP. +I (855) wolfssl: sntp_setservername: +I (865) wolfssl: pool.ntp.org +I (865) wolfssl: time.nist.gov +I (865) wolfssl: utcnist.colorado.edu +I (875) wolfssl: sntp_init done. +I (875) wolfssl: inet_pton +I (875) wolfssl: wolfSSL Entering wolfCrypt_Init +I (885) wolfssl: wolfSSH Server main loop heartbeat! +I (895) wolfssl: InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled +I (895) wolfssl: InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled +I (905) wolfssl: Debug ON v0.2b +I (935) wolfssl: socket creation successful +I (945) wolfssl: setsockopt re-use addr successful +I (945) wolfssl: SO_REUSEPORT not configured for setsockopt to re-use port + +I (945) wolfssl: socket bind successful. +I (945) wolfssl: socket listen successful + +I (965) wolfssl: wolfSSL Entering GetAlgoId + +``` + +Upon a successful remote connection to our embedded SSH Server as a WiFi Access Point, +the console monitoring port should show something like this: + +```text + +I (945) wolfssl: socket bind successful. +I (945) wolfssl: socket listen successful + +I (945) wolfssl: wolfSSL Entering GetAlgoId +I (10895) wolfssl: wolfSSH Server main loop heartbeat! +I (20895) wolfssl: wolfSSH Server main loop heartbeat! +I (30895) wolfssl: wolfSSH Server main loop heartbeat! +I (40895) wolfssl: wolfSSH Server main loop heartbeat! +I (50895) wolfssl: wolfSSH Server main loop heartbeat! +I (60895) wolfssl: wolfSSH Server main loop heartbeat! +I (68565) wifi:new:<1,1>, old:<1,1>, ap:<1,1>, sta:<255,255>, prof:1 +I (68565) wifi:station: [mac address] join, AID=1, bgn, 40U +I (68585) wifi station: station [mac address] join, AID=1 +I (68995) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4 .2 +W (70505) wifi:idx:2 (ifx:1, [mac address]), tid:0, ssn:61, winSize: 64 +I (70895) wolfssl: wolfSSH Server main loop heartbeat! +I (80895) wolfssl: wolfSSH Server main loop heartbeat! +I (90895) wolfssl: wolfSSH Server main loop heartbeat! +I (100895) wolfssl: wolfSSH Server main loop heartbeat! +I (104865) wolfssl: server_worker started. +I (104865) wolfssl: Start NonBlockSSH_accept +I (104905) wolfssl: wolfSSL Entering GetAlgoId +I (105225) wolfssl: wolfSSL Entering wc_ecc_shared_secret_gen_sync +I (105515) wolfssl: wolfSSL Leaving wc_ecc_shared_secret_gen_sync, return 0 +I (105515) wolfssl: wolfSSL Leaving wc_ecc_shared_secret_ex, return 0 +I (110895) wolfssl: wolfSSH Server main loop heartbeat! +I (116395) wolfssl: Exit NonBlockSSH_accept +I (116395) wolfssl: InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled +I (116415) wolfssl: Tx UART! +I (120895) wolfssl: wolfSSH Server main loop heartbeat! + +``` + +When the SSH server is running, but nothing interesting is happening, the main thread will continue to periodically +show a message: + +```text +I (2621868) wolfssl: wolfSSH Server main loop heartbeat! +``` + + + + + +# ENC28J60 Example +(See the README.md file in the upper level 'examples' [directory](https://github.com/espressif/esp-idf/tree/master/examples) for more information about examples.) + +## Overview + +ENC28J60 is a standalone Ethernet controller with a standard SPI interface. This example demonstrates how to drive this controller as an SPI device and then attach to TCP/IP stack. + +This is also an example of how to integrate a new Ethernet MAC driver into the `esp_eth` component, without needing to modify the ESP-IDF component. + +If you have a more complicated application to go (for example, connect to some IoT cloud via MQTT), you can always reuse the initialization codes in this example. + +## How to use ENC28J60example + +### Hardware Required + +To run this example, you need to prepare following hardwares: +* [ESP32 board](https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards.html) (e.g. ESP32-PICO, ESP32 DevKitC, etc) +* ENC28J60 module (the latest revision should be 6) +* **!! IMPORTANT !!** Proper input power source since ENC28J60 is quite power consuming device (it consumes more than 200 mA in peaks when transmitting). If improper power source is used, input voltage may drop and ENC28J60 may either provide nonsense response to host controller via SPI (fail to read registers properly) or it may enter to some strange state in the worst case. There are several options how to resolve it: + * Power ESP32 board from `USB 3.0`, if board is used as source of power to ENC board. + * Power ESP32 board from external 5V power supply with current limit at least 1 A, if board is used as source of power to ENC board. + * Power ENC28J60 from external 3.3V power supply with common GND to ESP32 board. Note that there might be some ENC28J60 boards with integrated voltage regulator on market and so powered by 5 V. Please consult documentation of your board for details. + + If a ESP32 board is used as source of power to ENC board, ensure that that particular board is assembled with voltage regulator capable to deliver current up to 1 A. This is a case of ESP32 DevKitC or ESP-WROVER-KIT, for example. Such setup was tested and works as expected. Other boards may use different voltage regulators and may perform differently. + **WARNING:** Always consult documentation/schematics associated with particular ENC28J60 and ESP32 boards used in your use-case first. + +#### Pin Assignment + +* ENC28J60 Ethernet module consumes one SPI interface plus an interrupt GPIO. By default they're connected as follows: + +| GPIO | ENC28J60 | +| ------ | ----------- | +| GPIO19 | SPI_CLK | +| GPIO23 | SPI_MOSI | +| GPIO25 | SPI_MISO | +| GPIO22 | SPI_CS | +| GPIO4 | Interrupt | + +### Configure the project + +``` +idf.py menuconfig +``` + +In the `Example Configuration` menu, set SPI specific configuration, such as SPI host number, GPIO used for MISO/MOSI/CS signal, GPIO for interrupt event and the SPI clock rate, duplex mode. + +**Note:** According to ENC28J60 data sheet and our internal testing, SPI clock could reach up to 20MHz, but in practice, the clock speed may depend on your PCB layout/wiring/power source. In this example, the default clock rate is set to 8 MHz since some ENC28J60 silicon revisions may not properly work at frequencies less than 8 MHz. + +### Build, Flash, and Run + +Build the project and flash it to the board, then run monitor tool to view serial output: + +``` +idf.py -p PORT build flash monitor +``` + +(Replace PORT with the name of the serial port to use.) + +(To exit the serial monitor, type ``Ctrl-]``.) + +See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects. + +## Example Output + +```bash +I (0) cpu_start: Starting scheduler on APP CPU. +I (401) enc28j60: revision: 6 +I (411) esp_eth.netif.glue: 00:04:a3:12:34:56 +I (411) esp_eth.netif.glue: ethernet attached to netif +I (421) eth_example: Ethernet Started +I (2421) enc28j60: working in 10Mbps +I (2421) enc28j60: working in half duplex +I (2421) eth_example: Ethernet Link Up +I (2421) eth_example: Ethernet HW Addr 00:04:a3:12:34:56 +I (4391) esp_netif_handlers: eth ip: 192.168.2.34, mask: 255.255.255.0, gw: 192.168.2.2 +I (4391) eth_example: Ethernet Got IP Address +I (4391) eth_example: ~~~~~~~~~~~ +I (4391) eth_example: ETHIP:192.168.2.34 +I (4401) eth_example: ETHMASK:255.255.255.0 +I (4401) eth_example: ETHGW:192.168.2.2 +I (4411) eth_example: ~~~~~~~~~~~ +``` + +Now you can ping your ESP32 in the terminal by entering `ping 192.168.2.34` (it depends on the actual IP address you get). + +**Notes:** +1. ENC28J60 hasn't burned any valid MAC address in the chip, you need to write an unique MAC address into its internal MAC address register before any traffic happened on TX and RX line. +2. It is recommended to operate the ENC28J60 in full-duplex mode since various errata exist to the half-duplex mode (even though addressed in the example) and due to its poor performance in the half-duplex mode (especially in TCP connections). However, ENC28J60 does not support automatic duplex negotiation. If it is connected to an automatic duplex negotiation enabled network switch or Ethernet controller, then ENC28J60 will be detected as a half-duplex device. To communicate in Full-Duplex mode, ENC28J60 and the remote node (switch, router or Ethernet controller) **must be manually configured for full-duplex operation**: + * The ENC28J60 can be set to full-duplex in the `Example Configuration` menu. + * On Ubuntu/Debian Linux distribution use: + ``` + sudo ethtool -s YOUR_INTERFACE_NAME speed 10 duplex full autoneg off + ``` + * On Windows, go to `Network Connections` -> `Change adapter options` -> open `Properties` of selected network card -> `Configure` -> `Advanced` -> `Link Speed & Duplex` -> select `10 Mbps Full Duplex in dropdown menu`. +3. Ensure that your wiring between ESP32 board and the ENC28J60 board is realized by short wires with the same length and no wire crossings. +4. CS Hold Time needs to be configured to be at least 210 ns to properly read MAC and MII registers as defined by ENC28J60 Data Sheet. This is automatically configured in the example based on selected SPI clock frequency by computing amount of SPI bit-cycles the CS should stay active after the transmission. However, if your PCB design/wiring requires different value, please update `cs_ena_posttrans` member of `devcfg` structure per your actual needs. + + + + +## Known Issues + +If improper GPIO lines are selected, say when using the defaults but an M5Stick-C is being used, the UART initialization may hang. + +When plugged into a PC that goes to sleep and powers down the USB power, the ESP32 device seems to sometimes crash and does not always recover when PC power resumes. + +Only one connection is allowed at the time. There may be a delay when an existing connected is unexpecteedly terminated before a new connection can be made. + + + + +## Troubleshooting + +### termios.error: (5, 'Input/output error') + +Try a slower baud rate: + +``` +idf.py -b 115200 -p /dev/ttyS20 flash +``` + + +### fatal error: wolfssl/options.h: No such file or directory + +Many problems can originate in the configuration file. + +The `options.h` typically is not used. This error typically means there's an incorrection user_setting.h, or the `#DEFINE WOLFSSL_USER_SETTINGS` is missing. + +This may be a helpful line to add to the beginning of the [CMakeLists.txt](./CMakeLists.txt): + +``` +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") +``` + + +#### FreeRTOS-Kernel/include/freertos is not a directory + +The error `FreeRTOS-Kernel/include/freertos is not a directory` typically means there's an ESP-IDF component directory for wolfssl and/or woldssh +as well as a local project wolfssl and/or woldssh directory. + +``` +Make Error at /home/[USERNAME]/esp/esp-idf/tools/cmake/component.cmake:306 (message): + Include directory + '/home/[USERNAME]/workspace/wolfssh/examples/ESP32-SSH-Server/components/freertos/FreeRTOS-Kernel/include/freertos' + is not a directory. + +``` + +The wolfssl components should exist in only the ESP-IDF or the local project, but not both. + +#### error: unknown type name 'xSemaphoreHandle' + +There's a known problem with ESP-IDF 5.0 and FreeRTOS. + +``` +home/[USERNAME]/esp/esp-idf/components/wolfssl/wolfssl/wolfcrypt/wc_port.h:199:17: error: unknown type name 'xSemaphoreHandle' + typedef xSemaphoreHandle wolfSSL_Mutex; +``` +Start a new terminal session, otherwise you'll likely see `ERROR: This script was called from a virtual environment, can not create a virtual environment again` + +``` +idf.py --version +cd ~/esp/esp-idf +git branch -a +git checkout release/v4.4 +./install.sh +. ./export.sh +cd ~/workspace/wolfssh/examples/ESP32-SSH-Server +``` + +A more radical approach is to completely replace the ESP-IDF +with [version 4.4.1](https://docs.espressif.com/projects/esp-idf/en/v4.4.1/esp32/get-started/index.html#step-2-get-esp-idf). +``` +mkdir -p ~/esp4.4.1/ +cd ~/esp4.4.1/ +git clone -b v4.4.1 --recursive https://github.com/espressif/esp-idf.git +cd esp-idf +./install.sh esp32 +. ./export.sh +cd /workspace/wolfssh/examples/ESP32-SSH-Server +cd ~/workspace/wolfssh/examples/ESP32-SSH-Server +idf.py build +``` + +#### undefined reference to wc_GenerateSeed + +The error `undefined reference to wc_GenerateSeed` is often caused by a bad or missing `components\wolfssh\include\user_settings.h` file. +It is usually best to ensure the setting here exactly match the wolfssl file in `\components\wolfssl\include` unless there's a +compelling reason to do otherwise. + + +Although [Error -236](https://github.com/wolfSSL/wolfssl/blob/9b5ad6f218f657d8651a56b50b6db1b3946a811c/wolfssl/wolfcrypt/error-crypt.h#L189) +typically means "_RNG required but not provided_", the reality is the time is probably wrong. + +``` +wolfssl: wolfSSL Leaving wc_ecc_shared_secret_gen_sync, return -236 +wolfssl: wolfSSL Leaving wc_ecc_shared_secret_ex, return -236 +``` +If the time is set to a reasonable value, and the `-236` error is still occuring, check the [sdkconfig](sdkconfig) +file for unexpected changes, such as when using the EDP-IDF menuconfig. When in doubt, revert back to repo version. + +#### E (545) uart: uart_set_pin(605): tx_io_num error + +A message such as `E (545) uart: uart_set_pin(605): tx_io_num error` typically means the pins assigned to be a UART +Tx/Rx are either input-only or output-only. see [gpio_types.h_](https://github.com/espressif/esp-idf/blob/master/components/hal/include/hal/gpio_types.h) +for example GPIO Pins [34](https://github.com/espressif/esp-idf/blob/3aeb80acb66038f14fc2a7606e7516a3e2bfa6c9/components/hal/include/hal/gpio_types.h#L108) +to 39 are input only. + +``` +E (545) uart: uart_set_pin(605): tx_io_num error +ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x400870c4 +file: "../main/enc28j60_example_main.c" line 250 +func: init_UART +expression: uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE) + +``` + +If there are a lot of garbage characters on the UART Tx/Rx, ensure the proper baud rate, ground connection, and voltage level match. +The ESP32 is 3.3V and typically not 5V tolerant. No ground connection will often cause garbage characters on the UART. + +The error `serialException: could not open port` typically means that something else is using the COM port on Windows. +Check for running instances of Putty, etc. + +``` + File "C:\SysGCC\esp32\esp-idf\v4.4\python-env\lib\site-packages\serial\serialwin32.py", line 64, in open + raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError())) +serial.serialutil.SerialException: could not open port 'COM9': PermissionError(13, 'Access is denied.', None, 5) +``` + +#### Unexplainable panic_abort Received a SIGTRAP: Trace/breakpoint trap + +If after exhausting all other options, try erasing the ESP32 before reprogramming. + +``` +idf.py -p /dev/ttyS20 erase_flash -b 115200 +``` + + + + +## Support + +For any issues related to wolfSSL or wolfSSH, please open an [issue](https://github.com/wolfssl/wolfssl/issues) on GitHub, +visit the [wolfSSL support forum](https://www.wolfssl.com/forums/), +send an email to [support@wolfssl.com](mailto:support@wolfssl.com), +or [contact us](https://www.wolfssl.com/contact/). diff --git a/Espressif/ESP32/ESP32-SSH-Server/ESP32-SSH-Server.vgdbproj b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v4_ESP32.vgdbproj similarity index 61% rename from Espressif/ESP32/ESP32-SSH-Server/ESP32-SSH-Server.vgdbproj rename to Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v4_ESP32.vgdbproj index 518d698..ec422a6 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/ESP32-SSH-Server.vgdbproj +++ b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v4_ESP32.vgdbproj @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ true - 74aa7434-c4fd-435a-b696-1f9899e5e801 + 7bbd1486-d457-4e49-92ba-0cfc9d80849e true true SourceDirs @@ -23,25 +23,17 @@ 9 - + .. DEBUG build/$(PlatformName)/$(ConfigurationName) false - - BuildMachine - BuiltinShortcut - $(ToolchainNinja) $(BuildDir) false - - BuildMachine - BuiltinShortcut - $(SYSPROGS_CMAKE_PATH) @@ -68,7 +60,7 @@ true - 728c8318-bf85-4301-b284-65c18c401679 + eadcc9ab-72b3-4b51-a838-593e5d80ddf7 Upper HeaderDirectoryAndSubdirectories @@ -79,8 +71,7 @@ esp-idf/v4.4.1 ESPIDF - COM20 - 460800 + COM9 false false ESP32 @@ -99,18 +90,10 @@ Default - - false - - BuildMachine - BuiltinShortcut - - - - COM20 + COM9 115200 8 @@ -176,112 +159,15 @@ - True + Unknown true true - - Enabled - true - true - true - true - true - - alpha.clone.CloneChecker - alpha.core.BoolAssignment - alpha.core.CallAndMessageUnInitRefArg - alpha.core.CastSize - alpha.core.CastToStruct - alpha.core.Conversion - alpha.core.DynamicTypeChecker - alpha.core.FixedAddr - alpha.core.IdenticalExpr - alpha.core.PointerArithm - alpha.core.PointerSub - alpha.core.SizeofPtr - alpha.core.StackAddressAsyncEscape - alpha.core.TestAfterDivZero - alpha.cplusplus.DeleteWithNonVirtualDtor - alpha.cplusplus.IteratorRange - alpha.cplusplus.MisusedMovedObject - alpha.deadcode.UnreachableCode - alpha.security.ArrayBound - alpha.security.ArrayBoundV2 - alpha.security.MallocOverflow - alpha.security.ReturnPtrRange - alpha.security.taint.TaintPropagation - alpha.unix.BlockInCriticalSection - alpha.unix.Chroot - alpha.unix.cstring.BufferOverlap - alpha.unix.cstring.NotNullTerminated - alpha.unix.cstring.OutOfBounds - alpha.unix.PthreadLock - alpha.unix.SimpleStream - alpha.unix.Stream - apiModeling.google.GTest - core.builtin.BuiltinFunctions - core.builtin.NoReturnFunctions - core.CallAndMessage - core.DivideZero - core.DynamicTypePropagation - core.NonnilStringConstants - core.NonNullParamChecker - core.NullDereference - core.StackAddressEscape - core.UndefinedBinaryOperatorResult - core.uninitialized.ArraySubscript - core.uninitialized.Assign - core.uninitialized.Branch - core.uninitialized.CapturedBlockVariable - core.uninitialized.UndefReturn - core.VLASize - cplusplus.NewDelete - cplusplus.NewDeleteLeaks - cplusplus.SelfAssignment - deadcode.DeadStores - llvm.Conventions - nullability.NullableDereferenced - nullability.NullablePassedToNonnull - nullability.NullableReturnedFromNonnull - nullability.NullPassedToNonnull - nullability.NullReturnedFromNonnull - optin.cplusplus.VirtualCall - optin.mpi.MPI-Checker - optin.osx.cocoa.localizability.EmptyLocalizationContextChecker - optin.osx.cocoa.localizability.NonLocalizedStringChecker - optin.performance.Padding - optin.portability.UnixAPI - security.FloatLoopCounter - security.insecureAPI.getpw - security.insecureAPI.gets - security.insecureAPI.mkstemp - security.insecureAPI.mktemp - security.insecureAPI.rand - security.insecureAPI.strcpy - security.insecureAPI.UncheckedReturn - security.insecureAPI.vfork - unix.API - unix.cstring.BadSizeArg - unix.cstring.NullArg - unix.Malloc - unix.MallocSizeof - unix.MismatchedDeallocator - unix.StdCLibraryFunctions - unix.Vfork - valist.CopyToSelf - valist.Uninitialized - valist.Unterminated - - - -analyzer-store=region - -analyzer-opt-analyze-nested-blocks - -analyzer-eagerly-assume - + false @@ -296,11 +182,7 @@ - - - - - + false @@ -338,7 +220,7 @@ openocd - -f interface/tigard.cfg -c "adapter_khz 29500" -f target/esp32.cfg + -f interface/ftdi/tigard.cfg -c "adapter_khz 15000" -f target/esp32.cfg diff --git a/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32-S3.vgdbproj b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32-S3.vgdbproj new file mode 100644 index 0000000..20a80fc --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32-S3.vgdbproj @@ -0,0 +1,269 @@ + + + + + + Unknown + + true + + 7bbd1486-d457-4e49-92ba-0cfc9d80849e + true + true + SourceDirs + + + + + + com.visualgdb.xtensa-esp32-elf + + 12.2.0 + 12.1 + 1 + + + .. + DEBUG + build/$(PlatformName)/$(ConfigurationName) + + false + $(ToolchainNinja) + $(BuildDir) + + + + false + $(SYSPROGS_CMAKE_PATH) + + + true + false + false + Ninja + false + RemoveBuildDirectory + false + + + true + true + true + false + true + false + true + HideOuterProjectTargets + true + false + true + + + true + eadcc9ab-72b3-4b51-a838-593e5d80ddf7 + + Upper + HeaderDirectoryAndSubdirectories + true + + + release/v5.1 + esp-idf/v5.1 + ESPIDF + + COM24 + false + false + ESP32S3 + + + + + + + + + + + + + + + Default + + + + COM24 + + 115200 + 8 + None + One + None + + + 0 + false + true + false + ASCII + + + 255 + 0 + 0 + 0 + + + 255 + 169 + 169 + 169 + + + 255 + 211 + 211 + 211 + + + 255 + 144 + 238 + 144 + + + 255 + 169 + 169 + 169 + + + + 16 + true + true + true + true + 0 + + LF + false + false + false + + + + true + + + + + Unknown + + true + true + true + + + + false + + + + + Debug + + + + Release + + + + + + + + + false + false + false + false + false + false + false + false + false + + false + false + false + false + false + false + true + false + None + false + false + app_main + true + false + false + true + 0 + false + 0 + true + false + + + openocd + + -f interface/ftdi/tigard.cfg -c "adapter_khz 15000" -f target/esp32.cfg + + + + false + + 131072 + Enabled + + set remotetimeout 60 + target remote :$$SYS:GDB_PORT$$ + mon gdb_breakpoint_override hard + mon reset halt + load + + false + 0 + 0 + false + + 5000 + 1 + true + + size2MB + freq40M + DIO + + true + + + true + Disabled + 0 + false + false + true + false + false + + _estack + 0 + false + + true + + \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32.sln b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32.sln new file mode 100644 index 0000000..e70784e --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32.sln @@ -0,0 +1,36 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{803FD0C6-D64E-4E16-9DC3-1DAEC859A3D2}") = "wolfssh_IDF_v5.1_ESP32", "wolfssh_IDF_v5.1_ESP32.vgdbproj", "{EADCC9AB-72B3-4B51-A838-593E5D80DDF7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7BA08548-4144-4B0C-91CF-E3D3247A9A74}" + ProjectSection(SolutionItems) = preProject + ..\README.md = ..\README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|VisualGDB = Debug|VisualGDB + Release|VisualGDB = Release|VisualGDB + Tests (Debug)|VisualGDB = Tests (Debug)|VisualGDB + Tests (Release)|VisualGDB = Tests (Release)|VisualGDB + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Debug|VisualGDB.Build.0 = Debug|VisualGDB + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Release|VisualGDB.ActiveCfg = Release|VisualGDB + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Release|VisualGDB.Build.0 = Release|VisualGDB + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Tests (Debug)|VisualGDB.ActiveCfg = Tests (Debug)|VisualGDB + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Tests (Debug)|VisualGDB.Build.0 = Tests (Debug)|VisualGDB + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Tests (Release)|VisualGDB.ActiveCfg = Tests (Release)|VisualGDB + {EADCC9AB-72B3-4B51-A838-593E5D80DDF7}.Tests (Release)|VisualGDB.Build.0 = Tests (Release)|VisualGDB + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {17B51EFD-8966-40AF-A82A-DEBF257AE0DC} + EndGlobalSection +EndGlobal diff --git a/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32.vgdbproj b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32.vgdbproj new file mode 100644 index 0000000..2b84675 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/VisualGDB/wolfssh_IDF_v5.1_ESP32.vgdbproj @@ -0,0 +1,269 @@ + + + + + + Unknown + + true + + 7bbd1486-d457-4e49-92ba-0cfc9d80849e + true + true + SourceDirs + + + + + + com.visualgdb.xtensa-esp32-elf + + 12.2.0 + 12.1 + 1 + + + .. + DEBUG + build/$(PlatformName)/$(ConfigurationName) + + false + $(ToolchainNinja) + $(BuildDir) + + + + false + $(SYSPROGS_CMAKE_PATH) + + + true + false + false + Ninja + false + RemoveBuildDirectory + false + + + true + true + true + false + true + false + true + HideOuterProjectTargets + true + false + true + + + true + eadcc9ab-72b3-4b51-a838-593e5d80ddf7 + + Upper + HeaderDirectoryAndSubdirectories + true + + + release/v5.1 + esp-idf/v5.1 + ESPIDF + + COM19 + false + false + ESP32 + + + + + + + + + + + + + + + Default + + + + COM19 + + 115200 + 8 + None + One + None + + + 0 + false + true + false + ASCII + + + 255 + 0 + 0 + 0 + + + 255 + 169 + 169 + 169 + + + 255 + 211 + 211 + 211 + + + 255 + 144 + 238 + 144 + + + 255 + 169 + 169 + 169 + + + + 16 + true + true + true + true + 0 + + LF + false + false + false + + + + true + + + + + Unknown + + true + true + true + + + + false + + + + + Debug + + + + Release + + + + + + + + + false + false + false + false + false + false + false + false + false + + false + false + false + false + false + false + true + false + None + false + false + app_main + true + false + false + true + 0 + false + 0 + true + false + + + openocd + + -f interface/ftdi/tigard.cfg -c "adapter_khz 15000" -f target/esp32.cfg + + + + false + + 131072 + Enabled + + set remotetimeout 60 + target remote :$$SYS:GDB_PORT$$ + mon gdb_breakpoint_override hard + mon reset halt + load + + false + 0 + 0 + false + + 5000 + 1 + true + + size2MB + freq40M + DIO + + true + + + true + Disabled + 0 + false + false + true + false + false + + _estack + 0 + false + + true + + \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/eth_enc28j60/CMakeLists.txt b/Espressif/ESP32/ESP32-SSH-Server/components/eth_enc28j60/CMakeLists.txt index 946650e..996a6f1 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/components/eth_enc28j60/CMakeLists.txt +++ b/Espressif/ESP32/ESP32-SSH-Server/components/eth_enc28j60/CMakeLists.txt @@ -1,3 +1 @@ -idf_component_register(SRCS "esp_eth_mac_enc28j60.c" - "esp_eth_phy_enc28j60.c" - INCLUDE_DIRS ".") +# No enc28j60 support at this time \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/wolfssh/CMakeLists.txt b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssh/CMakeLists.txt new file mode 100644 index 0000000..c737e11 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssh/CMakeLists.txt @@ -0,0 +1,624 @@ +# [wolfSSL Project]/components/wolfssh/CMakeLists.txt +# +# Copyright (C) 2006-2023 WOLFSSL Inc. +# +# This file is part of wolfSSH. +# +# wolfSSH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# +# cmake for wolfSSH Espressif projects v5.6.6 r1 +# +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html +# + +cmake_minimum_required(VERSION 3.16) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSH_USER_SETTINGS") + +set(VERBOSE_COMPONENT_MESSAGES 1) + +# The scope of this CMAKE_C_FLAGS is just this component: +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS") + +set(CMAKE_CURRENT_SOURCE_DIR ".") + +message(STATUS "CMAKE_CURRENT_LIST_DIR = ${CMAKE_CURRENT_LIST_DIR}") + +get_filename_component(THIS_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE) +message(STATUS "THIS_DIR = ${THIS_DIR}") + +# The root of the project is two directories up from here. (we are typically in [project name]components/mywolfssh) +get_filename_component(PROJECT_ROOT "${THIS_DIR}" DIRECTORY) # Up one directory from here is "components" +get_filename_component(PROJECT_ROOT "${PROJECT_ROOT}" DIRECTORY) # up one more directory should be the root of our project +message(STATUS "PROJECT_ROOT = ${PROJECT_ROOT}") + +# in case wolfssl user_settings.h is missing, we'll look for one in the ESP32/lib directory: +get_filename_component(LIB_USER_SETTINGS "${PROJECT_ROOT}/../lib/user_settings.h" ABSOLUTE) +message(STATUS "wolfssl user_settings.h lib = ${LIB_USER_SETTINGS}") + +get_filename_component(THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH "${PROJECT_ROOT}/components/wolfssl/include" ABSOLUTE) +message(STATUS "wolfssl user_settings.h path = ${THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH}") + +# Optionally set your source to wolfSSL in your project CMakeLists.txt like this: +# set(WOLFSSH_ROOT "c:/some/workspace/wolfssh" ) + +if ( "${WOLFSSH_ROOT}" STREQUAL "") + set(WOLFSSH_ROOT "$ENV{WOLFSSH_ROOT}" ) +endif() + +# Optional compiler definitions to help with system name detection (typically printed by app diagnostics) +if( VERBOSE_COMPONENT_MESSAGES ) + 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() +endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME + +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") + +# find the user name to search for possible "wolfssh-username" +# find the user name to search for possible "wolfssh-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}") + +# Attention! +# +# When editing component CMake files, consider the following : +# +# NO Managed Componenets: Normal stand-alone app, "as cloned" from github. +# There's no notion of staging names (e.g. mywolfssh) regardless of environment settings. +# All of the component source is locall. See settings such s WOLFSSL_ROOT=[your path] +# +# Partially Managed Components. This one is tricky. When publishing a component with examples, +# those examples will have a chicken-and-egg problem: the required component is not yet published. +# Adding to the complexity is the notion of staging components, that are purposely prefixed with +# "my" (e.g. mywolfssh) to distinguish from production, live components (e.g. wolfssh) +# +# Partially Managed Component Examples are typically only encountered by the component publisher +# and only at publish time, such as when performing the pre-publish build check. +# +# A partially managed component may also be manually created, when adding a managed component to +# and existing project. For example: +# +# idf.py add-dependency "wolfssl/wolfssh^1.4.15-stable" +# +# Fully Managaged Componenets. This is the typical example as created from the Component Registry: +# For example: +# +# idf.py create-project-from-example "wolfssl/wolfssh^1.4.15-stable:wolfssh_server" +# +# In all cases, keep in mind that components other than wolfssl will depend on the wolfssl component. +# + +# Component naming is only adjusted when using Managed Components, and only when using staging site. +if( "$ENV{IDF_COMPONENT_REGISTRY_URL}" STREQUAL "https://components-staging.espressif.com" ) + # TODO: Is checking these two variables really the best way to detect an active Component Manager? + message(STATUS "component_manager_interface_version = ${component_manager_interface_version}") + message(STATUS "managed_components = ${managed_components}") + message(STATUS "Checking if wolfssl is in ${PROJECT_ROOT}/managed_components/${THIS_USER}__mywolfssl") + + if(EXISTS "${PROJECT_ROOT}/managed_components/${THIS_USER}__mywolfssl/CMakeLists.txt") + message(STATUS "Found user-specific, managed, staging component. The wolfssl component will be named mywolfssl.") + set(WOLFSSL_COMPONENT_NAME "mywolfssl") + elseif( ("${managed_components}" STREQUAL "") AND ("${component_manager_interface_version}" STREQUAL "") ) + # We've found a staging component, but did not detect the component manager + message(STATUS "No component manager interface component wolfssl ${CMAKE_HOME_DIRECTORY}") + set(WOLFSSL_COMPONENT_NAME "wolfssl") + else() + message(STATUS "else mywolfssl") + set(WOLFSSL_COMPONENT_NAME "mywolfssl") + endif() +elseif(EXISTS "${CMAKE_HOME_DIRECTORY}/managed_components/${THIS_USER}__mywolfssl/CMakeLists.txt") + message(STATUS "Found managed_components mywolfssl") + set(WOLFSSL_COMPONENT_NAME "mywolfssl") +else() + message(STATUS "Not staging environment, no managed_components wolfssl") + set(WOLFSSL_COMPONENT_NAME "wolfssl") +endif() + +# function: IS_WOLFSSH_SOURCE +# parameter: DIRECTORY_PARAMETER = the directory to test +# output: RESULT = contains contents of DIRECTORY_PARAMETER for wolfssh directory, otherwise blank. +function(IS_WOLFSSH_SOURCE DIRECTORY_PARAMETER RESULT) + if (EXISTS "${DIRECTORY_PARAMETER}/wolfssh/ssh.h") + if (EXISTS "${DIRECTORY_PARAMETER}/wolfssh") + message(STATUS "1") + endif() + if (EXISTS "${DIRECTORY_PARAMETER}") + message(STATUS "2") + endif() + if (EXISTS "${DIRECTORY_PARAMETER}/src") + message(STATUS "3") + endif() + set(${RESULT} "${DIRECTORY_PARAMETER}" PARENT_SCOPE) + else() + set(${RESULT} "" PARENT_SCOPE) + endif() +endfunction() + +# function: FIND_WOLFSSH_DIRECTORY +# parameter: OUTPUT_FOUND_WOLFSSH_DIRECTORY contains root of source code, otherwise blank +# +function(FIND_WOLFSSH_DIRECTORY OUTPUT_FOUND_WOLFSSH_DIRECTORY) + message(STATUS "Starting FIND_WOLFSSH_DIRECTORY") + + message(STATUS "OUTPUT_FOUND_WOLFSSH_DIRECTORY = ${${OUTPUT_FOUND_WOLFSSH_DIRECTORY}}") + IS_WOLFSSH_SOURCE("${${OUTPUT_FOUND_WOLFSSH_DIRECTORY}}" FOUND_WOLFSSH) + if( FOUND_WOLFSSH ) + set(${OUTPUT_FOUND_WOLFSSH_DIRECTORY} ${${OUTPUT_FOUND_WOLFSSH_DIRECTORY}} PARENT_SCOPE) + return() + endif() + message(STATUS "") + + if ( "${${OUTPUT_FOUND_WOLFSSH_DIRECTORY}}" STREQUAL "" ) + set(CURRENT_SEARCH_DIR "$ENV{WOLFSSH_ROOT}") + if( "${CURRENT_SEARCH_DIR}" STREQUAL "" ) + message(STATUS "The WOLFSSH_ROOT environment variable is not set. Searching...") + else() + get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSH_ROOT}" ABSOLUTE) + IS_WOLFSSH_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSH) + if( FOUND_WOLFSSH ) + message(STATUS "Found WOLFSSH_ROOT via Environment Variable:") + else() + message(FATAL_ERROR "WOLFSSH_ROOT Environment Variable defined, but path not found:") + message(STATUS "$ENV{WOLFSSH_ROOT}") + endif() + endif() + else() + # There's a non-blank WOLFSSH_ROOT environment variable. Is it a valid wolfssh directory? + get_filename_component(CURRENT_SEARCH_DIR "$ENV{WOLFSSH_ROOT}" ABSOLUTE) + IS_WOLFSSH_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSH) + if( FOUND_WOLFSSH ) + message(STATUS "Found WOLFSSH_ROOT via Environment Variable:") + else() + message(FATAL_ERROR "WOLFSSH_ROOT Environment Variable defined, but path not found: $ENV{WOLFSSH_ROOT}") + #message(STATUS "Exit CMake") + endif() + endif() + + # we'll start in the THIS_CMAKE_CURRENT_SOURCE_DIR, typically [something]/projectname/components/wolfssh + message(STATUS "THIS_CMAKE_CURRENT_SOURCE_DIR = ${THIS_CMAKE_CURRENT_SOURCE_DIR}") + get_filename_component(CURRENT_SEARCH_DIR "${THIS_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 wolfssh + while(NOT CURRENT_SEARCH_DIR STREQUAL "/" AND NOT CURRENT_SEARCH_DIR STREQUAL "" ) + string(LENGTH ${CURRENT_SEARCH_DIR} CURRENT_SEARCH_DIR_LENGTH) + # wolfssh may simply be in a parent directory, such as for local examples in wolfssh repo + IS_WOLFSSH_SOURCE("${CURRENT_SEARCH_DIR}" FOUND_WOLFSSH) + if( FOUND_WOLFSSH ) + message(STATUS "Found wolfssh in CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + set(${OUTPUT_FOUND_WOLFSSH_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + endif() + + if( THIS_USER ) + # Check for "wolfssh-[username]" subdirectory as we recurse up the directory tree + set(CURRENT_SEARCH_DIR_ALT "${CURRENT_SEARCH_DIR}/wolfssh-${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_WOLFSSH_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSH ) + if ( FOUND_WOLFSSH ) + message(STATUS "Found wolfssh in user-suffix CURRENT_SEARCH_DIR_ALT = ${CURRENT_SEARCH_DIR_ALT}") + set(${OUTPUT_FOUND_WOLFSSH_DIRECTORY} ${CURRENT_SEARCH_DIR_ALT} PARENT_SCOPE) + return() + endif() + endif() + + # Next check for no user suffix "wolfssh" subdirectory as we recurse up the directory tree + set(CURRENT_SEARCH_DIR_ALT ${CURRENT_SEARCH_DIR}/wolfssh) + # if(EXISTS ${CURRENT_SEARCH_DIR} AND IS_DIRECTORY ${CURRENT_SEARCH_DIR} AND EXISTS "${CURRENT_SEARCH_DIR}/wolfcrypt/src") + IS_WOLFSSH_SOURCE("${CURRENT_SEARCH_DIR_ALT}" FOUND_WOLFSSH ) + if ( FOUND_WOLFSSH ) + message(STATUS "Found wolfssh in CURRENT_SEARCH_DIR = ${CURRENT_SEARCH_DIR}") + set(${OUTPUT_FOUND_WOLFSSH_DIRECTORY} ${CURRENT_SEARCH_DIR} PARENT_SCOPE) + return() + 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() + endwhile() + + # If not found, set the output variable to empty before exiting + set(${OUTPUT_FOUND_WOLFSSH_DIRECTORY} "" PARENT_SCOPE) +endfunction() + +# COMPONENT_NAME = wolfssh +# The component name is the directory name. "No feature to change this". +# See https://github.com/espressif/esp-idf/issues/8978#issuecomment-1129892685 + +# set the root of wolfssh in top-level project CMakelists.txt: +# set(WOLFSSH_ROOT "C:/some path/with/spaces") +# set(WOLFSSH_ROOT "c:/workspace/wolfssh-[username]") +# set(WOLFSSH_ROOT "/mnt/c/some path/with/spaces") +# or use this logic to assign value from Environment Variable WOLFSSH_ROOT, +# or assume this is an example 7 subdirectories below: + +# We are typically in [root]/IDE/Espressif/ESP-IDF/examples/WOLFSSH_test/components/wolfssh +# The root of wolfssh is 7 directories up from here: + +if(CMAKE_BUILD_EARLY_EXPANSION) + message(STATUS "wolfssh component CMAKE_BUILD_EARLY_EXPANSION:") + idf_component_register( + REQUIRES "${COMPONENT_REQUIRES}" + PRIV_REQUIRES + "${WOLFSSL_COMPONENT_NAME}" # either wolfssl or mywolfssl as a staging component + ) + +else() + # not CMAKE_BUILD_EARLY_EXPANSION + message(STATUS "************************************************************************************************") + message(STATUS "wolfssh component config:") + message(STATUS "************************************************************************************************") + FIND_WOLFSSH_DIRECTORY(WOLFSSH_ROOT) + + set(WOLFSSH_ROOT "${WOLFSSH_ROOT}" CACHE STRING "WOLFSSH_ROOT") + if(WOLFSSH_ROOT) + message(STATUS "Found wolfssh directory at: ${WOLFSSH_ROOT}") + else() + message(STATUS "wolfssh directory not found.") + # Abort. We need wolfmqtt _somewhere_. + message(FATAL_ERROR "Could not find wolfssh in ${WOLFSSH_ROOT}.\n" + "Try setting WOLFSSH_ROOT environment variable or git clone.") + endif() + + + # After all the logic above, does our WOLFSSH_ROOT actually exist? + if( EXISTS "${WOLFSSH_ROOT}" ) + message(STATUS "WOLFSSH_ROOT = ${WOLFSSH_ROOT}") + else() + # Abort. We need wolfssh _somewhere_. + message(FATAL_ERROR "Could not find wolfssh in ${WOLFSSH_ROOT}. Try setting environment variable or git clone.") + endif() + + + set(INCLUDE_PATH ${WOLFSSH_ROOT}) + + set(COMPONENT_SRCDIRS + "\"${WOLFSSH_ROOT}/src/\"" + ) # COMPONENT_SRCDIRS + message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") + + set(WOLFSSH_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssh") + + # Espressif may take several passes through this makefile. Check to see if we found IDF + string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "" WOLFSSH_FOUND_IDF) + + message(STATUS "IDF_PATH = $ENV{IDF_PATH}") + message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}") + message(STATUS "EXCLUDE_ASM = ${EXCLUDE_ASM}") + + # + # Check to see if there's both a local copy and EDP-IDF copy of the wolfssh and/or wolfssh components. + # + if( EXISTS "${WOLFSSH_PROJECT_DIR}" AND EXISTS "$ENV{IDF_PATH}/components/wolfssh/" ) + # + # wolfssh found in both ESP-IDF and local project - needs to be resolved by user + # + message(STATUS "") + message(STATUS "**************************************************************************************") + message(STATUS "") + message(STATUS "Error: Found components/wolfssh in both local project and IDF_PATH") + message(STATUS "") + message(STATUS "To proceed: ") + message(STATUS "") + message(STATUS "Remove either the local project component: ${WOLFSSH_PROJECT_DIR} ") + message(STATUS "or the Espressif shared component installed at: $ENV{IDF_PATH}/components/wolfssh/ ") + message(STATUS "") + message(FATAL_ERROR "Please use wolfssh in either local project or Espressif components, but not both.") + message(STATUS "") + message(STATUS "**************************************************************************************") + message(STATUS "") + + # Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSH_MULTI_INSTALL_WARNING") + + else() + if( EXISTS "$ENV{IDF_PATH}/components/wolfssh/" ) + # + # wolfssh found in ESP-IDF components and is assumed to be already configured in user_settings.h via setup. + # + message(STATUS "") + message(STATUS "Using components/wolfssh in IDF_PATH = $ENV{IDF_PATH}") + message(STATUS "") + else() + # + # wolfssh is not an ESP-IDF component. + # We need to now determine if it is local and if so if it is part of the wolfssh repo, + # or if wolfssh is simply installed as a local component. + # + + if( EXISTS "${WOLFSSH_PROJECT_DIR}" ) + # + # wolfssh found in local project. + # + if( EXISTS "${WOLFSSH_PROJECT_DIR}/wolfcrypt/" ) + message(STATUS "") + message(STATUS "Using installed project ./components/wolfssh in CMAKE_HOME_DIRECTORY = ${CMAKE_HOME_DIRECTORY}") + message(STATUS "") + # + # Note we already checked above and confirmed there's not another wolfssh installed in the ESP-IDF components. + # + # We won't do anything else here, as it will be assumed the original install completed successfully. + # + else() # full wolfssh not installed in local project + # + # This is the developer repo mode. wolfssh will be assumed to be not installed to ESP-IDF nor local project + # In this configuration, we are likely running a wolfssh example found directly in the repo. + # + message(STATUS "") + message(STATUS "Using developer repo ./components/wolfssh in CMAKE_HOME_DIRECTORY = ${CMAKE_HOME_DIRECTORY}") + message(STATUS "") + + message(STATUS "************************************************************************************************") + # When in developer mode, we are typically running wolfssh examples such as benchmark or test directories. + # However, the as-cloned or distributed wolfssh does not have the ./include/ directory, so we'll add it as needed. + # + # first check if there's a [root]/include/user_settings.h + if( EXISTS "${WOLFSSH_ROOT}/include/user_settings.h" ) + message(FATAL_ERROR "Found stray wolfssh user_settings.h in " + "${WOLFSSH_ROOT}/include/user_settings.h " + " (please move it to ${WOLFSSH_PROJECT_DIR}/components/wolfssl/include/user_settings.h )") + else() + # we won't overwrite an existing user settings file, just note that we already have one: + if( EXISTS "${THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH}/user_settings.h" ) + message(STATUS "Using existing wolfssh user_settings.h in " + "${THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH}") + else() + if(EXISTS "${LIB_USER_SETTINGS}" ) + message(STATUS "Installing wolfssh user_settings.h to " + "${THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH}") + file(COPY "${LIB_USER_SETTINGS}" + DESTINATION "${THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH}") + if( EXISTS "${THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH}/user_settings.h" ) + message(STATUS "Confirmed wolfssl user_settings.h in ${THIS_PROJECT_WOLFSSH_USER_SETTINGS_PATH}") + else() + message(ERROR "ERROR: Failed to copy wolfssl user_settings.h from ${LIB_USER_SETTINGS} to ${LIB_USER_SETTINGS}") + endif() + else() + message(ERROR "wolfssl user_settings.h not in project, and not found in ${LIB_USER_SETTINGS}") + endif() + endif() + endif() # user_settings.h + + message(STATUS "************************************************************************************************") + message(STATUS "") + endif() + + else() + # we did not find a ./components/wolfssh/include/ directory from this pass of cmake. + if($WOLFSSH_FOUND_IDF) + message(STATUS "") + message(STATUS "WARNING: wolfssh not found.") + message(STATUS "") + else() + # probably needs to be re-parsed by Espressif + message(STATUS "wolfssh found IDF. Project Source:${PROJECT_SOURCE_DIR}") + endif() # else we have not found ESP-IDF yet + endif() # else not a local wolfssh component + + endif() #else not an ESP-IDF component + endif() # else not local copy and EDP-IDF wolfssh + + + # RTOS_IDF_PATH is typically: + # "/Users/{username}/Desktop/esp-idf/components/freertos/include/freertos" + # depending on the environment, we may need to swap backslashes with forward slashes + string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") + + string(REPLACE "\\" "/" WOLFSSH_ROOT ${WOLFSSH_ROOT}) + + if(IS_DIRECTORY "${RTOS_IDF_PATH}") + message(STATUS "Found current RTOS path: ${RTOS_IDF_PATH}") + else() + # ESP-IDF prior version 4.4x has a different RTOS directory structure + string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/include/freertos") + if(IS_DIRECTORY "${RTOS_IDF_PATH}") + message(STATUS "Found legacy RTOS path: ${RTOS_IDF_PATH}") + else() + message(STATUS "Could not find RTOS path") + endif() + endif() + + + set(COMPONENT_ADD_INCLUDEDIRS + # "./include" # not used! See wolfSSL include/user_settings.h + "\"${WOLFSSH_ROOT}/\"" + "\"${WOLFSSH_ROOT}/wolfssh/\"" + "\"${RTOS_IDF_PATH}/\"" + ) + + + if(IS_DIRECTORY ${IDF_PATH}/components/cryptoauthlib) + list(APPEND COMPONENT_ADD_INCLUDEDIRS "../cryptoauthlib/lib") + endif() + + list(APPEND COMPONENT_ADD_INCLUDEDIRS "\"${WOLFSSH_ROOT}/wolfssh/\"") + + + + set(COMPONENT_SRCEXCLUDE + # wolfSSH + # TODO: we likely need to check #if !defined(WOLFSSH_MISC_INCLUDED) && !defined(NO_INLINE) && !defined(WOLFSSH_IGNORE_FILE_WARN) + # here in cmake if we actually want to always exclude wolfssh misc.c file. (see source; ok for demo) + "\"${WOLFSSH_ROOT}/src/misc.c\"" # misc.c does not need to be compiled when using inline (NO_INLINE not defined)) + ) + + spaces2list(COMPONENT_REQUIRES) + + separate_arguments(COMPONENT_SRCDIRS NATIVE_COMMAND "${COMPONENT_SRCDIRS}") + separate_arguments(COMPONENT_SRCEXCLUDE NATIVE_COMMAND "${COMPONENT_SRCEXCLUDE}") + separate_arguments(COMPONENT_ADD_INCLUDEDIRS NATIVE_COMMAND "${COMPONENT_ADD_INCLUDEDIRS}") + + # + # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#example-component-requirements + # + message(STATUS "COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") + message(STATUS "COMPONENT_ADD_INCLUDEDIRS = ${COMPONENT_ADD_INCLUDEDIRS}") + message(STATUS "COMPONENT_REQUIRES = ${COMPONENT_REQUIRES}") + message(STATUS "COMPONENT_SRCEXCLUDE = ${COMPONENT_SRCEXCLUDE}") + + # + # see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/build-system.html?highlight=space%20path + # + set(EXTRA_COMPONENT_DIRS "${COMPONENT_SRCDIRS}") + idf_component_register( + SRC_DIRS "${COMPONENT_SRCDIRS}" + INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" + REQUIRES "${COMPONENT_REQUIRES}" + EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" + PRIV_REQUIRES + esp_timer + driver + "${WOLFSSL_COMPONENT_NAME}" # either wolfssl or mywolfssl as a staging component + ) + # some optional diagnostics + if (1) + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + message(STATUS "") + message(STATUS "ALL VARIABLES BEGIN") + message(STATUS "") + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + message(STATUS "") + message(STATUS "ALL VARIABLES END") + message(STATUS "") + endif() + + # target_sources(wolfssh PRIVATE "\"${WOLFSSH_ROOT}/wolfssh/\"" "\"${WOLFSSH_ROOT}/wolfssh/wolfcrypt\"") +endif() # CMAKE_BUILD_EARLY_EXPANSION + + + +# check to see if there's both a local copy and EDP-IDF copy of the wolfssh components +if( EXISTS "${WOLFSSH_PROJECT_DIR}" AND EXISTS "$ENV{IDF_PATH}/components/wolfssh/" ) + message(STATUS "") + message(STATUS "") + message(STATUS "********************************************************************") + message(STATUS "WARNING: Found components/wolfssh in both local project and IDF_PATH") + message(STATUS "********************************************************************") + message(STATUS "") +endif() +# end multiple component check + + +# +# LIBWOLFSSH_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) +# +# Save the THIS_VAR as a string in a macro called VAR_OUPUT +# +# VAR_OUPUT: the name of the macro to define +# THIS_VAR: the OUTPUT_VARIABLE result from a execute_process() +# VAR_RESULT: the RESULT_VARIABLE from a execute_process(); "0" if successful. +# +function ( LIBWOLFSSH_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) + # is the RESULT_VARIABLE output value 0? If so, IS_VALID_VALUE is true. + string(COMPARE EQUAL "${VAR_RESULT}" "0" IS_VALID_VALUE) + + # if we had a successful operation, save the THIS_VAR in VAR_OUPUT + if(${IS_VALID_VALUE}) + # strip newline chars in THIS_VAR parameter and save in VAR_VALUE + string(REPLACE "\n" "" VAR_VALUE ${THIS_VAR}) + + # we'll could percolate the value to the parent for possible later use + # set(${VAR_OUPUT} ${VAR_VALUE} PARENT_SCOPE) + + # but we're only using it here in this function + set(${VAR_OUPUT} ${VAR_VALUE}) + + # we'll print what we found to the console + message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") + + # the interesting part is defining the VAR_OUPUT name a value to use in the app + add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + else() + # if we get here, check the execute_process command and parameters. + message(STATUS "LIBWOLFSSH_SAVE_INFO encountered a non-zero VAR_RESULT") + set(${VAR_OUPUT} "Unknown") + endif() +endfunction() # LIBWOLFSSH_SAVE_INFO + +# create some programmatic #define values that will be used by ShowExtendedSystemInfo(). +# see wolfcrypt\src\port\Espressif\esp32_utl.c +if(NOT CMAKE_BUILD_EARLY_EXPANSION) + set (git_cmd "git") + message(STATUS "Adding macro definitions:") + + # LIBWOLFSSH_VERSION_GIT_ORIGIN: git config --get remote.origin.url + execute_process(WORKING_DIRECTORY ${WOLFSSH_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSH_SAVE_INFO(LIBWOLFSSH_VERSION_GIT_ORIGIN "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSH_VERSION_GIT_BRANCH: git rev-parse --abbrev-ref HEAD + execute_process(WORKING_DIRECTORY ${WOLFSSH_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSH_SAVE_INFO(LIBWOLFSSH_VERSION_GIT_BRANCH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSH_VERSION_GIT_HASH: git rev-parse HEAD + execute_process(WORKING_DIRECTORY ${WOLFSSH_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSH_SAVE_INFO(LIBWOLFSSH_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSH_VERSION_GIT_SHORT_HASH: git rev-parse --short HEAD + execute_process(WORKING_DIRECTORY ${WOLFSSH_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSH_SAVE_INFO(LIBWOLFSSH_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSH_VERSION_GIT_HASH_DATE git show --no-patch --no-notes --pretty=\'\%cd\' + execute_process(WORKING_DIRECTORY ${WOLFSSH_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + LIBWOLFSSH_SAVE_INFO(LIBWOLFSSH_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") + + message(STATUS "************************************************************************************************") + message(STATUS "wolfssh component config complete!") + message(STATUS "************************************************************************************************") +endif() diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/wolfssh/component.mk b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssh/component.mk new file mode 100644 index 0000000..03b5c86 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssh/component.mk @@ -0,0 +1,296 @@ +# +# Copyright (C) 2006-2023 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# + +# +# Component Makefile +# +# +# The Espressif Managed Components are only for newer versions of the ESP-IDF +# Typically only for ESP32[-x] targets and only for ESP-IDF v4.3 or later: +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html +# https://components.espressif.com/ +# +# Usage: +# +# make flash +# +# make flash ESPPORT=/dev/ttyS55 +# +# make flash ESPBAUD=9600 +# +# make monitor ESPPORT=COM1 +# +# make monitor ESPPORT=/dev/ttyS55 MONITORBAUD=115200 +# +# export ESPPORT=/dev/ttyS55 +# +# https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html +# + +# Although the project should define WOLFSSL_USER_SETTINGS, we'll also +# define it here: +CFLAGS +=-DWOLFSSL_USER_SETTINGS + +# In the wolfSSL GitHub examples for Espressif, +# 7 6 5 4 3 2 1 +# the root is 7 directories up from the [workspace]\wolfssl\IDE\Espressif\ESP-IDF\examples\ESP8266\components\wolfssl : +# +# WOLFSSL_ROOT := ../../../../../../../ +# +# But we are in the wolfssh-examples repo +# 6 5 4 3 2 1 +# [workspace]\wolfssh-examples\Espressif\ESP32\ESP32-SSH-Server\components\wolfssl +# +# 6 5 4 3 2 1 +WOLFSSL_ROOT := ../../../../../../wolfssl-gojimmypi/ + +WOLFSSH_ROOT := ../../../../../../wolfssh-gojimmypi/ +# WOLFSSH_ROOT := /C/workspace/wolfssh-gojimmypi/ + +# TODO we don't actually want these hardcoded for gojimmypi + +# NOTE: The wolfSSL include diretory (e.g. user_settings.h) is +# located HERE in THIS project, and *not* in the wolfSSL root. +COMPONENT_ADD_INCLUDEDIRS := . +COMPONENT_ADD_INCLUDEDIRS += include +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT). +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt/port/Espressif +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark +# COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos +# COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" + + +# WOLFSSL_ROOT := "" +COMPONENT_SRCDIRS := $(WOLFSSL_ROOT)src +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/atmel +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/test +COMPONENT_SRCDIRS += include + +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/aes_gcm_x86_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)src/bio.o + + +## +## wolfSSL +## +COMPONENT_OBJS := $(WOLFSSL_ROOT)src/bio.o +# COMPONENT_OBJS += src/conf.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/crl.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/internal.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/keys.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ocsp.o +# COMPONENT_OBJS += src/pk.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/quic.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/sniffer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ssl.o +# COMPONENT_OBJS += src/ssl_asn1.o +# COMPONENT_OBJS += src/ssl_bn.o +# COMPONENT_OBJS += src/ssl_certman.o +# COMPONENT_OBJS += src/ssl_crypto.o +# COMPONENT_OBJS += src/ssl_misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/wolfio.o +# COMPONENT_OBJS += src/x509.o +# COMPONENT_OBJS += src/x509_str.o + +## +## wolfcrypt +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/arc4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asn.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/async.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2b.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2s.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/camellia.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha20_poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/coding.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/compress.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cpuid.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cryptocb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/des3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dh.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dilithium.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/eccsi.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc_fp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/error.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_kyber.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_xmss.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/falcon.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_operations.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips_test.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_operations.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hpke.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/integer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/kdf.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/logging.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md5.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/memory.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs12.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs7.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pwdbased.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/random.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rc2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ripemd.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sakke.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/selftest.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha256.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha512.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/signature.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/siphash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sphincs.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_armthumb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_cortexm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_dsp32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_int.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_armthumb.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_cortexm.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_x86_64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_x86_64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/srp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/tfm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_dsp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_encrypt.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber_poly.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_pkcs11.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_port.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_xmss.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_first.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_last.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfevent.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfmath.o + +## +## Espressif +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_mp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_util.o + +## +## wolfcrypt benchmark (optional) +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/benchmark/benchmark.o + +## +## wolfcrypt test (optional) +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/test/test.o + +## +## wolfcrypt +## +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src + +## +## wolfSSH +## +# COMPONENT_ADD_INCLUDEDIRS := . +# COMPONENT_ADD_INCLUDEDIRS += include + +# DO NOT RESET COMPONENT_ADD_INCLUDEDIRS for wolfSSH (i.e. use `+=` not `:=`) +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSH_ROOT). +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSH_ROOT)wolfssh + +COMPONENT_SRCDIRS += $(WOLFSSH_ROOT)src +# COMPONENT_SRCDIRS += include + +# COMPONENT_OBJEXCLUDE := $(WOLFSSH_ROOT)/src/exclude_example.o + +$(info WOLFSSH_ROOT/src/agent is $(WOLFSSH_ROOT)src/agent.c ) + +WOLFSSH_ROOT_ABS := $(CURDIR)/$(WOLFSSH_ROOT_RELATIVE) +$(info WOLFSSH_ROOT_ABS is $(WOLFSSH_ROOT_ABS)) + +COMPONENT_OBJEXCLUDE += $(WOLFSSH_ROOT)src/misc.o + +# AGENT_SRC := $(WOLFSSH_ROOT)src/agent.c +# ifeq ($(wildcard $(AGENT_SRC)),) +# $(info Source file $(AGENT_SRC) does not exist.) +# else +# $(info Source file $(AGENT_SRC) exists.) +# endif + +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/ssh.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/agent.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/certman.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/internal.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/io.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/keygen.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/log.o +# COMPONENT_OBJS += $(WOLFSSH_ROOT)src/misc.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/port.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/wolfscp.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/wolfsftp.o +COMPONENT_OBJS += $(WOLFSSH_ROOT)src/wolfterm.o + +# SRC_FILES := $(filter-out src/bar.cpp, $(SRC_FILES)) +# @echo "hello world! $(COMPONENT_OBJS)" diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/CMakeLists.txt b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/CMakeLists.txt new file mode 100644 index 0000000..d58704b --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/CMakeLists.txt @@ -0,0 +1,676 @@ +# +# Copyright (C) 2006-2023 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# +# cmake for wolfssl Espressif projects +# +# Version 5.6.4.016 for improved manual setting of WOLFSSL_ROOT + ESP8266 support; optional esp-timer / driver components +# +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html +# + +cmake_minimum_required(VERSION 3.16) + +set(VERBOSE_COMPONENT_MESSAGES 1) + +# The scope of this CMAKE_C_FLAGS is just this component: +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 + +# Optionally set your source to wolfSSL in your project CMakeLists.txt like this: +# set(WOLFSSL_ROOT "c:/test/blogtest/wolfssl" ) + +if ( "${WOLFSSL_ROOT}" STREQUAL "") + set(WOLFSSL_ROOT "$ENV{WOLFSSL_ROOT}" ) +endif() +# Optional compiler definitions to help with system name detection (typically printed by app diagnostics) +if(VERBOSE_COMPONENT_MESSAGES) + 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() +endif() # End optional WOLFSSL_CMAKE_SYSTEM_NAME + +message(STATUS "CONFIG_TARGET_PLATFORM = ${CONFIG_TARGET_PLATFORM}") + +# Check that there are not 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() + + +# Don't include lwip requirement for benchmark and test apps. +if( ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark") OR ("${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test") ) + 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 +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 + +# set the root of wolfSSL in top-level project CMakelists.txt: +# set(WOLFSSL_ROOT "C:/some path/with/spaces") +# set(WOLFSSL_ROOT "c:/workspace/wolfssl-[username]") +# set(WOLFSSL_ROOT "/mnt/c/some path/with/spaces") +# or use this logic to assign value from Environment Variable WOLFSSL_ROOT, +# or assume this is an example 7 subdirectories below: + +# We are typically in [root]/IDE/Espressif/ESP-IDF/examples/wolfssl_test/components/wolfssl +# The root of wolfSSL is 7 directories up from here: + +# 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() + +# ********************************************************************************************* +# function: FIND_WOLFSSL_DIRECTORY +# parameter: OUTPUT_FOUND_WOLFSSL_DIRECTORY contains root of source code, otherwise blank +# +# Example usage: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# ********************************************************************************************* +function(FIND_WOLFSSL_DIRECTORY OUTPUT_FOUND_WOLFSSL_DIRECTORY) + message(STATUS "Starting FIND_WOLFSSL_DIRECTORY: ${${OUTPUT_FOUND_WOLFSSL_DIRECTORY}}") + + 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() + 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() + + + # 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( 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() + + # 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() + + # 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() + endwhile() + + # If not found, set the output variable to empty before exiting + set(${OUTPUT_FOUND_WOLFSSL_DIRECTORY} "" PARENT_SCOPE) +endfunction() + + +# Example usage: +# +# Simply find the WOLFSSL_DIRECTORY by searching parent directories: +# FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) +# + +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_INCLUDE_TIMER}" + "${THIS_INCLUDE_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 "************************************************************************************************") + + if ( "${CONFIG_TARGET_PLATFORM}" STREQUAL "esp8266") + # There's no esp_timer, no driver components for the ESP8266 + set(THIS_INCLUDE_TIMER "") + set(THIS_INCLUDE_DRIVER "") + else() + set(THIS_INCLUDE_TIMER "esp_timer") + set(THIS_INCLUDE_DRIVER "driver") + endif() + + # search for wolfSSL + # TODO allow for cmake prior def + + if(WOLFSSL_ROOT) + IS_WOLFSSL_SOURCE("${WOLFSSL_ROOT}" FOUND_WOLFSSL) + if(FOUND_WOLFSSL) + message(STATUS "Found WOLFSSL_ROOT via CMake specification.") + else() + # WOLFSSL_ROOT Path specified in CMakeLists.txt is not a valid path + message(FATAL_ERROR "WOLFSSL_ROOT CMake Variable defined, but path not found: ${WOLFSSL_ROOT}\n" + "Try correcting WOLFSSL_ROOT in your project CMakeFile.txt or setting environment variable.") + # Abort CMake after fatal error. + endif() + else() + message(STATUS "Searching for wolfSL source code...") + FIND_WOLFSSL_DIRECTORY(WOLFSSL_ROOT) + endif() + + + if(WOLFSSL_ROOT) + message(STATUS "Confirmed wolfssl directory at: ${WOLFSSL_ROOT}") + else() + message(STATUS "Failed: wolfssl directory not found.") + # Abort. We need wolfssl _somewhere_. + message(FATAL_ERROR "Could not find wolfssl in ${WOLFSSL_ROOT}.\n" + "Try setting WOLFSSL_ROOT environment variable or git clone.") + # Abort CMake after fatal error. + endif() + + set(INCLUDE_PATH ${WOLFSSL_ROOT}) + + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/src/") + + # During regression tests, optionally copy source locally and use: set(USE_LOCAL_TEST_BENCH 1) + set(USE_LOCAL_TEST_BENCH 0) + if(NOT USE_LOCAL_TEST_BENCH) + if( "${CMAKE_PROJECT_NAME}" STREQUAL "hello-world" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_benchmark" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/benchmark") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/benchmark") + endif() + + if( "${CMAKE_PROJECT_NAME}" STREQUAL "wolfssl_test" ) + message(STATUS "Include ${WOLFSSL_ROOT}/wolfcrypt/test") + set(WOLFSSL_EXTRA_PROJECT_DIR "${WOLFSSL_ROOT}/wolfcrypt/test") + endif() + endif() + + set(COMPONENT_SRCDIRS "\"${WOLFSSL_ROOT}/src/\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/Espressif\"" + "\"${WOLFSSL_ROOT}/wolfcrypt/src/port/atmel\"" + "\"${WOLFSSL_EXTRA_PROJECT_DIR}\"" + ) # COMPONENT_SRCDIRS + + message(STATUS "This COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") + + # wolfSSL user_settings.h is in the local project. + set(WOLFSSL_PROJECT_DIR "${CMAKE_HOME_DIRECTORY}/components/wolfssl") + + string(REPLACE "/" "//" STR_WOLFSSL_PROJECT_DIR "${WOLFSSL_PROJECT_DIR}") + add_definitions(-DWOLFSSL_USER_SETTINGS_DIR="${STR_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) + + # get a list of all wolfcrypt assembly files; we'll exclude them as they don't target Xtensa + file(GLOB EXCLUDE_ASM *.S) + file(GLOB EXCLUDE_ASM ${CMAKE_SOURCE_DIR} "${WOLFSSL_ROOT}/wolfcrypt/src/*.S") + + message(STATUS "IDF_PATH = $ENV{IDF_PATH}") + message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}") + message(STATUS "EXCLUDE_ASM = ${EXCLUDE_ASM}") + + # + # Check to see if there's both a local copy and EDP-IDF copy of the wolfssl and/or wolfssh components. + # + if( EXISTS "${WOLFSSL_PROJECT_DIR}" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) + # + # wolfSSL found in both ESP-IDF and local project - needs to be resolved by user + # + message(STATUS "") + message(STATUS "**************************************************************************************") + message(STATUS "") + message(STATUS "Error: Found components/wolfssl in both local project and IDF_PATH") + message(STATUS "") + message(STATUS "To proceed: ") + message(STATUS "") + message(STATUS "Remove either the local project component: ${WOLFSSL_PROJECT_DIR} ") + message(STATUS "or the Espressif shared component installed at: $ENV{IDF_PATH}/components/wolfssl/ ") + message(STATUS "") + message(STATUS "") + message(STATUS "**************************************************************************************") + message(STATUS "") + + message(FATAL_ERROR "Please use wolfSSL in either local project or Espressif components, but not both.") + # Abort CMake after fatal error. + + # Optional: if you change the above FATAL_ERROR to STATUS you can warn at runtime with this macro definition: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_MULTI_INSTALL_WARNING") + + else() + if( EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) + # + # wolfSSL found in ESP-IDF components and is assumed to be already configured in user_settings.h via setup. + # + message(STATUS "") + message(STATUS "Using components/wolfssl in IDF_PATH = $ENV{IDF_PATH}") + message(STATUS "") + else() + # + # wolfSSL is not an ESP-IDF component. + # We need to now determine if it is local and if so if it is part of the wolfSSL repo, + # or if wolfSSL is simply installed as a local component. + # + + if( EXISTS "${WOLFSSL_PROJECT_DIR}" ) + # + # wolfSSL found in local project. + # + if( EXISTS "${WOLFSSL_PROJECT_DIR}/wolfcrypt/" ) + message(STATUS "") + message(STATUS "Using installed project ./components/wolfssl in CMAKE_HOME_DIRECTORY = ${CMAKE_HOME_DIRECTORY}") + message(STATUS "") + # + # Note we already checked above and confirmed there's not another wolfSSL installed in the ESP-IDF components. + # + # We won't do anything else here, as it will be assumed the original install completed successfully. + # + else() # full wolfSSL not installed in local project + # + # This is the developer repo mode. wolfSSL will be assumed to be not installed to ESP-IDF nor local project + # In this configuration, we are likely running a wolfSSL example found directly in the repo. + # + message(STATUS "") + message(STATUS "Using developer repo ./components/wolfssl in CMAKE_HOME_DIRECTORY = ${CMAKE_HOME_DIRECTORY}") + message(STATUS "") + + message(STATUS "************************************************************************************************") + # When in developer mode, we are typically running wolfSSL examples such as benchmark or test directories. + # However, the as-cloned or distributed wolfSSL does not have the ./include/ directory, so we'll add it as needed. + # + # first check if there's a [root]/include/user_settings.h + if( EXISTS "${WOLFSSL_ROOT}/include/user_settings.h" ) + message(FATAL_ERROR "Found stray wolfSSL user_settings.h in " + "${WOLFSSL_ROOT}/include/user_settings.h " + " (please move it to ${WOLFSSL_PROJECT_DIR}/include/user_settings.h )") + # Abort CMake after fatal error. + 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") + else() + message(STATUS "Installing wolfSSL user_settings.h to " + "${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() + endif() # user_settings.h + + # next check if there's a [root]/include/config.h + if( EXISTS "${WOLFSSL_ROOT}/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" ) + message(STATUS "Using existing wolfSSL config.h ${WOLFSSL_PROJECT_DIR}/include/config.h") + else() + message(STATUS "Installing wolfSSL config.h to ${WOLFSSL_PROJECT_DIR}/include/config.h") + file(COPY "${WOLFSSL_ROOT}/IDE/Espressif/ESP-IDF/dummy_config_h" DESTINATION "${WOLFSSL_PROJECT_DIR}/include/") + file(RENAME "${WOLFSSL_PROJECT_DIR}/include/dummy_config_h" "${WOLFSSL_PROJECT_DIR}/include/config.h") + endif() # Project config.h + endif() # WOLFSSL_ROOT config.h + message(STATUS "************************************************************************************************") + message(STATUS "") + endif() + + else() + # we did not find a ./components/wolfssl/include/ directory from this pass of cmake. + if($WOLFSSL_FOUND_IDF) + message(STATUS "") + message(STATUS "WARNING: wolfSSL not found.") + message(STATUS "") + else() + # probably needs to be re-parsed by Espressif + message(STATUS "wolfSSL found IDF. Project Source:${PROJECT_SOURCE_DIR}") + endif() # else we have not found ESP-IDF yet + endif() # else not a local wolfSSL component + + endif() #else not an ESP-IDF component + endif() # else not local copy and EDP-IDF wolfSSL + + + # RTOS_IDF_PATH is typically: + # "/Users/{username}/Desktop/esp-idf/components/freertos/include/freertos" + # depending on the environment, we may need to swap backslashes with forward slashes + string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") + + string(REPLACE "\\" "/" WOLFSSL_ROOT ${WOLFSSL_ROOT}) + + if(IS_DIRECTORY "${RTOS_IDF_PATH}") + message(STATUS "Found current RTOS path: ${RTOS_IDF_PATH}") + else() + # ESP-IDF prior version 4.4x has a different RTOS directory structure + string(REPLACE "\\" "/" RTOS_IDF_PATH "$ENV{IDF_PATH}/components/freertos/include/freertos") + if(IS_DIRECTORY "${RTOS_IDF_PATH}") + message(STATUS "Found legacy RTOS path: ${RTOS_IDF_PATH}") + else() + message(STATUS "Could not find RTOS path") + endif() + endif() + + # wolfSSL-specific include directories + set(COMPONENT_ADD_INCLUDEDIRS + "./include" # this is the location of local project wolfssl user_settings.h + "\"${WOLFSSL_ROOT}/\"" + "\"${WOLFSSL_ROOT}/wolfssl/\"" + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"" + "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/port/Espressif\"" + "\"${RTOS_IDF_PATH}/\"" + ) + + # Optionally include cryptoauthlib if present + if(IS_DIRECTORY ${IDF_PATH}/components/cryptoauthlib) + list(APPEND COMPONENT_ADD_INCLUDEDIRS "../cryptoauthlib/lib") + endif() + + list(APPEND COMPONENT_ADD_INCLUDEDIRS "\"${WOLFSSL_ROOT}/wolfssl/\"") + list(APPEND COMPONENT_ADD_INCLUDEDIRS "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt/\"") + + + # Some files are known to be included elsewhere, or not used for Espressif + set(COMPONENT_SRCEXCLUDE + "\"${WOLFSSL_ROOT}/src/bio.c\"" + "\"${WOLFSSL_ROOT}/src/conf.c\"" + "\"${WOLFSSL_ROOT}/src/misc.c\"" + "\"${WOLFSSL_ROOT}/src/pk.c\"" + "\"${WOLFSSL_ROOT}/src/ssl_asn1.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}\"" + ) + + spaces2list(COMPONENT_REQUIRES) + + separate_arguments(COMPONENT_SRCDIRS NATIVE_COMMAND "${COMPONENT_SRCDIRS}") + separate_arguments(COMPONENT_SRCEXCLUDE NATIVE_COMMAND "${COMPONENT_SRCEXCLUDE}") + separate_arguments(COMPONENT_ADD_INCLUDEDIRS NATIVE_COMMAND "${COMPONENT_ADD_INCLUDEDIRS}") + + # + # See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#example-component-requirements + # + message(STATUS "COMPONENT_SRCDIRS = ${COMPONENT_SRCDIRS}") + message(STATUS "COMPONENT_ADD_INCLUDEDIRS = ${COMPONENT_ADD_INCLUDEDIRS}") + message(STATUS "COMPONENT_REQUIRES = ${COMPONENT_REQUIRES}") + message(STATUS "COMPONENT_SRCEXCLUDE = ${COMPONENT_SRCEXCLUDE}") + + # + # see https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/build-system.html?highlight=space%20path + # + set(EXTRA_COMPONENT_DIRS "${COMPONENT_SRCDIRS}") + idf_component_register( + SRC_DIRS "${COMPONENT_SRCDIRS}" + INCLUDE_DIRS "${COMPONENT_ADD_INCLUDEDIRS}" + REQUIRES "${COMPONENT_REQUIRES}" + EXCLUDE_SRCS "${COMPONENT_SRCEXCLUDE}" + PRIV_REQUIRES + "${THIS_INCLUDE_TIMER}" + "${THIS_INCLUDE_DRIVER}" # this will typically only be needed for wolfSSL benchmark + ) + + # Some optional diagnostics. Verbose ones are truncated. + if (VERBOSE_COMPONENT_MESSAGES) + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + message(STATUS "") + message(STATUS "ALL VARIABLES BEGIN") + message(STATUS "") + foreach (_variableName ${_variableNames}) + if ( ("${_variableName}" STREQUAL "bootloader_binary_files") + OR ("${_variableName}" STREQUAL "Component paths") + OR ("${_variableName}" STREQUAL "component_targets") + OR ("${_variableName}" STREQUAL "__COMPONENT_TARGETS") + OR ("${_variableName}" STREQUAL "CONFIGS_LIST") + OR ("${_variableName}" STREQUAL "__CONFIG_VARIABLES") + OR ("${_variableName}" STREQUAL "val") + OR ("${_variableName}" MATCHES "^__idf_") + ) + # Truncate the displayed value: + string(SUBSTRING "${${_variableName}}" 0 70 truncatedValue) + message(STATUS "${_variableName} = ${truncatedValue} ... (truncated)") + else() + message(STATUS "${_variableName}=${${_variableName}}") + endif() + endforeach() + message(STATUS "") + message(STATUS "ALL VARIABLES END") + message(STATUS "") + endif() + + # target_sources(wolfssl PRIVATE "\"${WOLFSSL_ROOT}/wolfssl/\"" "\"${WOLFSSL_ROOT}/wolfssl/wolfcrypt\"") + +endif() # CMAKE_BUILD_EARLY_EXPANSION + + + +# check to see if there's both a local copy and EDP-IDF copy of the wolfssl components +if( EXISTS "${WOLFSSL_PROJECT_DIR}" AND EXISTS "$ENV{IDF_PATH}/components/wolfssl/" ) + message(STATUS "") + message(STATUS "") + message(STATUS "********************************************************************") + message(STATUS "WARNING: Found components/wolfssl in both local project and IDF_PATH") + message(STATUS "********************************************************************") + message(STATUS "") +endif() +# end multiple component check + + +# +# LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) +# +# Save the THIS_VAR as a string in a macro called VAR_OUPUT +# +# VAR_OUPUT: the name of the macro to define +# THIS_VAR: the OUTPUT_VARIABLE result from a execute_process() +# VAR_RESULT: the RESULT_VARIABLE from a execute_process(); "0" if successful. +# +function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) + # is the RESULT_VARIABLE output value 0? If so, IS_VALID_VALUE is true. + string(COMPARE EQUAL "${VAR_RESULT}" "0" IS_VALID_VALUE) + + # if we had a successful operation, save the THIS_VAR in VAR_OUPUT + if(${IS_VALID_VALUE}) + # strip newline chars in THIS_VAR parameter and save in VAR_VALUE + string(REPLACE "\n" "" VAR_VALUE ${THIS_VAR}) + + # we'll could percolate the value to the parent for possible later use + # set(${VAR_OUPUT} ${VAR_VALUE} PARENT_SCOPE) + + # but we're only using it here in this function + set(${VAR_OUPUT} ${VAR_VALUE}) + + # we'll print what we found to the console + message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") + + # the interesting part is defining the VAR_OUPUT name a value to use in the app + add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + else() + # if we get here, check the execute_process command and parameters. + message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") + set(${VAR_OUPUT} "Unknown") + endif() +endfunction() # LIBWOLFSSL_SAVE_INFO + +# create some programmatic #define values that will be used by ShowExtendedSystemInfo(). +# see wolfcrypt\src\port\Espressif\esp32_utl.c +if(NOT CMAKE_BUILD_EARLY_EXPANSION) + set (git_cmd "git") + message(STATUS "Adding macro definitions:") + + # LIBWOLFSSL_VERSION_GIT_ORIGIN: git config --get remote.origin.url + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "config" "--get" "remote.origin.url" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_ORIGIN "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_BRANCH: git rev-parse --abbrev-ref HEAD + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--abbrev-ref" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_BRANCH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_HASH: git rev-parse HEAD + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_SHORT_HASH: git rev-parse --short HEAD + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_HASH_DATE git show --no-patch --no-notes --pretty=\'\%cd\' + execute_process(WORKING_DIRECTORY ${WOLFSSL_ROOT} COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") + + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_WOLFSSL_ROOT "${WOLFSSL_ROOT}" "${TMP_RES}") + + message(STATUS "************************************************************************************************") + message(STATUS "wolfssl component config complete!") + message(STATUS "************************************************************************************************") +endif() diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/LICENSE.txt b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/LICENSE.txt new file mode 100644 index 0000000..8d59438 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/LICENSE.txt @@ -0,0 +1,354 @@ + +wolfSSL (formerly known as CyaSSL) and wolfCrypt are either licensed for use +under the GPLv2 (or at your option any later version) or a standard commercial +license. For our users who cannot use wolfSSL under GPLv2 +(or any later version), a commercial license to wolfSSL and wolfCrypt is +available. + +Please contact wolfSSL Inc. directly at: + +Email: licensing@wolfssl.com +Phone: +1 425 245-8247 + +More information can be found on the wolfSSL website at www.wolfssl.com. + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/README.md b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/README.md new file mode 100644 index 0000000..04c0451 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/README.md @@ -0,0 +1,9 @@ +# Component wolfSSL + +This `wolfssl` directory exists only for the stand-alone examples. + +The only files of interest are the [CMakeLists.txt](./CMakeLists.txt) that should point +to the wolfSSL source code and the respective [include/user_settings.h](./include/user_settings.h). + +This directory is _not_ included in the publish to the Espressif Registry, as that +mechanism copies the published source code to the local component directory as needed. diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/component.mk b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/component.mk new file mode 100644 index 0000000..54afe98 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/component.mk @@ -0,0 +1,251 @@ +# +# Copyright (C) 2006-2023 wolfSSL Inc. +# +# This file is part of wolfSSL. +# +# wolfSSL is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# wolfSSL is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# + +# +# Component Makefile +# +# +# The Espressif Managed Components are only for newer versions of the ESP-IDF +# Typically only for ESP32[-x] targets and only for ESP-IDF v4.3 or later: +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html +# https://components.espressif.com/ +# +# Usage: +# +# make flash +# +# make flash ESPPORT=/dev/ttyS55 +# +# make flash ESPBAUD=9600 +# +# make monitor ESPPORT=COM1 +# +# make monitor ESPPORT=/dev/ttyS55 MONITORBAUD=115200 +# +# export ESPPORT=/dev/ttyS55 +# +# https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html +# + +# Although the project should define WOLFSSL_USER_SETTINGS, we'll also +# define it here: +CFLAGS +=-DWOLFSSL_USER_SETTINGS + +# In the wolfSSL GitHub examples for Espressif, +# 7 6 5 4 3 2 1 +# the root is 7 directories up from the [workspace]\wolfssl\IDE\Espressif\ESP-IDF\examples\ESP8266\components\wolfssl : +# +# WOLFSSL_ROOT := ../../../../../../../ +# +# But we are in the wolfssh-examples repo +# 6 5 4 3 2 1 +# [workspace]\wolfssh-examples\Espressif\ESP32\ESP32-SSH-Server\components\wolfssl +# +# 6 5 4 3 2 1 +WOLFSSL_ROOT := ../../../../../../wolfssl-gojimmypi/ + + +# NOTE: The wolfSSL include diretory (e.g. user_settings.h) is +# located HERE in THIS project, and *not* in the wolfSSL root. +COMPONENT_ADD_INCLUDEDIRS := . +COMPONENT_ADD_INCLUDEDIRS += include +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT). +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfssl/wolfcrypt/port/Espressif +COMPONENT_ADD_INCLUDEDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark +# COMPONENT_ADD_INCLUDEDIRS += $ENV(IDF_PATH)/components/freertos/include/freertos +# COMPONENT_ADD_INCLUDEDIRS += "$ENV(IDF_PATH)/soc/esp32s3/include/soc" + + +# WOLFSSL_ROOT := "" +COMPONENT_SRCDIRS := $(WOLFSSL_ROOT)src +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src/port/atmel +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/benchmark +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/test +COMPONENT_SRCDIRS += include + +COMPONENT_OBJEXCLUDE := $(WOLFSSL_ROOT)wolfcrypt/src/aes_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/sha512_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/fe_x25519_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)wolfcrypt/src/aes_gcm_x86_asm.o +COMPONENT_OBJEXCLUDE += $(WOLFSSL_ROOT)src/bio.o + + +## +## wolfSSL +## +COMPONENT_OBJS := $(WOLFSSL_ROOT)src/bio.o +# COMPONENT_OBJS += src/conf.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/crl.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/dtls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/internal.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/keys.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ocsp.o +# COMPONENT_OBJS += src/pk.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/quic.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/sniffer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/ssl.o +# COMPONENT_OBJS += src/ssl_asn1.o +# COMPONENT_OBJS += src/ssl_bn.o +# COMPONENT_OBJS += src/ssl_certman.o +# COMPONENT_OBJS += src/ssl_crypto.o +# COMPONENT_OBJS += src/ssl_misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/tls13.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)src/wolfio.o +# COMPONENT_OBJS += src/x509.o +# COMPONENT_OBJS += src/x509_str.o + +## +## wolfcrypt +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/arc4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/asn.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/async.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2b.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/blake2s.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/camellia.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/chacha20_poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/coding.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/compress.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cpuid.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/cryptocb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/curve448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/des3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dh.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dilithium.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/dsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/eccsi.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ecc_fp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed25519.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ed448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/error.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/evp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_kyber.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ext_xmss.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/falcon.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fe_operations.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/fips_test.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_448.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_low_mem.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ge_operations.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hmac.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/hpke.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/integer.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/kdf.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/logging.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/md5.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/memory.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/misc.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs12.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pkcs7.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/poly1305.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/pwdbased.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/random.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rc2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/ripemd.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/rsa.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sakke.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/selftest.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha256.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sha512.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/signature.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/siphash.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm2.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm3.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sm4.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sphincs.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_armthumb.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_c64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_cortexm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_dsp32.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_int.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_arm64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_armthumb.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c32.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_c64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_cortexm.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_sm2_x86_64.o +# COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/sp_x86_64.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/srp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/tfm.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_dsp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_encrypt.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_kyber_poly.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_lms.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_pkcs11.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_port.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wc_xmss.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_first.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfcrypt_last.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfevent.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/wolfmath.o + +## +## Espressif +## +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_aes.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_mp.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_sha.o +COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/src/port/Espressif/esp32_util.o + +## +## wolfcrypt benchmark (optional) +## +## COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/benchmark/benchmark.o + +## +## wolfcrypt test (optional) +## +## COMPONENT_OBJS += $(WOLFSSL_ROOT)wolfcrypt/test/test.o + +## +## wolfcrypt +## +COMPONENT_SRCDIRS += $(WOLFSSL_ROOT)wolfcrypt/src + + +# SRC_FILES := $(filter-out src/bar.cpp, $(SRC_FILES)) +# @echo "hello world! $(COMPONENT_OBJS)" diff --git a/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/include/user_settings.h b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/include/user_settings.h new file mode 100644 index 0000000..c6df3c7 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/components/wolfssl/include/user_settings.h @@ -0,0 +1,589 @@ +/* user_settings.h (this is a special file specifically for ESP SSH to UART) + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +#include "sdkconfig.h" /* essential to chip set detection */ + +#undef WOLFSSL_ESPIDF +#undef WOLFSSL_ESP32 +#undef WOLFSSL_ESPWROOM32SE +#undef WOLFSSL_ESP32 +#undef WOLFSSL_ESP8266 + +#define WOLFSSL_ESPIDF + +#define DEBUG_WOLFSSH + +/* The Espressif sdkconfig will have chipset info. +** +** Possible values: +** +** CONFIG_IDF_TARGET_ESP32 +** CONFIG_IDF_TARGET_ESP32S2 +** CONFIG_IDF_TARGET_ESP32S3 +** CONFIG_IDF_TARGET_ESP32C3 +** CONFIG_IDF_TARGET_ESP32C6 +*/ +#define ESP_ENABLE_WOLFSSH +/* Optionally enable some wolfSSH settings */ + +#ifdef ESP_ENABLE_WOLFSSH + /* The default SSH Windows size is massive for an embedded target. Limit it: */ + #define DEFAULT_WINDOW_SZ 2000 + + /* These may be defined in cmake for other examples: */ + #undef WOLFSSH_TERM + #define WOLFSSH_TERM + + #undef DEBUG_WOLFSSH + #define DEBUG_WOLFSSH + + #undef WOLFSSL_KEY_GEN + #define WOLFSSL_KEY_GEN + + #undef WOLFSSL_PTHREADS + #define WOLFSSL_PTHREADS + + #define WOLFSSH_TEST_SERVER + + /* optional threading test code can be enabled: */ + /* #define WOLFSSH_TEST_THREADING */ + + /* The "no file system" for wolfSSL */ + #undef NO_FILESYSTEM + #define NO_FILESYSTEM + + /* The "no file system" for wolfSSH */ + #undef WOLFSSH_NO_FILESYSTEM + #define WOLFSSH_NO_FILESYSTEM + + /* WOLFSSL_NONBLOCK is a value assigned to threadCtx->nonBlock + * and should be a value 1 or 0 + */ + #define WOLFSSL_NONBLOCK 1 + +#endif /* ESP_ENABLE_WOLFSSH */ + +/* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */ +/* TODO: previously saw depth mismatch when disabling SINGLE_THREADED ? + * (but putty cannot connect: server host key invalid when defined) + * fails for both `WOLFSSL_NONBLOCK 0` or `WOLFSSL_NONBLOCK 1` */ +#define SINGLE_THREADED + +/* Need to increase pthread stack size when using WOLFSSH_TEST_THREADING */ +/* Minimum defined size should be 20096, but not in SINGLE_THREADED */ +/* #define WOLFSSH_TEST_THREADING */ + +#if defined(WOLFSSH_TEST_THREADING) && defined(SINGLE_THREADED) + #error "Cannot enable both WOLFSSH_TEST_THREADING and SINGLE_THREADED" +#endif + +/* + * choose ONE of these Espressif chips to define: + * + * WOLFSSL_ESP32 + * WOLFSSL_ESPWROOM32SE + * WOLFSSL_ESP8266 + */ + +#define WOLFSSL_ESP32 + +/* optionally turn off SHA512/224 SHA512/256 */ +/* #define WOLFSSL_NOSHA512_224 */ +/* #define WOLFSSL_NOSHA512_256 */ + +/* When you don't want to use the old SHA */ +/* #define NO_SHA */ +/* #define NO_OLD_TLS */ + +#define BENCH_EMBEDDED + +#define NO_OLD_TLS + +/* TLS 1.3 */ +/* #define MY_USE_TLS13 */ +#ifdef MY_USE_TLS13 + #define WOLFSSL_TLS13 + #define HAVE_TLS_EXTENSIONS + #define WC_RSA_PSS + #define HAVE_SUPPORTED_CURVES + #define HAVE_FFDHE_2048 + + /* or one of the other supported FFDHE sizes [2048, 3072, 4096, 6144, 8192] */ + /* #define HAVE_FFDHE_8192 */ + +#endif +#define HAVE_HKDF +#define HAVE_AEAD + +/* note "file system": "load keys and certificate from files" vs NO_FILESYSTEM + * and "access an actual file system via SFTP/SCP" vs WOLFSSH_NO_FILESYSTEM + * we'll typically have neither on an embedded device: + */ +#define NO_FILESYSTEM + +#define HAVE_AESGCM + +#define WOLFSSL_RIPEMD +/* when you want to use SHA224 */ +/* #define WOLFSSL_SHA224 */ + +/* when you want to use SHA384 */ +/* #define WOLFSSL_SHA384 */ + +/* #define WOLFSSL_SHA3 */ + +#define MY_USE_ECC 1 +#define MY_USE_RSA 0 + +/* Define DEMO_SERVER_384 to use ecdsa-sha2-nistp384 + * if DEMO_SERVER_384 is not defined then ecdsa-sha2-nistp256 is default. */ +/* #define DEMO_SERVER_384 */ + +/* We can use either or both ECC and RSA, but must use at least one. */ +/* RSA not yet implemented for SSH to UART demo */ +#if MY_USE_ECC || MY_USE_RSA + #if MY_USE_ECC + /* ---- ECDSA / ECC ---- */ + #define HAVE_ECC + #define HAVE_CURVE25519 + #define HAVE_ED25519 + /* ED25519 requires SHA512 */ + #undef WOLFSSL_SHA512 + #define WOLFSSL_SHA512 + + /* + #define HAVE_ECC384 + #define CURVE25519_SMALL + */ + + #ifdef DEMO_SERVER_384 + /* we'll connect with ecdsa-sha2-nistp384 */ + /* confirmed working with both HW / SW ESP32 wolfcrypt */ + + /* First, we need to force off the [ECDH/ECDSA]'NISTP256 items */ + #define WOLFSSH_NO_ECDH_SHA2_NISTP256 + #define WOLFSSH_NO_ECDSA_SHA2_NISTP256 + /* SHA256 still needed */ + + #define WOLFSSL_SHA384 + #define HAVE_ECC384 + + /* TODO confirm these are needed: */ + #define WOLFSSL_SHA512 + #define HAVE_ECC521 + + #else + /* default ecdsa-sha2-nistp256 needs no special settings. */ + + /* TODO: SHA256 HW enabled causes wolfSSH project error: + * "signature from server's host key is invalid + * + * Software SHA256 works. + */ + #ifndef WOLFSSL_FULL_WOLFSSH_SUPPORT + /* wolfSSL 5.6.6 SHA256 HW not supported with wolfSSH */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 + #endif + #endif + #else + /* Warning: only ECC implemented for SSH UART demo at this time */ + #define WOLFSSH_NO_ECC + /* WOLFSSH_NO_ECDSA is typically defined automatically, + * here for clarity: */ + #define WOLFSSH_NO_ECDSA + #endif + + #if MY_USE_RSA + /* Warning: RSA not implemented for SSH UART demo at this time */ + + /* ---- RSA ----- */ + /* #define RSA_LOW_MEM */ + + /* DH disabled by default, needed if ECDSA/ECC also turned off */ + #define HAVE_DH + + /* WC_RSA_PSS */ + #else + #undef WOLFSSH_NO_RSA + #define WOLFSSH_NO_RSA + + #undef NO_RSA + #define NO_RSA + #endif +#else + #error "Either RSA or ECC must be enabled" +#endif + + +/* when you want to use pkcs7 */ +/* #define HAVE_PKCS7 */ + +#if defined(HAVE_PKCS7) + #define HAVE_AES_KEYWRAP + #define HAVE_X963_KDF + #define WOLFSSL_AES_DIRECT +#endif + +/* when you want to use aes counter mode */ +/* #define WOLFSSL_AES_DIRECT */ +/* #define WOLFSSL_AES_COUNTER */ + +/* debug options */ +/* #define DEBUG_WOLFSSL */ +/* #define WOLFSSL_ESP32_CRYPT_DEBUG */ +/* #define WOLFSSL_ATECC508A_DEBUG */ + +/* date/time */ +/* if it cannot adjust time in the device, */ +/* enable macro below */ +/* #define NO_ASN_TIME */ +/* #define XTIME time */ + +/* adjust wait-timeout count if you see timeout in RSA HW acceleration */ +#define ESP_RSA_TIMEOUT_CNT 0x249F00 + + +/* USE_FAST_MATH is default */ +#define USE_FAST_MATH + +/***** Use SP_MATH *****/ +/* #undef USE_FAST_MATH */ +/* #define SP_MATH */ +/* #define WOLFSSL_SP_MATH_ALL */ +/* #define WOLFSSL_SP_RISCV32 */ + +/***** Use Integer Heap Math *****/ +/* #undef USE_FAST_MATH */ +/* #define USE_INTEGER_HEAP_MATH */ + + +#define WOLFSSL_SMALL_STACK + +/* The ESP32 has some detailed statup information available:*/ +#define HAVE_VERSION_EXTENDED_INFO + +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */ +/* +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + /* SM settings, possible cipher suites: + + TLS13-AES128-GCM-SHA256 + TLS13-CHACHA20-POLY1305-SHA256 + TLS13-SM4-GCM-SM3 + TLS13-SM4-CCM-SM3 + + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \ + "TLS13-SM4-CCM-SM3:" + */ + + /* WOLFSSL_BASE16 required for WOLFSSL_SM2 */ + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 + + #undef WOLFSSL_SM4_ECB + #define WOLFSSL_SM4_ECB + + #undef WOLFSSL_SM4_CBC + #define WOLFSSL_SM4_CBC + + #undef WOLFSSL_SM4_CTR + #define WOLFSSL_SM4_CTR + + #undef WOLFSSL_SM4_GCM + #define WOLFSSL_SM4_GCM + + #undef WOLFSSL_SM4_CCM + #define WOLFSSL_SM4_CCM + + #define HAVE_POLY1305 + #define HAVE_CHACHA + + #undef HAVE_AESGCM + #define HAVE_AESGCM +#else + /* default settings */ +#endif + +/* esp32-wroom-32se specific definition */ +#if defined(WOLFSSL_ESPWROOM32SE) + #define WOLFSSL_ATECC508A + #define HAVE_PK_CALLBACKS + /* when you want to use a custom slot allocation for ATECC608A */ + /* unless your configuration is unusual, you can use default */ + /* implementation. */ + /* #define CUSTOM_SLOT_ALLOCATION */ +#endif + +/* Default is HW enabled unless turned off. +** Uncomment these lines to force SW instead of HW acceleration */ +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(WOLFSSL_ESPWROOM32SE) + /* wolfSSL HW Acceleration supported on ESP32. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + + /* These are defined automatically in esp32-crypt.h, here for clarity: */ + /* no SHA224 HW on ESP32 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224 + + /* Define USE_FAST_MATH and SMALL_STACK */ + #define ESP32_USE_RSA_PRIMITIVE + + /* threshold for performance adjustment for HW primitive use */ + /* X bits of G^X mod P greater than */ + #define EPS_RSA_EXPT_XBTIS 32 + + /* X and Y of X * Y mod P greater than */ + #undef ESP_RSA_MULM_BITS + #define ESP_RSA_MULM_BITS 16 + + /***** END CONFIG_IDF_TARGET_ESP32 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32S2) + /* wolfSSL HW Acceleration supported on ESP32-S2. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* Note: There's no AES192 HW on the ESP32-S2; falls back to SW */ + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32S2 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32S3) + /* wolfSSL HW Acceleration supported on ESP32-S3. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* Note: There's no AES192 HW on the ESP32-S3; falls back to SW */ + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32S3 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) + /* ESP8684 is essentially ESP32-C2 chip + flash embedded together in a + * single QFN 4x4 mm package. Out of released documentation, Technical + * Reference Manual as well as ESP-IDF Programming Guide is applicable + * to both ESP32-C2 and ESP8684. + * + * See: https://www.esp32.com/viewtopic.php?f=5&t=27926#:~:text=ESP8684%20is%20essentially%20ESP32%2DC2,both%20ESP32%2DC2%20and%20ESP8684. */ + + /* wolfSSL HW Acceleration supported on ESP32-C2. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ /* to disable all SHA HW */ + + /* These are defined automatically in esp32-crypt.h, here for clarity */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C2 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C2 */ + + /* There's no AES or RSA/Math accelerator on the ESP32-C2 + * Auto defined with NO_WOLFSSL_ESP32_CRYPT_RSA_PRI, for clarity: */ + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD + /***** END CONFIG_IDF_TARGET_ESP32C2 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32C3) + /* wolfSSL HW Acceleration supported on ESP32-C3. Uncomment to disable: */ + + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ /* to disable all SHA HW */ + + /* These are defined automatically in esp32-crypt.h, here for clarity: */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C6 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C6 */ + + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32C3 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32C6) + /* wolfSSL HW Acceleration supported on ESP32-C6. Uncomment to disable: */ + + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* These are defined automatically in esp32-crypt.h, here for clarity: */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C6 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C6 */ + + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32C6 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32H2) + /* wolfSSL Hardware Acceleration not yet implemented */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + /***** END CONFIG_IDF_TARGET_ESP32H2 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO: Revisit ESP8266 */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + /***** END CONFIG_IDF_TARGET_ESP266 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP8684) + /* There's no Hardware Acceleration available on ESP8684 */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + /***** END CONFIG_IDF_TARGET_ESP8684 *****/ + +#else + /* Anything else encountered, disable HW accleration */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI +#endif /* CONFIG_IDF_TARGET Check */ + +/* Debug options: + +#define ESP_VERIFY_MEMBLOCK +#define DEBUG_WOLFSSL +#define DEBUG_WOLFSSL_VERBOSE +#define DEBUG_WOLFSSL_SHA_MUTEX +#define WOLFSSL_ESP32_CRYPT_DEBUG +#define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG +#define NO_RECOVER_SOFTWARE_CALC +#define WOLFSSL_TEST_STRAY 1 +#define USE_ESP_DPORT_ACCESS_READ_BUFFER +#define WOLFSSL_ESP32_HW_LOCK_DEBUG +#define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS +#define ESP_DISABLE_HW_TASK_LOCK +*/ + +/* Pause in a loop rather than exit. */ +#define WOLFSSL_ESPIDF_ERROR_PAUSE + +/* #define WOLFSSL_HW_METRICS */ + +/* for test.c */ +/* #define HASH_SIZE_LIMIT */ + +/* Optionally turn off HW math checks */ +/* #define NO_HW_MATH_TEST */ + +/* Optionally include alternate HW test library: alt_hw_test.h */ +/* When enabling, the ./components/wolfssl/CMakeLists.txt file + * will need the name of the library in the idf_component_register + * for the PRIV_REQUIRES list. */ +/* #define INCLUDE_ALT_HW_TEST */ + +/* optionally turn off individual math HW acceleration features */ + +/* Turn off Large Number ESP32 HW Multiplication: +** [Z = X * Y] in esp_mp_mul() */ +/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + +/* Turn off Large Number ESP32 HW Modular Exponentiation: +** [Z = X^Y mod M] in esp_mp_exptmod() */ +/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + +/* Turn off Large Number ESP32 HW Modular Multiplication +** [Z = X * Y mod M] in esp_mp_mulmod() */ +/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + +#define WOLFSSL_PUBLIC_MP /* used by benchmark */ + +/* when turning on ECC508 / ECC608 support +#define WOLFSSL_ESPWROOM32SE +#define HAVE_PK_CALLBACKS +#define WOLFSSL_ATECC508A +#define ATCA_WOLFSSL +*/ + +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + #include + #define CTX_CA_CERT root_sm2 + #define CTX_CA_CERT_SIZE sizeof_root_sm2 + #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_PEM + #define CTX_SERVER_CERT server_sm2 + #define CTX_SERVER_CERT_SIZE sizeof_server_sm2 + #define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_PEM + #define CTX_SERVER_KEY server_sm2_priv + #define CTX_SERVER_KEY_SIZE sizeof_server_sm2_priv + #define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_PEM + + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 +#else + #define USE_CERT_BUFFERS_2048 + #define USE_CERT_BUFFERS_256 + #define CTX_CA_CERT ca_cert_der_2048 + #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_2048 + #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1 + #define CTX_SERVER_CERT server_cert_der_2048 + #define CTX_SERVER_CERT_SIZE sizeof_server_cert_der_2048 + #define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_ASN1 + #define CTX_SERVER_KEY server_key_der_2048 + #define CTX_SERVER_KEY_SIZE sizeof_server_key_der_2048 + #define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_ASN1 +#endif + +/* See settings.h for some of the possible hardening options: + * + * #define NO_ESPIDF_DEFAULT + * #define WC_NO_CACHE_RESISTANT + * #define WC_AES_BITSLICED + * #define HAVE_AES_ECB + * #define HAVE_AES_DIRECT + */ + +/* Custom stack check (experimental) */ +#define WOLFSSL_STACK_CHECK diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/CMakeLists.txt b/Espressif/ESP32/ESP32-SSH-Server/main/CMakeLists.txt index 91251cc..14fc4bd 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/CMakeLists.txt +++ b/Espressif/ESP32/ESP32-SSH-Server/main/CMakeLists.txt @@ -1,8 +1,164 @@ -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DDEBUG_WOLFSSL") - -set(srcs main.c ssh_server.c uart_helper.c uart_helper.c wifi.c ssh_server_config.c enc28j60_helper.c int_to_string.c tx_rx_buffer.c) - -idf_component_register( - SRCS "${srcs}" - INCLUDE_DIRS "." - PRIV_INCLUDE_DIRS) +# [wolfSSL Project]/main/CMakeLists.txt +# +# Copyright (C) 2006-2023 WOLFSSL Inc. +# +# This file is part of WOLFSSH. +# +# WOLFSSH is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# WOLFSSH is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA +# +# cmake for WOLFSSH Espressif projects +# +# See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html +# wolfSSL wolfSSH Espressif Example Project/main/CMakeLists.txt +# v1.0 +# +message(STATUS "main cmake found WOLFSSL_COMPONENT_NAME = ${WOLFSSL_COMPONENT_NAME}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS -DDEBUG_WOLFSSL") + + +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/" ) + # + # wolfSSL found in both ESP-IDF and local project - needs to be resolved by user + # + message(STATUS "") + message(STATUS "WARNING: Found components/wolfssl in both local project and IDF_PATH") + message(STATUS "") + 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" + "ssh_server.c" + "uart_helper.c" + "wifi_connect.c" + "ssh_server_config.c" + "int_to_string.c" + "tx_rx_buffer.c" + "time_helper.c" + INCLUDE_DIRS + "./include" + ) + +# +# LIBWOLFSSL_SAVE_INFO(VAR_OUPUT THIS_VAR VAR_RESULT) +# +# Save the THIS_VAR as a string in a macro called VAR_OUPUT +# +# VAR_OUPUT: the name of the macro to define +# THIS_VAR: the OUTPUT_VARIABLE result from a execute_process() +# VAR_RESULT: the RESULT_VARIABLE from a execute_process(); "0" if successful. +# +function ( LIBWOLFSSL_SAVE_INFO VAR_OUPUT THIS_VAR VAR_RESULT ) + # is the RESULT_VARIABLE output value 0? If so, IS_VALID_VALUE is true. + string(COMPARE EQUAL "${VAR_RESULT}" "0" IS_VALID_VALUE) + + # if we had a successful operation, save the THIS_VAR in VAR_OUPUT + if(${IS_VALID_VALUE}) + # strip newline chars in THIS_VAR parameter and save in VAR_VALUE + string(REPLACE "\n" "" VAR_VALUE ${THIS_VAR}) + + # we'll could percolate the value to the parent for possible later use + # set(${VAR_OUPUT} ${VAR_VALUE} PARENT_SCOPE) + + # but we're only using it here in this function + set(${VAR_OUPUT} ${VAR_VALUE}) + + # we'll print what we found to the console + message(STATUS "Found ${VAR_OUPUT}=${VAR_VALUE}") + + # the interesting part is defining the VAR_OUPUT name a value to use in the app + add_definitions(-D${VAR_OUPUT}=\"${VAR_VALUE}\") + else() + # if we get here, check the execute_process command and parameters. + message(STATUS "LIBWOLFSSL_SAVE_INFO encountered a non-zero VAR_RESULT") + set(${VAR_OUPUT} "Unknown") + endif() +endfunction() # LIBWOLFSSL_SAVE_INFO + +if(NOT CMAKE_BUILD_EARLY_EXPANSION) + # LIBWOLFSSL_VERSION_GIT_HASH + execute_process(COMMAND ${git_cmd} "rev-parse" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_SHORT_HASH + execute_process(COMMAND ${git_cmd} "rev-parse" "--short" "HEAD" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ERROR_QUIET ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_SHORT_HASH "${TMP_OUT}" "${TMP_RES}") + + # LIBWOLFSSL_VERSION_GIT_HASH_DATE + execute_process(COMMAND ${git_cmd} "show" "--no-patch" "--no-notes" "--pretty=\'\%cd\'" OUTPUT_VARIABLE TMP_OUT RESULT_VARIABLE TMP_RES ) + LIBWOLFSSL_SAVE_INFO(LIBWOLFSSL_VERSION_GIT_HASH_DATE "${TMP_OUT}" "${TMP_RES}") +endif() + +message(STATUS "") + diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/component.mk b/Espressif/ESP32/ESP32-SSH-Server/main/component.mk index d1eb1e5..ccec230 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/component.mk +++ b/Espressif/ESP32/ESP32-SSH-Server/main/component.mk @@ -1,4 +1,6 @@ -# -# "main" pseudo-component makefile. -# -# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) +# +# "main" pseudo-component makefile. +# +# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) + +COMPONENT_PRIV_INCLUDEDIRS += diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/enc28j60_helper.c b/Espressif/ESP32/ESP32-SSH-Server/main/enc28j60_helper.c deleted file mode 100644 index f1cbc94..0000000 --- a/Espressif/ESP32/ESP32-SSH-Server/main/enc28j60_helper.c +++ /dev/null @@ -1,194 +0,0 @@ -/* enc28j60_helper.c - * - * Copyright (C) 2014-2022 wolfSSL Inc. - * - * This file is part of wolfSSH. - * - * wolfSSH is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * wolfSSH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with wolfSSH. If not, see . - */ - -/* #define USE_ENC28J60 */ - -#include "enc28j60_helper.h" - -#include "esp_netif.h" -#include "esp_eth.h" -#include "esp_event.h" -#include "esp_eth_enc28j60.h" -#include "driver/gpio.h" -#include "driver/spi_master.h" - -/* ENC28J60 doesn't burn any factory MAC address, we need to set it manually. - 02:00:00 is a Locally Administered OUI range so should not be used except when testing on a LAN under your control. - see enc28j60_helper -*/ - - -/* logging - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/log.html - */ -#ifdef LOG_LOCAL_LEVEL -#undef LOG_LOCAL_LEVEL -#endif -#define LOG_LOCAL_LEVEL ESP_LOG_INFO -#include "esp_log.h" - -static const char *TAG = "enc28j60_helper"; -static bool _EthernetReady = false; - -bool EthernetReady_ENC28J60() { - return _EthernetReady; -} - -/** Event handler for Ethernet events */ -static void eth_event_handler(void *arg, - esp_event_base_t event_base, - int32_t event_id, - void *event_data) { - uint8_t mac_addr[6] = { 0x02, 0x00, 0x00, 0x12, 0x34, 0x56 }; - /* we can get the ethernet driver handle from event data */ - esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data; - - switch (event_id) { - case ETHERNET_EVENT_CONNECTED: - esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr); - ESP_LOGI(TAG, "Ethernet Link Up"); - ESP_LOGI(TAG, - "Ethernet HW Addr %02x:%02x:%02x:%02x:%02x:%02x", - mac_addr[0], - mac_addr[1], - mac_addr[2], - mac_addr[3], - mac_addr[4], - mac_addr[5]); - break; - case ETHERNET_EVENT_DISCONNECTED: - ESP_LOGI(TAG, "Ethernet Link Down"); - _EthernetReady = false; - break; - case ETHERNET_EVENT_START: - ESP_LOGI(TAG, "Ethernet Started"); - /* just because the itnerface has started, does not mean Ethernet is ready or not. - * see got_ip_event_handler - */ - break; - case ETHERNET_EVENT_STOP: - ESP_LOGI(TAG, "Ethernet Stopped"); - _EthernetReady = false; - break; - default: - break; - } -} - -/** Event handler for IP_EVENT_ETH_GOT_IP */ -static void got_ip_event_handler(void *arg, - esp_event_base_t event_base, - int32_t event_id, - void *event_data) { - ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data; - const esp_netif_ip_info_t *ip_info = &event->ip_info; - - ESP_LOGI(TAG, "Ethernet Got IP Address"); - ESP_LOGI(TAG, "~~~~~~~~~~~"); - ESP_LOGI(TAG, "ETHIP:" IPSTR, IP2STR(&ip_info->ip)); - ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask)); - ESP_LOGI(TAG, "ETHGW:" IPSTR, IP2STR(&ip_info->gw)); - ESP_LOGI(TAG, "~~~~~~~~~~~"); - _EthernetReady = true; -} - -/* - * initialize the ENC28J60 wired ethernet SPI device. - * See optional define of USE_ENC28J60 - */ -int init_ENC28J60(uint8_t MacAddressToAssign[6]) { -#ifdef USE_ENC28J60 - ESP_LOGI(TAG, "Begin init_ENC28J60."); -#else - ESP_LOGI(TAG, "WARNING: init_ENC28J60 called but USE_ENC28J60 is not defined."); -#endif - - ESP_ERROR_CHECK(gpio_install_isr_service(0)); - /* Initialize TCP/IP network interface (should be called only once in application) */ - ESP_ERROR_CHECK(esp_netif_init()); - /* Create default event loop that running in background */ - ESP_ERROR_CHECK(esp_event_loop_create_default()); - esp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_ETH(); - esp_netif_t *eth_netif = esp_netif_new(&netif_cfg); - - - spi_bus_config_t buscfg = { - .miso_io_num = CONFIG_EXAMPLE_ENC28J60_MISO_GPIO, - .mosi_io_num = CONFIG_EXAMPLE_ENC28J60_MOSI_GPIO, - .sclk_io_num = CONFIG_EXAMPLE_ENC28J60_SCLK_GPIO, - .quadwp_io_num = -1, - .quadhd_io_num = -1, - }; - ESP_ERROR_CHECK(spi_bus_initialize(CONFIG_EXAMPLE_ENC28J60_SPI_HOST, - &buscfg, 1)); - /* ENC28J60 ethernet driver is based on spi driver */ - spi_device_interface_config_t devcfg = { - .command_bits = 3, - .address_bits = 5, - .mode = 0, - .clock_speed_hz = CONFIG_EXAMPLE_ENC28J60_SPI_CLOCK_MHZ * 1000 * 1000, - .spics_io_num = CONFIG_EXAMPLE_ENC28J60_CS_GPIO, - .queue_size = 20 - }; - spi_device_handle_t spi_handle = NULL; - ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ENC28J60_SPI_HOST, - &devcfg, &spi_handle)); - - eth_enc28j60_config_t enc28j60_config = ETH_ENC28J60_DEFAULT_CONFIG(spi_handle); - enc28j60_config.int_gpio_num = CONFIG_EXAMPLE_ENC28J60_INT_GPIO; - - eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG(); - mac_config.smi_mdc_gpio_num = -1; /* ENC28J60 doesn't have SMI interface */ - mac_config.smi_mdio_gpio_num = -1; - esp_eth_mac_t *mac = esp_eth_mac_new_enc28j60(&enc28j60_config, &mac_config); - - eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG(); - phy_config.autonego_timeout_ms = 0; /* ENC28J60 doesn't support auto-negotiation */ - phy_config.reset_gpio_num = -1; /* ENC28J60 doesn't have a pin to reset internal PHY */ - esp_eth_phy_t *phy = esp_eth_phy_new_enc28j60(&phy_config); - - esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy); - esp_eth_handle_t eth_handle = NULL; - ESP_ERROR_CHECK(esp_eth_driver_install(ð_config, ð_handle)); - - - mac->set_addr(mac, MacAddressToAssign); - - - /* attach Ethernet driver to TCP/IP stack */ - ESP_ERROR_CHECK(esp_netif_attach(eth_netif, - esp_eth_new_netif_glue(eth_handle)) - ); - - /* Register user defined event handers - * "ensure that they register the user event handlers as the last thing prior to starting the Ethernet driver." - */ - ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, - ð_event_handler, NULL)); - - ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, - &got_ip_event_handler, NULL)); - - /* start Ethernet driver state machine */ - ESP_ERROR_CHECK(esp_eth_start(eth_handle)); - - ESP_LOGI(TAG, "End init_ENC28J60."); - return 0; -} diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/enc28j60_helper.h b/Espressif/ESP32/ESP32-SSH-Server/main/enc28j60_helper.h deleted file mode 100644 index 75eb4a5..0000000 --- a/Espressif/ESP32/ESP32-SSH-Server/main/enc28j60_helper.h +++ /dev/null @@ -1,26 +0,0 @@ -/* enc28j60_helper.h - * - * Copyright (C) 2014-2022 wolfSSL Inc. - * - * This file is part of wolfSSH. - * - * wolfSSH is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * wolfSSH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with wolfSSH. If not, see . - */ -#pragma once - -#include "stdbool.h" -#include "esp_netif.h" - -bool EthernetReady_ENC28J60(); -int init_ENC28J60(uint8_t MacAddressToAssign[6]); \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/int_to_string.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/int_to_string.h similarity index 84% rename from Espressif/ESP32/ESP32-SSH-Server/main/int_to_string.h rename to Espressif/ESP32/ESP32-SSH-Server/main/include/int_to_string.h index c4980e7..332f5ac 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/int_to_string.h +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/int_to_string.h @@ -17,13 +17,14 @@ * You should have received a copy of the GNU General Public License * along with wolfSSH. If not, see . */ -#pragma once +#ifndef _INT_TO_STRING_H_ +#define _INT_TO_STRING_H_ #ifdef __cplusplus extern "C" { #endif - int int_to_string_VERSION(); + int int_to_string_VERSION(void); char *int_to_bin(char *dest, unsigned long n); char *int_to_hex(char *dest, unsigned long n); @@ -32,4 +33,6 @@ extern "C" { #ifdef __cplusplus } -#endif \ No newline at end of file +#endif /* __cplusplus */ + +#endif /* _INT_TO_STRING_H_ */ \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/include/main.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/main.h new file mode 100644 index 0000000..4ac44e3 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/main.h @@ -0,0 +1,88 @@ +/* template main.h + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ +#ifndef _MAIN_H_ +#define _MAIN_H_ + +/* Espressif libraries */ +#include "sdkconfig.h" +#include +#include + +/* wolfSSL */ +#include +/* Reminder: settings.h includes wolfssl/user_settings.h */ +#ifndef WOLFSSL_ESPIDF + #error "Problem with wolfSSL user_settings." + #error "Check components/wolfssl/include" +#endif +#include + +/* wolfSSH */ +#include +#include + +/* Project settings */ + +/* See also user.settings.g, in particular DEFAULT_WINDOW_SZ + * that can drammatically affect required memory. */ +#define UART_RX_TASK_STACK_SIZE ( 4 * 1024) +#define UART_TX_TASK_STACK_SIZE ( 4 * 1024) + +#ifdef WOLFSSH_TEST_THREADING + #define SERVER_SESSION_STACK_SIZE (4 * 1024) + + /* SSH Server will use pthreads task */ + #ifdef CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT + #if (CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT < 20096) + #error "CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT too small" + #endif + #else + #error "CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT needs to be defined " \ + "when WOLFSSH_TEST_THREADING is enabled " + #endif + + #if defined(SINGLE_THREADED) + #error "Cannot enable both WOLFSSH_TEST_THREADING and SINGLE_THREADED" + #endif +#else + /* 20K is known to work for demo w/ ECC; TODO determine more exact minimum. + * 15K observed to fail with default settings + * + * Currently faling with SINGLE_THREADED, + * even on S3 with SERVER_SESSION_STACK_SIZE = 153KB */ + #define SERVER_SESSION_STACK_SIZE (23 * 1024) + + /* SSH Server will use NOT pthreads task without WOLFSSH_TEST_THREADING */ + #ifdef CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT + #if (CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT > 4096) + #error "CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT too large" + #endif + + /* The smallest confirmed stack size is 23KB */ + #if (SERVER_SESSION_STACK_SIZE < 23 * 1024) + #error "SERVER_SESSION_STACK_SIZE too small" + #endif + #else + #error "CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT needs to be defined " + #endif +#endif + +#endif /* _MAIN_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/my_config.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/my_config.h similarity index 78% rename from Espressif/ESP32/ESP32-SSH-Server/main/my_config.h rename to Espressif/ESP32/ESP32-SSH-Server/main/include/my_config.h index d959264..056e7c5 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/my_config.h +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/my_config.h @@ -1,4 +1,3 @@ -#pragma once /* my_config.h * * Copyright (C) 2014-2022 wolfSSL Inc. @@ -19,6 +18,10 @@ * along with wolfSSH. If not, see . * */ + +#ifndef _MY_CONFIG_H_ +#define _MY_CONFIG_H_ + #define USE_MY_PRIVATE_CONFIG /* @@ -68,7 +71,9 @@ endif() #define XSTR(x) STR(x) #define STR(x) #x -#define EXAMPLE_ESP_WIFI_AP_SSID "TheBucketHill" +#ifndef EXAMPLE_ESP_WIFI_AP_SSID + #define EXAMPLE_ESP_WIFI_AP_SSID "TheBucketHill" +#endif #define EXAMPLE_ESP_WIFI_AP_PASS "jackorjill" /* clang intellisense gives a pragma-messages warning @@ -97,8 +102,8 @@ endif() #include SYSPROGS_MY_PRIVATE_CONFIG #elif defined(WINDOWS_MY_PRIVATE_CONFIG) - #pragma message ( "Found WINDOWS_MY_PRIVATE_CONFIG !" ) - #pragma message ( XSTR(WINDOWS_MY_PRIVATE_CONFIG) ) + /* #pragma message ( "Found WINDOWS_MY_PRIVATE_CONFIG !" ) */ + /* #pragma message ( XSTR(WINDOWS_MY_PRIVATE_CONFIG) ) */ #include WINDOWS_MY_PRIVATE_CONFIG #elif defined(WSL_MY_PRIVATE_CONFIG) @@ -111,27 +116,29 @@ endif() #pragma message ( XSTR(LINUX_MY_PRIVATE_CONFIG) ) #include LINUX_MY_PRIVATE_CONFIG +#elif defined(CONFIG_IDF_TARGET_ESP8266) + /* config TODO */ #else /* reminder that if you put a password here, * it might get checked into GitHub! */ -#warning "Not using my_private_config.h" + #warning "Not using my_private_config.h" + + #ifndef CONFIG_EXAMPLE_WIFI_SSID + #define CONFIG_EXAMPLE_WIFI_SSID "TheBucketHill" + #endif + #ifndef CONFIG_EXAMPLE_WIFI_PASSWORD + #define CONFIG_EXAMPLE_WIFI_PASSWORD "jackorjill" + #endif + + #ifndef CONFIG_ESP_WIFI_SSID + #define CONFIG_ESP_WIFI_SSID "TheBucketHill" + #endif + #ifndef CONFIG_ESP_WIFI_PASSWORD + #define CONFIG_ESP_WIFI_PASSWORD "jackorjill" + #endif -#ifndef CONFIG_EXAMPLE_WIFI_SSID - #define CONFIG_EXAMPLE_WIFI_SSID "TheBucketHill" -#endif -#ifndef CONFIG_EXAMPLE_WIFI_PASSWORD - #define CONFIG_EXAMPLE_WIFI_PASSWORD "jackorjill" -#endif - -#ifndef CONFIG_ESP_WIFI_SSID - #define CONFIG_ESP_WIFI_SSID "TheBucketHill" -#endif -#ifndef CONFIG_ESP_WIFI_PASSWORD - #define CONFIG_ESP_WIFI_PASSWORD "jackorjill" -#endif - -#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID -#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD + #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID + #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD #endif /* turn off GCC diagnostic ignored "-W#pragma-messages" from above @@ -139,4 +146,6 @@ endif() /* #pragma GCC diagnostic pop -*/ \ No newline at end of file +*/ + +#endif /* _MY_CONFIG_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/ssh_server.h similarity index 50% rename from Espressif/ESP32/ESP32-SSH-Server/main/ssh_server.h rename to Espressif/ESP32/ESP32-SSH-Server/main/include/ssh_server.h index a8a336e..7b17f02 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server.h +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/ssh_server.h @@ -1,5 +1,3 @@ -#pragma once - /* ssh_server.h * * Copyright (C) 2014-2022 wolfSSL Inc. @@ -19,62 +17,34 @@ * You should have received a copy of the GNU General Public License * along with wolfSSH. If not, see . */ - - -#ifndef _WOLFSSH_EXAMPLES_SERVER_H_ -#define _WOLFSSH_EXAMPLES_SERVER_H_ +#ifndef _SSH_SERVER_H_ +#define _SSH_SERVER_H_ #include - #ifdef HAVE_CONFIG_H -#include + #include #endif - -#define NO_FILESYSTEM -#define WOLFSSH_TEST_SERVER -#define WOLFSSH_TEST_THREADING - /* make sure this appears before any other wolfSSL headers */ #ifdef WOLFSSL_USER_SETTINGS -#include + #include #else -#include + #include #endif -/* wolfSSL */ -#include -#include -#include -#include +///* wolfSSL */ +//#include +//#include +//#include +//#include +// +///* wolfSSH */ +//#include +//#include -#include -#include - -#include -#ifdef SINGLE_THREADED - typedef unsigned int THREAD_RETURN; - typedef void* THREAD_TYPE; - #define WOLFSSH_THREAD -#else - #if defined(_POSIX_THREADS) && !defined(__MINGW32__) - typedef void* THREAD_RETURN; - typedef pthread_t THREAD_TYPE; - #define WOLFSSH_THREAD - #define INFINITE -1 - #define WAIT_OBJECT_0 0L - #elif defined(WOLFSSL_NUCLEUS) || defined(FREESCALE_MQX) - typedef unsigned int THREAD_RETURN; - typedef intptr_t THREAD_TYPE; - #define WOLFSSH_THREAD - #else - typedef unsigned int THREAD_RETURN; - typedef intptr_t THREAD_TYPE; - #define WOLFSSH_THREAD __stdcall - #endif -#endif +// #include /* socket includes */ #include "lwip/netdb.h" @@ -90,16 +60,18 @@ #endif - +/* the main SSH Server demo*/ void server_test(void *arg); +/* External buffer functions used between RTOS tasks. (typically the UART) + * TODO: Implement interrupts rather than polling */ +volatile char* __attribute__((optimize("O0"))) ExternalTransmitBuffer(void); +volatile char* __attribute__((optimize("O0"))) ExternalReceiveBuffer(void); -volatile char* __attribute__((optimize("O0"))) ExternalTransmitBuffer(); -volatile char* __attribute__((optimize("O0"))) ExternalReceiveBuffer(); -int ExternalTransmitBufferSz(); -int ExternalReceiveBufferSz(); +int ExternalTransmitBufferSz(void); +int ExternalReceiveBufferSz(void); int Set_ExternalTransmitBufferSz(int n); int Set_ExternalReceiveBufferSz(int n); -#endif /* _WOLFSSH_EXAMPLES_SERVER_H_ */ +#endif /* _SSH_SERVER_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server_config.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/ssh_server_config.h similarity index 57% rename from Espressif/ESP32/ESP32-SSH-Server/main/ssh_server_config.h rename to Espressif/ESP32/ESP32-SSH-Server/main/include/ssh_server_config.h index fd90ef4..0d10d3f 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server_config.h +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/ssh_server_config.h @@ -17,14 +17,19 @@ * You should have received a copy of the GNU General Public License * along with wolfSSH. If not, see . */ -#pragma once +#ifndef _SSH_SERVER_CONFIG_H_ +#define _SSH_SERVER_CONFIG_H_ -/* WOLFSSL_USER_SETTINGS is defined here only for the syntax highlighter - * see CMakeLists.txt -#define WOLFSSL_USER_SETTINGS - */ +/* sdkconfig needed for target chipset identification */ +#include "sdkconfig.h" + +/* Define wolfSSL settings in user_settings.h; NOT HERE! */ + +/* wolfSSL */ +#include #include +#include /** ****************************************************************************** @@ -33,14 +38,13 @@ ****************************************************************************** ****************************************************************************** **/ -#define SINGLE_THREADED /* EdgeRouter-X is 57600, others are typically 115200 - * + * This is the UART baud rate to use in SSH server, NOT the monitor baud rate! **/ -#define BAUD_RATE (57600) +#define BAUD_RATE (115200) /* SSH is usually on port 22, but for our example it lives at port 22222 */ @@ -61,78 +65,60 @@ * #define WOLFSSH_SERVER_IS_STA **/ -#define WOLFSSH_SERVER_IS_AP - +/* #define WOLFSSH_SERVER_IS_AP */ +#define WOLFSSH_SERVER_IS_STA /* set GPIO pins for UART_NUM_1 */ #undef ULX3S #undef M5STICKC -#ifdef M5STICKC + +/* + * Example documentation images: + * Tx (transmit) is orange wire + * Rx (receive) is yellow wire + */ +#if defined(M5STICKC) /* reminder GPIO 34 to 39 are input only */ - #define TXD_PIN (GPIO_NUM_26) /* orange */ - #define RXD_PIN (GPIO_NUM_36) /* yellow */ + #define TXD_PIN (GPIO_NUM_26) + #define RXD_PIN (GPIO_NUM_36) #elif defined (ULX3S) /* reminder GPIO 34 to 39 are input only */ - #define TXD_PIN (GPIO_NUM_32) /* orange */ - #define RXD_PIN (GPIO_NUM_33) /* yellow */ + #define TXD_PIN (GPIO_NUM_32) + #define RXD_PIN (GPIO_NUM_33) +#elif defined (SSH_HUZZAH_ESP8266) + #define EX_UART_NUM UART_NUM_0 +#elif defined(CONFIG_IDF_TARGET_ESP8266) + #define EX_UART_NUM UART_NUM_0 + /* `TXD2` = `GPIO 15` = `D8` (Yellow) */ + /* `RXD2` = `GPIO 13` = `D7` (Orange) */ + + #define TXD_PIN (GPIO_Pin_15) + #define RXD_PIN (GPIO_Pin_13) /* TODO assign valid GPIO */ #else - #define TXD_PIN (GPIO_NUM_17) /* orange */ - #define RXD_PIN (GPIO_NUM_16) /* yellow */ + #ifndef GPIO_NUM_17 + #define GPIO_NUM_17 17 + #endif + #ifndef GPIO_NUM_16 + #define GPIO_NUM_16 16 + #endif + #define RXD_PIN (GPIO_NUM_16) + #define TXD_PIN (GPIO_NUM_17) #endif - #define SSH_SERVER_BANNER "wolfSSH Example Server\n" #undef SO_REUSEPORT -/* WOLFSSL_NONBLOCK is a value assigned to threadCtx->nonBlock - * and should be a value 1 or 0 - */ -#define WOLFSSL_NONBLOCK 1 - /* set SSH_SERVER_ECHO to a value of 1 to echo UART * this is optional and typically not desired as the - * UART target will typically echo its own characters. + * UART target will usually echo its own characters. * Valid values are 0 and 1. */ #define SSH_SERVER_ECHO 0 - -/* - * Time server settings. - * - * Accurate time is often important in cryptographic key exchange. - * - * see https://tf.nist.gov/tf-cgi/servers.cgi - */ -#define NTP_SERVER_LIST ( (char*[]) { \ - "pool.ntp.org", \ - "time.nist.gov", \ - "utcnist.colorado.edu" \ - } \ - ) - - -#define TIME_ZONE "PST-8" - - -/* TODO will be ever need WOLFSSL_NUCLEUS here? probably not */ -#ifdef WOLFSSL_NUCLEUS - #define WFD_SET_TYPE FD_SET - #define WFD_SET NU_FD_Set - #define WFD_ZERO NU_FD_Init - #define WFD_ISSET NU_FD_Check -#else - #define WFD_SET_TYPE fd_set - #define WFD_SET FD_SET - #define WFD_ZERO FD_ZERO - #define WFD_ISSET FD_ISSET -#endif - - /** ****************************************************************************** ****************************************************************************** @@ -153,21 +139,6 @@ #endif #define SCRATCH_BUFFER_SZ 1200 - -/* NELEMS(x) number of elements - * To determine the number of elements in the array, we can divide the total size of - * the array by the size of the array element - * See https://stackoverflow.com/questions/37538/how-do-i-determine-the-size-of-my-array-in-c - **/ -#define NELEMS(x) ( (int)(sizeof(x) / sizeof((x)[0])) ) - -/* #define NTP_SERVER_COUNT (int)(sizeof(NTP_SERVER_LIST) / sizeof(NTP_SERVER_LIST[0])) */ -#define NTP_SERVER_COUNT NELEMS(NTP_SERVER_LIST) - -/* our NTP server list is global info */ -extern char* ntpServerList[NTP_SERVER_COUNT]; - - #ifdef WOLFSSH_SERVER_IS_AP #ifdef WOLFSSH_SERVER_IS_STA #error "Concurrent WOLFSSH_SERVER_IS_AP and WOLFSSH_SERVER_IS_STA" @@ -175,18 +146,26 @@ extern char* ntpServerList[NTP_SERVER_COUNT]; #endif #endif -void ssh_server_config_init(); +int ssh_server_config_init(void); /* sanity checks */ -#if defined USE_ENC28J60 && defined WOLFSSH_SERVER_IS_AP +#if defined(USE_ENC28J60) && defined(WOLFSSH_SERVER_IS_AP) #error "Server cannot be WiFi AP when using ENC28J60 at this time." #endif -#if defined USE_ENC28J60 && defined WOLFSSH_SERVER_IS_AP +#if defined(USE_ENC28J60) && defined(WOLFSSH_SERVER_IS_AP) #error "Server cannot be WiFi STA when using ENC28J60 at this time." #endif #ifdef WOLFSSL_ESP8266 #error "WOLFSSL_ESP8266 defined for ESP32 project. See user_settings.h" #endif + +#if defined(TXD_PIN) && defined(RXD_PIN) + #if TXD_PIN == RXD_PIN + #error "TXD_PIN cannot be the same as RXD_PIN" + #endif +#endif + +#endif /* _SSH_SERVER_CONFIG_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/include/time_helper.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/time_helper.h new file mode 100644 index 0000000..f20b6de --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/time_helper.h @@ -0,0 +1,55 @@ +/* time_helper.h + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +/* common Espressif time_helper v5.6.3.001 */ + +#ifndef _TIME_HELPER_H_ +#define _TIME_HELPER_H_ + +/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from release v5.0 + * See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#year-2036-and-2038-overflow-issues + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* a function to show the current data and time */ +int esp_show_current_datetime(void); + +/* worst case, if GitHub time not available, used fixed time */ +int set_fixed_default_time(void); + +/* set time from string (e.g. GitHub commit time) */ +int set_time_from_string(const char* time_buffer); + +/* set time from NTP servers, + * also initially calls set_fixed_default_time or set_time_from_string */ +int set_time(void); + +/* wait NTP_RETRY_COUNT seconds before giving up on NTP time */ +int set_time_wait_for_ntp(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* #ifndef _TIME_HELPER_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/tx_rx_buffer.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/tx_rx_buffer.h similarity index 74% rename from Espressif/ESP32/ESP32-SSH-Server/main/tx_rx_buffer.h rename to Espressif/ESP32/ESP32-SSH-Server/main/include/tx_rx_buffer.h index 282dd1d..51198cb 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/tx_rx_buffer.h +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/tx_rx_buffer.h @@ -1,5 +1,4 @@ -#pragma once -/* my_config.h +/* tx_rx_buffer.h * * Copyright (C) 2014-2022 wolfSSL Inc. * @@ -18,18 +17,24 @@ * You should have received a copy of the GNU General Public License * along with wolfSSH. If not, see . */ +#ifndef _TX_RX_BUFFER_H_ +#define _TX_RX_BUFFER_H_ #include #include #include + /* TODO do these really need to be so big? probably not */ -#define ExternalReceiveBufferMaxLength 2047 -#define ExternalTransmitBufferMaxLength 2047 +/* Sizes for shared transmit and receive buffers, for + * both external (typically UART) and SSH data streams */ +#define EXT_RX_BUF_MAX_SZ 2048 +#define EXT_TX_BUF_MAX_SZ 2048 typedef uint8_t byte; -int init_tx_rx_buffer(byte TxPin, byte RxPin); +int init_tx_rx_buffer(byte TxPin, byte RxPin); + int Get_ExternalTransmitBuffer(byte **ToData); int Set_ExternalTransmitBuffer(byte *FromData, int sz); @@ -38,3 +43,4 @@ int Set_ExternalReceiveBuffer(byte *FromData, int sz); bool ExternalReceiveBuffer_IsChar(char charValue); +#endif /* _TX_RX_BUFFER_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/uart_helper.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/uart_helper.h similarity index 72% rename from Espressif/ESP32/ESP32-SSH-Server/main/uart_helper.h rename to Espressif/ESP32/ESP32-SSH-Server/main/include/uart_helper.h index 861e441..6a8a1dc 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/uart_helper.h +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/uart_helper.h @@ -17,18 +17,24 @@ * You should have received a copy of the GNU General Public License * along with wolfSSH. If not, see . */ -#pragma once +#ifndef _UART_HELPER_H_ +#define _UART_HELPER_H_ -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_system.h" -#include "esp_log.h" -#include "driver/uart.h" -#include "string.h" -#include "driver/gpio.h" +#include +#include +#include +#include +#include +#include + +void init_UART(void); + +void uart_send_welcome(void); -void uart_send_welcome(); void uart_tx_task(void *arg); + void uart_rx_task(void *arg); int sendData(const char* logName, const char* data); + +#endif /* _UART_HELPER_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/include/wifi_connect.h b/Espressif/ESP32/ESP32-SSH-Server/main/include/wifi_connect.h new file mode 100644 index 0000000..e06451b --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/main/include/wifi_connect.h @@ -0,0 +1,97 @@ +/* wifi_connect.h + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ +#ifndef _WIFI_CONNECT_H_ +#define _WIFI_CONNECT_H_ + +#include +#include + +/* ESP lwip */ +#define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY + +#define USE_WIFI_EXAMPLE +#ifdef USE_WIFI_EXAMPLE + #if defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO ESP8266 WiFi */ + #else + #include /* see project CMakeLists.txt */ + #endif +#endif + +/** + ****************************************************************************** + ****************************************************************************** + ** USER APPLICATION SETTINGS BEGIN + ****************************************************************************** + ****************************************************************************** + **/ + +/* when using a private config with plain text passwords, + * file my_private_config.h should be excluded from git updates */ +/* #define USE_MY_PRIVATE_CONFIG */ +#undef USE_MY_PRIVATE_CONFIG +#ifdef USE_MY_PRIVATE_CONFIG + #if defined(WOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS) + #include "/workspace/my_private_config.h" WINDOWS_MY_PRIVATE_CONFIG + #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_WSL) + #include "/mnt/c/workspace/my_private_config.h" + #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_LINUX) + #include "~/workspace/my_private_config.h" + #elif defined(WOLFSSL_CMAKE_SYSTEM_NAME_APPLE) + #include "~/Documents/my_private_config.h" + #else + #warning "did not detect environment. using ~/my_private_config.h" + #include "~/my_private_config.h" + #endif +#else + + /* + ** The examples use WiFi configuration that you can set via project + ** configuration menu + ** + ** If you'd rather not, just change the below entries to strings with + ** the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" + */ + #ifdef CONFIG_ESP_WIFI_SSID + #define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID + #else + #define EXAMPLE_ESP_WIFI_SSID "MYSSID_WIFI_CONNECT" + #endif + + #ifdef CONFIG_ESP_WIFI_PASSWORD + #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD + #else + #define EXAMPLE_ESP_WIFI_PASS "MYPASSWORD_WIFI_CONNECT" + #endif +#endif + +/* ESP lwip */ +#define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY + +void wifi_init_softap(void); + +int wifi_init_sta(void); + +int wifi_show_ip(void); + +bool wifi_ready(void); + +#endif /* _WIFI_CONNECT_H_ */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/main.c b/Espressif/ESP32/ESP32-SSH-Server/main/main.c index e9cef8d..877d4f9 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/main.c +++ b/Espressif/ESP32/ESP32-SSH-Server/main/main.c @@ -1,6 +1,6 @@ -/* ssh_server.h +/* main.c * - * Copyright (C) 2014-2022 wolfSSL Inc. + * Copyright (C) 2006-2023 wolfSSL Inc. * * This file is part of wolfSSH. * @@ -30,77 +30,42 @@ * */ -/* WOLFSSL_USER_SETTINGS is defined here only for the syntax highlighter - * see CMakeLists.txt -#define WOLFSSL_USER_SETTINGS - */ - #include "sdkconfig.h" - /* include ssh_server_config.h first */ #include "my_config.h" #include "ssh_server_config.h" +#include "time_helper.h" +#include "main.h" #include #include -#include -#include -#include -/* see ssh_server_config.h for optional use of physical ethernet: USE_ENC28J60 */ -#ifdef USE_ENC28J60 - #include +/* wolfSSL */ +#ifndef WOLFSSL_USER_SETTINGS + #error "WOLFSSL_USER_SETTINGS should have been defined in project cmake" +#endif +/* Important: make sure settings.h appears before any other wolfSSL headers */ +#include +#include +#include +#ifndef WOLFSSL_ESPIDF + #error "Problem with wolfSSL user_settings." + #error "Check [project]/components/wolfssl/include" #endif - -/* - * wolfSSL - * - * IMPORTANT: Ensure wolfSSL settings.h appears before any other wolfSSL headers - * - * Example locations: - - * Standard ESP-IDF: - * C:\Users\[username]\Desktop\esp-idf\components\wolfssh\wolfssl\wolfcrypt\settings.h - * - * VisualGDB - * C:\SysGCC\esp32\esp-idf\[version]\components\wolfssl\wolfcrypt\settings.h - * - **/ #ifdef WOLFSSL_STALE_EXAMPLE #warning "This project is configured using local, stale wolfSSL code. See Makefile." #endif -#define WOLFSSL_ESPIDF -#define WOLFSSL_ESPWROOM32 - -#define WOLFSSL_TLS13 -#define HAVE_TLS_EXTENSIONS -#define HAVE_SUPPORTED_CURVES -#define HAVE_ECC -#define HAVE_HKDF -#define HAVE_FFDHE_8192 /* or one of the other supported FFDHE sizes [2048, 3072, 4096, 6144, 8192] */ -#define WC_RSA_PSS -#define WOLFSSH_TEST_THREADING - -/* note "file system": "load keys and certificate from files" vs NO_FILESYSTEM - * and "access an actual file system via SFTP/SCP" vs WOLFSSH_NO_FILESYSTEM - * we'll typically have neither on an embedded device: - */ -#define NO_FILESYSTEM -#define WOLFSSH_NO_FILESYSTEM -/* TODO check wolfSSL config - * #include - * make sure this appears before any other wolfSSL headers - */ - -#include -#include +/* see ssh_server_config.h for optional use of physical ethernet: USE_ENC28J60 */ +#ifdef USE_ENC28J60 + #include +#endif #ifdef USE_ENC28J60 /* no WiFi when using external ethernet */ #else - #include "wifi.h" + #include "wifi_connect.h" #endif #include "ssh_server.h" @@ -115,92 +80,15 @@ #undef LOG_LOCAL_LEVEL #endif #define LOG_LOCAL_LEVEL ESP_LOG_INFO -#include "esp_log.h" +#include -/* time */ -#include +#define THIS_MAX_MAIN_STACK_SIZE 6000 static const char *TAG = "SSH Server main"; /* 10 seconds, used for heartbeat message in thread */ -static TickType_t DelayTicks = (10000 / portTICK_PERIOD_MS); - - -int set_time() -{ - /* we'll also return a result code of zero */ - int res = 0; - int i = 0; /* counter for time servers */ - time_t interim_time; - - /* ideally, we'd like to set time from network, - * but let's set a default time, just in case */ - struct tm timeinfo = { - .tm_year = 2022 - 1900, - .tm_mon = 6, - .tm_mday = 29, - .tm_hour = 10, - .tm_min = 46, - .tm_sec = 10 - }; - struct timeval now; - - /* set interim static time */ - interim_time = mktime(&timeinfo); - now = (struct timeval){ .tv_sec = interim_time }; - settimeofday(&now, NULL); - - /* set timezone */ - setenv("TZ", TIME_ZONE, 1); - tzset(); - - /* next, let's setup NTP time servers - * - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#sntp-time-synchronization - */ - sntp_setoperatingmode(SNTP_OPMODE_POLL); - - ESP_LOGI(TAG, "sntp_setservername:"); - for (i = 0; i < NTP_SERVER_COUNT; i++) { - const char* thisServer = ntpServerList[i]; - if (strncmp(thisServer, "\x00", 1) == 0) { - /* just in case we run out of NTP servers */ - break; - } - ESP_LOGI(TAG, "%s", thisServer); - sntp_setservername(i, thisServer); - } - sntp_init(); - ESP_LOGI(TAG, "sntp_init done."); - return res; -} - +static TickType_t DelayTicks = (60000 / portTICK_PERIOD_MS); -#include "driver/uart.h" - -void init_UART(void) -{ - ESP_LOGI(TAG, "Begin init_UART."); - int intr_alloc_flags = 0; - const uart_config_t uart_config = { - .baud_rate = BAUD_RATE, - .data_bits = UART_DATA_8_BITS, - .parity = UART_PARITY_DISABLE, - .stop_bits = UART_STOP_BITS_1, - .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - .source_clk = UART_SCLK_APB, - }; - -#if CONFIG_UART_ISR_IN_IRAM - intr_alloc_flags = ESP_INTR_FLAG_IRAM; -#endif - /* We won't use a buffer for sending UART_NUM_1 data. */ - ESP_ERROR_CHECK(uart_driver_install(UART_NUM_1, 2048, 0, 0, NULL, intr_alloc_flags)); - ESP_ERROR_CHECK(uart_param_config(UART_NUM_1, &uart_config)); - ESP_ERROR_CHECK(uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); - - ESP_LOGI(TAG, "End init_UART."); -} void server_session(void* args) { @@ -242,15 +130,27 @@ bool NoEthernet() #if defined(WOLFSSH_SERVER_IS_AP) || defined(WOLFSSH_SERVER_IS_STA) void init_nvsflash() { + esp_err_t ret = ESP_OK; ESP_LOGI(TAG, "Setting up nvs flash for WiFi."); - esp_err_t ret = nvs_flash_init(); + + ret = nvs_flash_init(); + +#if defined(CONFIG_IDF_TARGET_ESP8266) + if (ret == ESP_ERR_NVS_NO_FREE_PAGES) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); + } +#else if (ret == ESP_ERR_NVS_NO_FREE_PAGES || - ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { + ret == ESP_ERR_NVS_NEW_VERSION_FOUND + ) { ESP_ERROR_CHECK(nvs_flash_erase()); ret = nvs_flash_init(); } +#endif + ESP_ERROR_CHECK(ret); } #endif @@ -258,26 +158,37 @@ void init_nvsflash() /* * main initialization for UART, optional ethernet, time, etc. */ -void init() +int init(void) { + int ret = ESP_OK; TickType_t EthernetWaitDelayTicks = (1000 / portTICK_PERIOD_MS); ESP_LOGI(TAG, "Begin main init."); -#ifdef DEBUG_WOLFSSH - ESP_LOGI(TAG, "wolfSSH debugging on."); - wolfSSH_Debugging_ON(); -#endif - + #ifdef DEBUG_WOLFSSH + { + ESP_LOGI(TAG, "wolfSSH debugging on."); + wolfSSH_Debugging_ON(); + } + #endif -#ifdef DEBUG_WOLFSSL - ESP_LOGI(TAG, "wolfSSL debugging on."); - wolfSSL_Debugging_ON(); - ESP_LOGI(TAG,"Debug ON"); + #ifdef DEBUG_WOLFSSL + { + ESP_LOGI(TAG, "wolfSSL debugging on."); + wolfSSL_Debugging_ON(); + ESP_LOGI(TAG, "Debug ON"); + } /* TODO ShowCiphers(); */ -#endif + #endif + /* Set time for cert validation. + * Some lwIP APIs, including SNTP functions, are not thread safe. */ + ret = set_time(); /* need to setup NTP before WiFi */ + +#ifndef DISABLE_SSH_UART + /* Our "External" device will be the UART, connected to the SSH server */ init_UART(); +#endif /* * here we have one of three options: @@ -288,47 +199,65 @@ void init() * * WiFi Station: WOLFSSH_SERVER_IS_STA **/ -#if defined(USE_ENC28J60) - /* wired ethernet */ - ESP_LOGI(TAG, "Found USE_ENC28J60 config."); - init_ENC28J60(MY_MAC_ADDRESS); - -#elif defined( WOLFSSH_SERVER_IS_AP) - /* acting as an access point */ - init_nvsflash(); - - ESP_LOGI(TAG, "Begin setup WiFi Soft AP."); - wifi_init_softap(); - ESP_LOGI(TAG, "End setup WiFi Soft AP."); - -#elif defined(WOLFSSH_SERVER_IS_STA) - /* acting as a WiFi Station (client) */ - init_nvsflash(); - - ESP_LOGI(TAG, "Begin setup WiFi STA."); - wifi_init_sta(); - ESP_LOGI(TAG, "End setup WiFi STA."); -#else - /* we should never get here */ - while (1) + #if defined(USE_ENC28J60) { - ESP_LOGE(TAG,"ERROR: No network is defined... choose USE_ENC28J60, \ - WOLFSSH_SERVER_IS_AP, or WOLFSSH_SERVER_IS_STA "); - vTaskDelay(EthernetWaitDelayTicks ? EthernetWaitDelayTicks : 1); + /* wired ethernet */ + ESP_LOGI(TAG, "Found USE_ENC28J60 config."); + init_ENC28J60(MY_MAC_ADDRESS); } -#endif + + #elif defined( WOLFSSH_SERVER_IS_AP) + { + /* acting as an access point */ + init_nvsflash(); + + ESP_LOGI(TAG, "Begin setup WiFi Soft AP."); + wifi_init_softap(); + ESP_LOGI(TAG, "End setup WiFi Soft AP."); + } + + #elif defined(WOLFSSH_SERVER_IS_STA) + { + /* acting as a WiFi Station (client) */ + init_nvsflash(); + + ESP_LOGI(TAG, "Begin setup WiFi STA."); + wifi_init_sta(); + ESP_LOGI(TAG, "End setup WiFi STA."); + } + #else + { + /* we should never get here */ + while (1) + { + ESP_LOGE(TAG, + "ERROR: No network is defined... choose USE_ENC28J60, \ + WOLFSSH_SERVER_IS_AP, or WOLFSSH_SERVER_IS_STA "); + vTaskDelay(EthernetWaitDelayTicks ? EthernetWaitDelayTicks : 1); + } + } + #endif while (NoEthernet()) { ESP_LOGI(TAG,"Waiting for ethernet..."); vTaskDelay(EthernetWaitDelayTicks ? EthernetWaitDelayTicks : 1); } - /* one of the most important aspects of security is the time and date values */ - set_time(); - ESP_LOGI(TAG,"inet_pton"); /* TODO */ - wolfSSH_Init(); + /* Once we are connected to the network, start & wait for NTP time */ + ret = set_time_wait_for_ntp(); + + if (ret < -1) { + /* a value of -1 means there was no NTP server, so no need to wait */ + ESP_LOGI(TAG, "Waiting 10 more seconds for NTP to complete." ); + vTaskDelay(10000 / portTICK_PERIOD_MS); /* brute-force solution */ + esp_show_current_datetime(); + } + + ret = wolfSSH_Init(); + + return ret; } /** @@ -345,21 +274,82 @@ static bool is_our_netif(const char *prefix, esp_netif_t *netif) { void app_main(void) { + /* main stack size: 4048 */ + int stack_start = 0; + + ESP_LOGI(TAG, "---------------- wolfSSL Benchmark Example -------------"); + ESP_LOGI(TAG, "--------------------------------------------------------"); + ESP_LOGI(TAG, "--------------------------------------------------------"); + ESP_LOGI(TAG, "---------------------- BEGIN MAIN ----------------------"); + ESP_LOGI(TAG, "--------------------------------------------------------"); + ESP_LOGI(TAG, "--------------------------------------------------------"); +#ifdef CONFIG_ESP_MAIN_TASK_STACK_SIZE + ESP_LOGI(TAG, "ESP_TASK_MAIN_STACK: %d", CONFIG_ESP_MAIN_TASK_STACK_SIZE); + if (CONFIG_ESP_MAIN_TASK_STACK_SIZE > THIS_MAX_MAIN_STACK_SIZE) { + ESP_LOGW(TAG, "Warning: excessively large main task size!"); + } +#endif +#ifdef ESP_TASK_MAIN_STACK + ESP_LOGI(TAG, "ESP_TASK_MAIN_STACK: %d", ESP_TASK_MAIN_STACK); +#endif +#ifdef ESP_TASK_MAIN_STACK + ESP_LOGI(TAG, "ESP_TASK_MAIN_STACK: %d", ESP_TASK_MAIN_STACK); +#endif +#ifdef TASK_EXTRA_STACK_SIZE + ESP_LOGI(TAG, "TASK_EXTRA_STACK_SIZE: %d", TASK_EXTRA_STACK_SIZE); +#endif +#ifdef INCLUDE_uxTaskGetStackHighWaterMark + ESP_LOGI(TAG, "CONFIG_ESP_MAIN_TASK_STACK_SIZE = %d bytes (%d words)", + CONFIG_ESP_MAIN_TASK_STACK_SIZE, + (int)(CONFIG_ESP_MAIN_TASK_STACK_SIZE / sizeof(void*))); + + /* Returns the high water mark of the stack associated with xTask. That is, + * the minimum free stack space there has been (in bytes not words, unlike + * vanilla FreeRTOS) since the task started. The smaller the returned + * number the closer the task has come to overflowing its stack. + * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html + */ + stack_start = uxTaskGetStackHighWaterMark(NULL); + ESP_LOGI(TAG, "Stack Start HWM: %d bytes", stack_start); +#endif + ESP_LOGI(TAG, "UART_RX_TASK_STACK_SIZE: %d bytes", + UART_RX_TASK_STACK_SIZE); + ESP_LOGI(TAG, "UART_TX_TASK_STACK_SIZE: %d bytes", + UART_TX_TASK_STACK_SIZE); + ESP_LOGI(TAG, "SERVER_SESSION_STACK_SIZE: %d bytes", + SERVER_SESSION_STACK_SIZE); +#ifdef ESP_ENABLE_WOLFSSH + ESP_LOGI(TAG, "SSH DEFAULT_WINDOW_SZ: %d bytes", + DEFAULT_WINDOW_SZ); +#else + #error "ESP_ENABLE_WOLFSSH ust be enabled for this project" +#endif +#if defined(HAVE_VERSION_EXTENDED_INFO) + esp_ShowExtendedSystemInfo(); +#endif + init(); - /* note that by the time we get here, the scheduler is already running! - * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#esp-idf-freertos-applications + /* Note that by the time we get here, the scheduler is already running! + * See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html#esp-idf-freertos-applications * Unlike Vanilla FreeRTOS, users must not call vTaskStartScheduler(); * - * all of the tasks are at the same, highest idle priority, so they will all get equal attention - * when priority was set to configMAX_PRIORITIES - [1,2,3] there was an odd WDT timeout warning. + * All of the tasks are at the same, highest idle priority, so they will + * all get equal attentiom when priority was set to + * configMAX_PRIORITIES - [1,2,3] + * there was an odd WDT timeout warning. */ - xTaskCreate(uart_rx_task, "uart_rx_task", 1024 * 2, NULL, +#ifndef DISABLE_SSH_UART + xTaskCreate(uart_rx_task, "uart_rx_task", + UART_RX_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL); - xTaskCreate(uart_tx_task, "uart_tx_task", 1024 * 2, NULL, + xTaskCreate(uart_tx_task, "uart_tx_task", + UART_TX_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL); +#endif - xTaskCreate(server_session, "server_session", 6024 * 2, NULL, + xTaskCreate(server_session, "server_session", + SERVER_SESSION_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL); @@ -373,4 +363,4 @@ void app_main(void) /* TODO this is unreachable with RTOS threads, do we ever want to shut down? */ wolfSSH_Cleanup(); -} +} /* app_main */ diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server.c b/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server.c index d89927d..226ccdf 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server.c +++ b/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server.c @@ -17,20 +17,44 @@ * You should have received a copy of the GNU General Public License * along with wolfSSH. If not, see . */ + #include "ssh_server_config.h" #include "ssh_server.h" #include "tx_rx_buffer.h" #include + +/* wolfSSL */ +#ifndef WOLFSSL_USER_SETTINGS + #error "WOLFSSL_USER_SETTINGS should have been defined in project cmake" +#endif +/* Important: make sure settings.h appears before any other wolfSSL headers */ +#include +#include +#include #include +#ifndef WOLFSSL_ESPIDF + #error "Problem with wolfSSL user_settings." + #error "Check [project]/components/wolfssl/include" +#endif +/* wolfSSL */ +#include +#include +#include +#include +#include + +/* wolfSSH */ +#include +#include /* note our actual buffer is used by RTOS threads, and eventually interrupts */ -static volatile byte sshStreamTransmitBufferArray[ExternalTransmitBufferMaxLength]; -static volatile byte sshStreamReceiveBufferArray[ExternalReceiveBufferMaxLength]; +static volatile byte sshStreamTransmitBufferArray[EXT_TX_BUF_MAX_SZ]; +static volatile byte sshStreamReceiveBufferArray[EXT_RX_BUF_MAX_SZ]; -char * TAG = "ssh_server"; +static const char* TAG = "ssh_server"; static const char samplePasswordBuffer[] = "jill:upthehill\n" @@ -63,7 +87,18 @@ static const char samplePublicKeyRsaBuffer[] = "biE57dK6BrH5iZwVLTQKux31uCJLPhiktI3iLbdlGZEctJkTasfVSsUizwVIyRjhVKmbdI" "RGwkU38D043AR1h0mUoGCPIKuqcFMf gretel\n"; +/* #define SSH_SERVER_PROFILE */ + +#ifdef SSH_SERVER_PROFILE + static int MaxSeenRxSize = 0; + static int MaxSeenTxSize = 0; +#endif +/* Show HW lockdepth. Oddities here are often a symptom of stack overflow. */ +#if !defined(NO_WOLFSSL_ESP32_CRYPT_HASH) && \ + defined(WOLFSSL_ESP32_HW_LOCK_DEBUG) + #define SSH_SERVER_DEBUG_LOCKDEPTH +#endif /* Map user names to passwords */ /* Use arrays for username and p. The password or public key can * be hashed and the hash stored here. Then I won't need the type. */ @@ -80,12 +115,6 @@ typedef struct PwMapList { PwMap* head; } PwMapList; -enum { - WS_SELECT_FAIL, - WS_SELECT_TIMEOUT, - WS_SELECT_RECV_READY, - WS_SELECT_ERROR_READY -}; typedef struct { WOLFSSH* ssh; @@ -97,23 +126,28 @@ typedef struct { /* find a byte character [str] of length [bufSz] within [buf]; * returns byte position if found, otherwise zero - * TODO what if bufSz > 255? */ static byte find_char(const byte* str, const byte* buf, word32 bufSz) { + int ret = 0; + ESP_LOGW(TAG, "Updated ret code, needs tested"); /* TODO */ const byte* cur; - while (bufSz) { + while (bufSz && (ret == 0) && (ret < 255)) { cur = str; while (*cur != '\0') { - if (*cur == *buf) - return *cur; + if (*cur == *buf) { + ret = *cur; + } cur++; } buf++; bufSz--; } + if (ret == 255) { + ESP_LOGE(TAG, "find_char not found in 254 chars"); + } - return 0; + return ret; } @@ -142,56 +176,6 @@ static int dump_stats(thread_ctx_t* ctx) return wolfSSH_stream_send(ctx->ssh, (byte*)stats, statsSz); } -static WC_INLINE int wSelect(int nfds, - WFD_SET_TYPE* recvfds, - WFD_SET_TYPE *writefds, - WFD_SET_TYPE *errfds, - struct timeval* timeout) -{ -#ifdef WOLFSSL_NUCLEUS - int ret = NU_Select(nfds, - recvfds, - writefds, - errfds, - (UNSIGNED)timeout->tv_sec); - if (ret == NU_SUCCESS) { - return 1; - } - return 0; -#else - return select(nfds, recvfds, writefds, errfds, timeout); -#endif -} - -/* - * tcp_select; call wSelect & check for success or fail - */ -static WC_INLINE int tcp_select(SOCKET_T socketfd, int to_sec) -{ - WFD_SET_TYPE recvfds, errfds; - int nfds = (int)socketfd + 1; - struct timeval timeout = { (to_sec > 0) ? to_sec : 0, 0 }; - int result; - - WFD_ZERO(&recvfds); - WFD_SET(socketfd, &recvfds); - WFD_ZERO(&errfds); - WFD_SET(socketfd, &errfds); - - result = wSelect(nfds, &recvfds, NULL, &errfds, &timeout); - - if (result == 0) - return WS_SELECT_TIMEOUT; - else if (result > 0) { - if (WFD_ISSET(socketfd, &recvfds)) - return WS_SELECT_RECV_READY; - else if (WFD_ISSET(socketfd, &errfds)) - return WS_SELECT_ERROR_READY; - } - - return WS_SELECT_FAIL; -} - static int NonBlockSSH_accept(WOLFSSH* ssh) { int ret; @@ -233,24 +217,21 @@ static int NonBlockSSH_accept(WOLFSSH* ssh) /* RTOS yield */ vTaskDelay(100 / portTICK_PERIOD_MS); - esp_task_wdt_reset(); + #ifdef SSH_SERVER_WDT_RESET + { + esp_task_wdt_reset(); + } + #endif } ESP_LOGI(TAG,"Exit NonBlockSSH_accept"); return ret; } -/* #define SSH_SERVER_PROFILE */ - -#ifdef SSH_SERVER_PROFILE - static int MaxSeenRxSize = 0; - static int MaxSeenTxSize = 0; -#endif - /* * server_worker is the main thread for a given SSH connection - **/ + */ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs) { int ret; @@ -301,6 +282,7 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs) /* int show_msg = 0; TODO optionally disable echo of text to USB port */ int has_err = 0; this_rx_buf = (byte*)&sshStreamReceiveBufferArray; + vTaskDelay(10); if (!stop) { do { @@ -320,6 +302,12 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs) stop = 1; } + /* when polling, debugging can be verbose, turn it off */ + #ifdef DEBUG_WOLFSSH + ESP_LOGV(TAG, "wolfSSH debugging off."); + wolfSSH_Debugging_OFF(); + #endif + /* this is a blocking call, awaiting an SSH keypress * unless nonBlock = 1 (normally we are NOT blocking) */ rxSz = wolfSSH_stream_read(threadCtx->ssh, @@ -337,12 +325,25 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs) { /* any other negative value is an error */ has_err = 1; - ESP_LOGE(TAG,"wolfSSH_stream_read error!"); + ESP_LOGE(TAG, "wolfSSH_stream_read error!"); } } + else { + ESP_LOGI(TAG,"Received %d bytes from client.", rxSz); + } + + /* turn debugging back on */ + #ifdef DEBUG_WOLFSSH + ESP_LOGV(TAG, "wolfSSH debugging on."); + wolfSSH_Debugging_ON(); + #endif taskYIELD(); - esp_task_wdt_reset(); + #ifdef SSH_SERVER_WDT_RESET + { + esp_task_wdt_reset(); + } + #endif } while ((WOLFSSL_NONBLOCK == 0) /* we'll wait only when not using non-blocking socket */ && @@ -460,7 +461,11 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs) } taskYIELD(); - esp_task_wdt_reset(); + #ifdef SSH_SERVER_WDT_RESET + { + esp_task_wdt_reset(); + } + #endif } /* while */ if (txSum < backlogSz) { @@ -478,12 +483,12 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs) } } -#ifdef DEBUG_WDT + #ifdef DEBUG_WDT /* if we get panic faults, perhaps the watchdog needs attention? */ taskYIELD(); vTaskDelay(pdMS_TO_TICKS(10)); esp_task_wdt_reset(); -#endif + #endif } while (!stop); } /* if (ret == WS_SUCCESS) */ @@ -574,8 +579,14 @@ static int load_key(byte isEcc, byte* buf, word32 bufSz) if ((word32)sizeof_ecc_key_der_256 > bufSz) { return 0; } + #ifdef DEMO_SERVER_384 + WMEMCPY(buf, ecc_key_der_384, sizeof_ecc_key_der_384); + sz = sizeof_ecc_key_der_384; + #else WMEMCPY(buf, ecc_key_der_256, sizeof_ecc_key_der_256); sz = sizeof_ecc_key_der_256; + #endif + } else { if ((word32)sizeof_rsa_key_der_2048 > bufSz) { @@ -605,12 +616,14 @@ static PwMap* PwMapNew(PwMapList* list, word32 usernameSz, const byte* p, word32 pSz) { - PwMap* map; + PwMap* map = NULL; map = (PwMap*)malloc(sizeof(PwMap)); if (map != NULL) { - wc_Sha256 sha; + // wc_Sha256 sha[2] = { }; + wc_Sha256 sha = { }; byte flatSz[4]; + int fsz = 0; map->type = type; if (usernameSz >= sizeof(map->username)) @@ -619,11 +632,30 @@ static PwMap* PwMapNew(PwMapList* list, map->username[usernameSz] = 0; map->usernameSz = usernameSz; + ESP_LOGI(TAG, "map->username = %s", map->username); + wc_InitSha256(&sha); c32toa(pSz, flatSz); - wc_Sha256Update(&sha, flatSz, sizeof(flatSz)); - wc_Sha256Update(&sha, p, pSz); - wc_Sha256Final(&sha, map->p); + + fsz = sizeof(flatSz); + ESP_LOGI(TAG, "SHA256 flatSz: 0x%02x%02x%02x%02x; size = %d", + flatSz[0], flatSz[1], flatSz[2], flatSz[3], fsz); + ESP_LOGI(TAG, "SHA256 sample password: '%s': size = %d bytes", p, pSz); + #if defined(SSH_SERVER_DEBUG_LOCKDEPTH) + ESP_LOGW(TAG, "PwMapNew sha256 final ctx->lockDepth = %d", + (&sha.ctx)->lockDepth); + ESP_LOGW(TAG, "calling wc_Sha256Update(1) ctx->lockDepth = %d", + (&sha.ctx)->lockDepth); + #endif + wc_Sha256Update((wc_Sha256*)&sha, flatSz, fsz); + #if defined(SSH_SERVER_DEBUG_LOCKDEPTH) + ESP_LOGW(TAG, "calling wc_Sha256Update(2) ctx->lockDepth = %d", (&sha.ctx)->lockDepth); + #endif + wc_Sha256Update((wc_Sha256*)&sha, p, pSz); + #if defined(SSH_SERVER_DEBUG_LOCKDEPTH) + ESP_LOGW(TAG, "calling wc_Sha256Final ctx->lockDepth = %d", (&sha.ctx)->lockDepth); + #endif + wc_Sha256Final((wc_Sha256*)&sha, (byte*)map->p); map->next = list->head; list->head = map; @@ -663,8 +695,10 @@ static int LoadPasswordBuffer(byte* buf, word32 bufSz, PwMapList* list) if (list == NULL) return -1; - if (buf == NULL || bufSz == 0) + if (buf == NULL || bufSz == 0) { + ESP_LOGW(TAG, "Warning: LoadPasswordBuffer size is zero!"); return 0; + } while (*str != 0) { delimiter = strchr(str, ':'); @@ -712,8 +746,10 @@ static int LoadPublicKeyBuffer(byte* buf, word32 bufSz, PwMapList* list) if (list == NULL) return -1; - if (buf == NULL || bufSz == 0) + if (buf == NULL || bufSz == 0) { + ESP_LOGW(TAG, "Warning: LoadPublicKeyBuffer buffer size is zero!"); return 0; + } while (*str != 0) { /* Skip the public key type. This example will always be ssh-rsa. */ @@ -837,64 +873,6 @@ static int wsUserAuth(byte authType, typedef THREAD_RETURN WOLFSSH_THREAD THREAD_FUNC(void*); -static WC_INLINE void ThreadStart(THREAD_FUNC fun, void* args, THREAD_TYPE* thread) { -#ifdef SINGLE_THREADED - (void)fun; - (void)args; - (void)thread; -#elif defined(_POSIX_THREADS) && !defined(__MINGW32__) -#ifdef WOLFSSL_VXWORKS - { - pthread_attr_t myattr; - pthread_attr_init(&myattr); - pthread_attr_setstacksize(&myattr, 0x10000); - pthread_create(thread, &myattr, fun, args); - } -#else - pthread_create(thread, 0, fun, args); -#endif - return; -#elif defined(WOLFSSL_TIRTOS) - /* Initialize the defaults and set the parameters. */ - Task_Params taskParams; - Task_Params_init(&taskParams); - taskParams.arg0 = (UArg)args; - taskParams.stackSize = 65535; - *thread = Task_create((Task_FuncPtr)fun, &taskParams, NULL); - if (*thread == NULL) { - printf("Failed to create new Task\n"); - } - Task_yield(); -#else - * thread = (THREAD_TYPE)_beginthreadex(0, 0, fun, args, 0, 0); -#endif -} - - -static WC_INLINE void ThreadJoin(THREAD_TYPE thread) -{ -#ifdef SINGLE_THREADED - (void)thread; -#elif defined(_POSIX_THREADS) && !defined(__MINGW32__) - pthread_join(thread, 0); -#elif defined(WOLFSSL_TIRTOS) - while (1) { - if (Task_getMode(thread) == Task_Mode_TERMINATED) { - Task_sleep(5); - break; - } - Task_yield(); - } -#else - int res = WaitForSingleObject((HANDLE)thread, INFINITE); - assert(res == WAIT_OBJECT_0); - res = CloseHandle((HANDLE)thread); - assert(res); - (void)res; /* Suppress un-used variable warning */ -#endif -} - - static WC_INLINE void ThreadDetach(THREAD_TYPE thread) { #ifdef SINGLE_THREADED (void)thread; @@ -959,27 +937,6 @@ static int my_IOSend(WOLFSSH* ssh, void* buff, word32 sz, void* ctx) { } */ -static WC_INLINE void tcp_set_nonblocking(SOCKET_T* sockfd) -{ - #ifdef USE_WINDOWS_API - unsigned long blocking = 1; - int ret = ioctlsocket(*sockfd, FIONBIO, &blocking); - if (ret == SOCKET_ERROR) - err_sys_with_errno("ioctlsocket failed"); - #elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET) \ - || defined (WOLFSSL_TIRTOS)|| defined(WOLFSSL_VXWORKS) \ - || defined(WOLFSSL_ZEPHYR) - /* non blocking not supported, for now */ - #else - int flags = fcntl(*sockfd, F_GETFL, 0); - if (flags < 0) - ESP_LOGE(TAG,"fcntl get failed"); - flags = fcntl(*sockfd, F_SETFL, flags | O_NONBLOCK); - if (flags < 0) - ESP_LOGE(TAG,"fcntl set failed"); - #endif -} - void server_test(void *arg) { int DEFAULT_PORT = SSH_UART_PORT; @@ -1015,12 +972,6 @@ void server_test(void *arg) /* TODO ShowCiphers(); */ #endif /* DEBUG_WOLFSSL */ - -#ifndef WOLFSSL_TLS13 - ret = WOLFSSL_FAILURE; - ESP_LOGE(TAG,"\r\nERROR: Example requires TLS v1.3.\n"); -#endif /* WOLFSSL_TLS13 */ - /* Initialize the server address struct with zeros */ memset(&servAddr, 0, sizeof(servAddr)); @@ -1361,6 +1312,7 @@ void server_test(void *arg) const char* bufName; byte buf[SCRATCH_BUFFER_SZ]; word32 bufSz; + int ret = 0; bufSz = load_key(useEcc, buf, SCRATCH_BUFFER_SZ); if (bufSz == 0) { @@ -1378,7 +1330,11 @@ void server_test(void *arg) bufSz = (word32)strlen(samplePasswordBuffer); memcpy(buf, samplePasswordBuffer, bufSz); buf[bufSz] = 0; - LoadPasswordBuffer(buf, bufSz, &pwMapList); + ret = LoadPasswordBuffer(buf, bufSz, &pwMapList); + if (ret != 0) { + ESP_LOGE(TAG, "Error: failed LoadPasswordBuffer %d", ret); + exit(EXIT_FAILURE); + } bufName = useEcc ? samplePublicKeyEccBuffer : samplePublicKeyRsaBuffer; @@ -1386,6 +1342,10 @@ void server_test(void *arg) memcpy(buf, bufName, bufSz); buf[bufSz] = 0; LoadPublicKeyBuffer(buf, bufSz, &pwMapList); + if (ret != 0) { + ESP_LOGE(TAG, "Error: failed LoadPasswordBuffer %d", ret); + exit(EXIT_FAILURE); + } } listen(sockfd, 5); @@ -1451,17 +1411,22 @@ void server_test(void *arg) ESP_LOGI(TAG,"server_worker started."); #ifndef SINGLE_THREADED + #ifdef WOLFSSH_TEST_THREADING ThreadStart(server_worker, threadCtx, &thread); if (multipleConnections) ThreadDetach(thread); else ThreadJoin(thread); + #else + /* see "wolfssh/test.h" check user_settings.h */ + #error "WOLFSSH_TEST_THREADING must be enabled unless SINGLE_THREADED" + #endif #else server_worker(threadCtx); #endif /* SINGLE_THREADED */ ESP_LOGI(TAG,"server_worker completed."); - + vTaskDelay(10); } while (multipleConnections); ESP_LOGI(TAG,"all servers exited."); diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server_config.c b/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server_config.c index eb2019c..eeb803b 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server_config.c +++ b/Espressif/ESP32/ESP32-SSH-Server/main/ssh_server_config.c @@ -1,30 +1,32 @@ -/* ssh_server_config.c - * - * Copyright (C) 2014-2022 wolfSSL Inc. - * - * This file is part of wolfSSH. - * - * wolfSSH is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * wolfSSH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with wolfSSH. If not, see . - */ -#include "ssh_server_config.h" - -/* our NTP server list is global info */ -char* ntpServerList[NTP_SERVER_COUNT] = NTP_SERVER_LIST; - -void ssh_server_config_init() -{ - ESP_LOGI("init", "ssh_server_config_init"); -} - - +/* ssh_server_config.c + * + * Copyright (C) 2014-2022 wolfSSL Inc. + * + * This file is part of wolfSSH. + * + * wolfSSH is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * wolfSSH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with wolfSSH. If not, see . + */ +#include "ssh_server_config.h" + +int ssh_server_config_init(void) +{ + int ret = ESP_OK; + ESP_LOGI("init", "ssh_server_config_init"); + + /* TODO make public the esp_util show_macro() */ +/* show_macro("NO_ESPIDF_DEFAULT", STR_IFNDEF(NO_ESPIDF_DEFAULT)); */ + return ret; +} + + diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/time_helper.c b/Espressif/ESP32/ESP32-SSH-Server/main/time_helper.c new file mode 100644 index 0000000..e0cf43e --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/main/time_helper.c @@ -0,0 +1,378 @@ +/* time_helper.c + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +/* See https://tf.nist.gov/tf-cgi/servers.cgi */ + +/* common Espressif time_helper v5.6.6.001 */ +#include "sdkconfig.h" +#include "time_helper.h" + +#include +#include + +#if defined(ESP_IDF_VERSION_MAJOR) && defined(ESP_IDF_VERSION_MINOR) + #if (ESP_IDF_VERSION_MAJOR == 5) && (ESP_IDF_VERSION_MINOR >= 1) + #define HAS_ESP_NETIF_SNTP 1 + #include + #include + #else + #include + #include + #endif +#else + /* TODO Consider non ESP-IDF environments */ +#endif + +/* ESP-IDF uses a 64-bit signed integer to represent time_t starting from release v5.0 + * See: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#year-2036-and-2038-overflow-issues + */ + +/* see https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html */ +#ifndef TIME_ZONE + /* + * PST represents Pacific Standard Time. + * +8 specifies the offset from UTC (Coordinated Universal Time), indicating + * that Pacific Time is UTC-8 during standard time. + * PDT represents Pacific Daylight Time. + * M3.2.0 indicates that Daylight Saving Time (DST) starts on the + * second (2) Sunday (0) of March (3). + * M11.1.0 indicates that DST ends on the first (1) Sunday (0) of November (11) + */ + #define TIME_ZONE "PST+8PDT,M3.2.0,M11.1.0" +#endif /* not defined: TIME_ZONE, so we are setting our own */ + +#define NTP_RETRY_COUNT 10 + +/* NELEMS(x) number of elements + * To determine the number of elements in the array, we can divide the total + * size of the array by the size of the array element. + * See https://stackoverflow.com/questions/37538/how-do-i-determine-the-size-of-my-array-in-c + **/ +#define NELEMS(x) ( (int)(sizeof(x) / sizeof((x)[0])) ) + +/* See also CONFIG_LWIP_SNTP_MAX_SERVERS in sdkconfig */ +#define NTP_SERVER_LIST ( (char*[]) { \ + "pool.ntp.org", \ + "time.nist.gov", \ + "utcnist.colorado.edu" \ + } \ + ) +/* #define NTP_SERVER_COUNT using NELEMS: + * + * (int)(sizeof(NTP_SERVER_LIST) / sizeof(NTP_SERVER_LIST[0])) + */ +#define NTP_SERVER_COUNT NELEMS(NTP_SERVER_LIST) + +#ifndef CONFIG_LWIP_SNTP_MAX_SERVERS + /* We should find max value in sdkconfig, if not set it to our count:*/ + #define CONFIG_LWIP_SNTP_MAX_SERVERS NTP_SERVER_COUNT +#endif + +char* ntpServerList[NTP_SERVER_COUNT] = NTP_SERVER_LIST; + +const static char* TAG = "time_helper"; + +/* our NTP server list is global info */ +extern char* ntpServerList[NTP_SERVER_COUNT]; + +/* Show the current date and time */ +int esp_show_current_datetime(void) +{ + time_t now; + char strftime_buf[64]; + struct tm timeinfo; + + time(&now); + setenv("TZ", TIME_ZONE, 1); + tzset(); + + localtime_r(&now, &timeinfo); + strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo); + ESP_LOGI(TAG, "The current date/time is: %s", strftime_buf); + return ESP_OK; +} + +/* the worst-case scenario is a hard-coded date/time */ +int set_fixed_default_time(void) +{ + /* ideally, we'd like to set time from network, + * but let's set a default time, just in case */ + struct tm timeinfo = { + .tm_year = 2023 - 1900, + .tm_mon = 1, + .tm_mday = 02, + .tm_hour = 13, + .tm_min = 01, + .tm_sec = 05 + }; + struct timeval now; + time_t interim_time; + int ret = -1; + + /* set interim static time */ + interim_time = mktime(&timeinfo); + + ESP_LOGI(TAG, "Adjusting time from fixed value"); + now = (struct timeval){ .tv_sec = interim_time }; + ret = settimeofday(&now, NULL); + ESP_LOGI(TAG, "settimeofday result = %d", ret); + return ret; +} + +/* probably_valid_time_string(s) + * + * some sanity checks on time string before calling sscanf() + * + * returns 0 == ESP_OK == Success if str is likely a valid time. + * -1 == ESP_FAIL otherwise + */ +int probably_valid_time_string(const char* str) +{ + int ret = ESP_OK; + size_t length = 0; + size_t spaces = 0; + size_t colons = 0; + + while (str[length] != '\0') { + if (str[length] == ' ') { + spaces++; + } + if (str[length] == ':') { + colons++; + } + length++; + } + + if ((length > 32) || (spaces < 4) || (spaces > 5) || (colons > 2)) { + ret = ESP_FAIL; + ESP_LOGE(TAG, "ERROR, failed time sanity check: %s", str); + } + return ret; +} + +/* set_time_from_string(s) + * + * returns 0 = success if able to set the time from the provided string + * error for any other value, typically -1 */ +int set_time_from_string(const char* time_buffer) +{ + /* expecting github default formatting: 'Thu Aug 31 12:41:45 2023 -0700' */ + const char *format = "%3s %3s %d %d:%d:%d %d %s"; + struct tm this_timeinfo; + struct timeval now; + time_t interim_time; + char offset[28]; /* large arrays, just in case there's still bad data */ + char day_str[28]; + char month_str[28]; + int day, year, hour, minute, second; + int quote_offset = 0; + int ret = 0; + + /* perform some basic sanity checkes */ + ret = probably_valid_time_string(time_buffer); + if (ret == ESP_OK) { + /* we are expecting the string to be encapsulated in single quotes */ + if (*time_buffer == 0x27) { + quote_offset = 1; + } + + ret = sscanf(time_buffer + quote_offset, + format, + day_str, month_str, + &day, &hour, &minute, &second, &year, &offset); + + if (ret == 8) { + /* we found a match for all componets */ + + const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + + for (int i = 0; i < 12; i++) { + if (strcmp(month_str, months[i]) == 0) { + this_timeinfo.tm_mon = i; + break; + } + } + + this_timeinfo.tm_mday = day; + this_timeinfo.tm_hour = hour; + this_timeinfo.tm_min = minute; + this_timeinfo.tm_sec = second; + this_timeinfo.tm_year = year - 1900; /* Number of years since 1900 */ + + interim_time = mktime(&this_timeinfo); + now = (struct timeval){ .tv_sec = interim_time }; + ret = settimeofday(&now, NULL); + ESP_LOGI(TAG, "Time updated to %s", time_buffer); + } + else { + ESP_LOGE(TAG, "Failed to convert \"%s\" to a tm date.", time_buffer); + ESP_LOGI(TAG, "Trying fixed date that was hard-coded."); + set_fixed_default_time(); + ret = ESP_FAIL; + } + } + + return ret; +} + +/* set time; returns 0 if succecssfully configured with NTP */ +int set_time(void) +{ +#ifndef NTP_SERVER_COUNT + ESP_LOGW(TAG, "Warning: no sntp server names defined. " + "Setting to empty list"); + #define NTP_SERVER_COUNT 0 + #warning "NTP not properly configured" +#endif /* not defined: NTP_SERVER_COUNT */ + +#ifdef HAS_ESP_NETIF_SNTP + #if CONFIG_LWIP_SNTP_MAX_SERVERS > 1 + esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG_MULTIPLE( + NTP_SERVER_COUNT, + ESP_SNTP_SERVER_LIST(ntpServerList[0]) + ); + #else + esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG(ntpServerList[0]); + #endif /* CONFIG_LWIP_SNTP_MAX_SERVERS > 1 */ +#endif /* HAS_ESP_NETIF_SNTP */ + + int ret = 0; + int i = 0; /* counter for time servers */ + + ESP_LOGI(TAG, "Setting the time. Startup time:"); + esp_show_current_datetime(); + +#ifdef LIBWOLFSSL_VERSION_GIT_HASH_DATE + /* initialy set a default approximate time from recent git commit */ + ESP_LOGI(TAG, "Found git hash date, attempting to set system date."); + set_time_from_string(LIBWOLFSSL_VERSION_GIT_HASH_DATE); + esp_show_current_datetime(); + + ret = -4; +#else + /* otherwise set a fixed time that was hard coded */ + set_fixed_default_time(); + esp_show_current_datetime(); + ret = -3; +#endif + +#ifdef CONFIG_SNTP_TIME_SYNC_METHOD_SMOOTH + config.smooth_sync = true; +#endif + + if (NTP_SERVER_COUNT) { + /* next, let's setup NTP time servers + * + * see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html#sntp-time-synchronization + * + * WARNING: do not set operating mode while SNTP client is running! + */ + /* TODO Consider esp_sntp_setoperatingmode(SNTP_OPMODE_POLL); */ + sntp_setoperatingmode(SNTP_OPMODE_POLL); + if (NTP_SERVER_COUNT > CONFIG_LWIP_SNTP_MAX_SERVERS) { + ESP_LOGW(TAG, "WARNING: %d NTP Servers defined, but " + "CONFIG_LWIP_SNTP_MAX_SERVERS = %d", + NTP_SERVER_COUNT,CONFIG_LWIP_SNTP_MAX_SERVERS); + } + ESP_LOGI(TAG, "sntp_setservername:"); + for (i = 0; i < CONFIG_LWIP_SNTP_MAX_SERVERS; i++) { + const char* thisServer = ntpServerList[i]; + if (strncmp(thisServer, "\x00", 1) == 0) { + /* just in case we run out of NTP servers */ + break; + } + ESP_LOGI(TAG, "%s", thisServer); + sntp_setservername(i, thisServer); + } + #ifdef HAS_ESP_NETIF_SNTP + ret = esp_netif_sntp_init(&config); + #else + ESP_LOGW(TAG,"Warning: Consider upgrading ESP-IDF to take advantage " + "of updated SNTP libraries"); + #endif + if (ret == ESP_OK) { + ESP_LOGV(TAG, "Successfully called esp_netif_sntp_init"); + } + else { + ESP_LOGE(TAG, "ERROR: esp_netif_sntp_init return = %d", ret); + } + + sntp_init(); + switch (ret) { + case ESP_ERR_INVALID_STATE: + break; + default: + break; + } + ESP_LOGI(TAG, "sntp_init done."); + } + else { + ESP_LOGW(TAG, "No sntp time servers found."); + ret = -1; + } + + esp_show_current_datetime(); + ESP_LOGI(TAG, "time helper existing with result = %d", ret); + return ret; +} + +/* wait for NTP to actually set the time */ +int set_time_wait_for_ntp(void) +{ + int ret = 0; +#ifdef HAS_ESP_NETIF_SNTP + int ntp_retry = 0; + const int ntp_retry_count = NTP_RETRY_COUNT; + + ret = esp_netif_sntp_start(); + + ret = esp_netif_sntp_sync_wait(500 / portTICK_PERIOD_MS); +#else + ESP_LOGE(TAG, "HAS_ESP_NETIF_SNTP now defined"); +#endif /* HAS_ESP_NETIF_SNTP */ + esp_show_current_datetime(); + +#ifdef HAS_ESP_NETIF_SNTP + while (ret == ESP_ERR_TIMEOUT && (ntp_retry++ < ntp_retry_count)) { + ret = esp_netif_sntp_sync_wait(1000 / portTICK_PERIOD_MS); + ESP_LOGI(TAG, "Waiting for NTP to sync time... (%d/%d)", + ntp_retry, + ntp_retry_count); + esp_show_current_datetime(); + } +#endif /* HAS_ESP_NETIF_SNTP */ + +#ifdef TIME_ZONE + setenv("TZ", TIME_ZONE, 1); + tzset(); +#endif + + if (ret == ESP_OK) { + ESP_LOGI(TAG, "Successfuly set time via NTP servers."); + } + else { + ESP_LOGW(TAG, "Warning: Failed to set time with NTP: " + "result = 0x%0x: %s", + ret, esp_err_to_name(ret)); + } + return ret; +} diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/tx_rx_buffer.c b/Espressif/ESP32/ESP32-SSH-Server/main/tx_rx_buffer.c index e303710..13ce586 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/tx_rx_buffer.c +++ b/Espressif/ESP32/ESP32-SSH-Server/main/tx_rx_buffer.c @@ -1,474 +1,522 @@ -/* uart_hlper.c - * - * Copyright (C) 2014-2022 wolfSSL Inc. - * - * This file is part of wolfSSH. - * - * wolfSSH is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * wolfSSH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with wolfSSH. If not, see . - * - */ -#include "tx_rx_buffer.h" -#include "int_to_string.h" -#include "esp_log.h" - -#define SSH_WELCOME_MESSAGE "\r\nWelcome to wolfSSL ESP32 SSH UART Server!\n\r\n\r" -#define SSH_GPIO_MESSAGE "You are now connected to UART " -#define SSH_GPIO_MESSAGE_TX "Tx GPIO " -#define SSH_GPIO_MESSAGE_RX ", Rx GPIO " -#define SSH_READY_MESSAGE ".\r\n\r\nPress [Enter] to start. Ctrl-C to exit.\r\n\r\n" - - -static const char *TAG = "SSH Server lib"; - - -/* TODO define size and check when assigning */ -volatile static char _ExternalReceiveBuffer[ExternalReceiveBufferMaxLength]; -volatile static char _ExternalTransmitBuffer[ExternalTransmitBufferMaxLength]; -volatile static int _ExternalReceiveBufferSz = 0; -volatile static int _ExternalTransmitBufferSz = 0; - - -static SemaphoreHandle_t _xExternalReceiveBuffer_Semaphore = NULL; -static SemaphoreHandle_t _xExternalTransmitBuffer_Semaphore = NULL; - - -/* - * initialize the external buffer (typically a UART) Receive Semaphore. - */ -void InitReceiveSemaphore() -{ - if (_xExternalReceiveBuffer_Semaphore == NULL) { - ESP_LOGI(TAG, "InitReceiveSemaphore."); - - /* the case of recursive mutexes is interesting, so alert */ -#ifdef configUSE_RECURSIVE_MUTEXES - /* see semphr.h */ - ESP_LOGI(TAG,"InitSemaphore UART configUSE_RECURSIVE_MUTEXES enabled"); -#endif - - _xExternalReceiveBuffer_Semaphore = xSemaphoreCreateMutex(); - } -} - -/* - * initialize the external buffer (typically a UART) Transmit Semaphore. - */ -void InitTransmitSemaphore() -{ - if (_xExternalTransmitBuffer_Semaphore == NULL) { - - /* the case of recursive mutexes is interesting, so alert */ -#ifdef configUSE_RECURSIVE_MUTEXES - /* see semphr.h */ - ESP_LOGI(TAG,"InitSemaphore UART configUSE_RECURSIVE_MUTEXES enabled"); -#endif - _xExternalTransmitBuffer_Semaphore = xSemaphoreCreateMutex(); - } - -} - -/* - * return true if the Rx buffer is exactly 1 char long and contains charValue - */ -bool __attribute__((optimize("O0"))) ExternalReceiveBuffer_IsChar(char charValue) -{ - bool ret = false; /* assume not a match unless proven otherwise */ - char thisChar; /* typically looking at position 0, e.g. user typing */ - - InitReceiveSemaphore(); - if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, - (TickType_t) 10) == pdTRUE) { - - /* the entire thread-safety wrapper is for this code segment */ - { - if (_ExternalReceiveBufferSz == 1) - { - thisChar = _ExternalReceiveBuffer[0]; - ret = (thisChar == charValue); - } - } - xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! - * TODO how to handle this? */ - ret = false; - } - - return ret; -} - -volatile char* __attribute__((optimize("O0"))) ExternalReceiveBuffer() -{ - return _ExternalReceiveBuffer; -} - -volatile char* __attribute__((optimize("O0"))) ExternalTransmitBuffer() -{ - return _ExternalTransmitBuffer; -} - -/* RTOS-safe positional value of current receive buffer position. - * care should be take when using the number as more chars may have arrived! - */ -int ExternalReceiveBufferSz() -{ - int ret = 0; - - InitReceiveSemaphore(); - if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, - (TickType_t) 10) == pdTRUE) { - - /* the entire thread-safety wrapper is for this code statement */ - { - ret = _ExternalReceiveBufferSz; - } - xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! - * TODO how to handle this? */ - ret = 0; - } - -#ifdef SSH_SERVER_PROFILE - if (ret > MaxSeenRxSize) { - MaxSeenRxSize = ret; - } -#endif - return ret; -} - -/* RTOS-safe positional value of current transmit buffer position. - * care should be take when using the number as more chars may have been sent! - */ -int ExternalTransmitBufferSz() -{ - int ret; - - InitTransmitSemaphore(); - if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, - (TickType_t) 10) == pdTRUE) { - - /* the entire thread-safety wrapper is for this code statement */ - { - ret = _ExternalTransmitBufferSz; - } - - xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! - * TODO how to handle this? */ - ret = 0; - } - -#ifdef SSH_SERVER_PROFILE - if (ret > MaxSeenTxSize) { - MaxSeenTxSize = ret; - } -#endif - - return ret; -} - -/* - * returns zero if ExternalReceiveBufferSz successfully assigned - */ -int Set_ExternalReceiveBufferSz(int n) -{ - int ret = 0; /* we assume success unless proven otherwise */ - - InitReceiveSemaphore(); - if ((n >= 0) && (n < ExternalReceiveBufferMaxLength - 1)) { - /* only assign valid buffer sizes */ - if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, - (TickType_t) 10) == pdTRUE) { - - /* the entire thread-safety wrapper is for this code statement */ - { - _ExternalReceiveBufferSz = n; - - /* ensure the next char is zero, in case the stuffer of data - * does not do it */ - _ExternalReceiveBuffer[n + 1] = 0; - } - - xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! */ - ret = 1; - } - } - else { - /* the new length must be between zero and maximum length! */ - ret = 1; - } - return ret; -} - -/* - * returns zero if ExternalTransmitBufferSz successfully assigned - */ -int Set_ExternalTransmitBufferSz(int n) -{ - int ret = 0; /* we assume success unless proven otherwise */ - - InitTransmitSemaphore(); - - /* we look at ByteExternalTransmitBufferSz + 1 - * since we also append our own zero string termination - */ - if ( (n < 0) || (n > ExternalTransmitBufferMaxLength + 1) ) { - /* the new buffer size length must be between zero and maximum length! */ - ret = 1; - } - else { - /* only assign valid buffer sizes */ - if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, - (TickType_t) 10) == pdTRUE) { - - /* the entire thread-safety wrapper is for this code statement */ - { - _ExternalTransmitBufferSz = n; - - /* ensure the next char is zero, - * in case the stuffer of data does not do it */ - _ExternalTransmitBuffer[n + 1] = 0; - } - - xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! */ - ret = 1; - } - } /* valid value of n */ - return ret; -} - - -int Set_ExternalReceiveBuffer(byte *FromData, int sz) -{ - /* TODO this block has not yet been tested */ - int ret = 0; /* we assume success unless proven otherwise */ - - if ( (sz < 0) || (sz > ExternalReceiveBufferMaxLength) ) { - /* we'll only do a copy for valid sizes, otherwise return an error */ - ret = 1; - } - else { - InitReceiveSemaphore(); - if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, - (TickType_t) 10) == pdTRUE) { - - /* the entire thread-safety wrapper is for this code statement. - * in a multi-threaded environment, a different thread may be reading - * or writing from the data. we need to ensure it is static at the - * time of copy. - */ - { - memcpy((byte*)&_ExternalReceiveBuffer[_ExternalReceiveBufferSz], - FromData, - sz - ); - - _ExternalReceiveBufferSz = sz; - } - - xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! - * TODO how to handle this? */ - ret = 1; - } - } - - return ret; -} - -/* - * thread safe populate ToData with the contents of _ExternalTransmitBuffer - * returns the size of the data, negative values are errors. - **/ -int Get_ExternalTransmitBuffer(byte **ToData) -{ - int ret = 0; - InitTransmitSemaphore(); - - if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, - (TickType_t) 10) == pdTRUE) { - - int thisSize = _ExternalTransmitBufferSz; - if (thisSize == 0) { - /* nothing to do */ - ESP_LOGI(TAG,"Get_ExternalTransmitBuffer size is already zero"); - } - - else { - if (*ToData == NULL) { - /* we could not allocate memory, so fail */ - ret = -1; - ESP_LOGI(TAG,"Get_ExternalTransmitBuffer *ToData == NULL"); - } - else { - memcpy(*ToData, - (byte*)_ExternalTransmitBuffer, - thisSize - ); - - _ExternalTransmitBufferSz = 0; - ret = thisSize; - } - } - xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! TODO how to handle this? */ - ret = -1; - ESP_LOGE(TAG,"ERROR: Get_ExternalTransmitBuffer SemaphoreTake _xExternalTransmitBuffer_Semaphore failed."); - } - - return ret; -} - - - -int Set_ExternalTransmitBuffer(byte *FromData, int sz) -{ - int ret = 0; /* we assume success unless proven otherwise */ - - /* here we need to call the thread-safe ExternalTransmitBufferSz() */ - int thisNewSize = sz + ExternalTransmitBufferSz(); - - if ( (sz < 0) || (thisNewSize > ExternalTransmitBufferMaxLength) ) { - /* we'll only do a copy for valid sizes, otherwise return an error */ - ret = 1; - } - else { - InitTransmitSemaphore(); - if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, (TickType_t) 10) == pdTRUE) { - - /* trim any trailing zeros from existing data by adjusting our array pointer */ - int thisStart = _ExternalTransmitBufferSz; - while (thisStart > 0 - && - (_ExternalTransmitBuffer[thisStart - 1] == 0x0)) { - thisStart--; - } - - /* the actual new size may be smaller that above if we trimmed some zeros */ - thisNewSize = thisStart + sz; - - /* the entire thread-safety wrapper is for this code statement. - * in a multi-threaded environment, a different thread may be reading - * or writing from the data. we need to ensure it is static at the - * time of copy. - */ - { - memcpy((byte*)&_ExternalTransmitBuffer[thisStart], - FromData, - sz); - - _ExternalTransmitBufferSz = thisNewSize; - } - xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); - } - else { - /* we could not get the semaphore to update the value! TODO how to handle this? */ - ret = 1; - } - } - - return ret; -} - - -/* - * initialize external buffers and show welcome message. - * TxPin and RxPin are for display purposes only. - */ -int init_tx_rx_buffer(byte TxPin, byte RxPin) -{ - int ret = 0; - char numStr[2]; /* this will hold 2-digit GPIO numbers converted to a string */ - - /* these inits need to be called only once, - * but can be repeatedly called as needed */ - InitReceiveSemaphore(); - InitTransmitSemaphore(); - - /* - * init and stuff startup message in buffer - */ - Set_ExternalReceiveBufferSz(0); - Set_ExternalTransmitBufferSz(0); - - /* typically "Welcome to wolfSSL ESP32 SSH UART Server!" */ - Set_ExternalTransmitBuffer((byte*)SSH_WELCOME_MESSAGE, - sizeof(SSH_WELCOME_MESSAGE) - ); - - /* typically "You are now connected to UART " */ - Set_ExternalTransmitBuffer((byte*)SSH_GPIO_MESSAGE, - sizeof(SSH_GPIO_MESSAGE) - ); - - /* "Tx GPIO " */ - Set_ExternalTransmitBuffer((byte*)SSH_GPIO_MESSAGE_TX, - sizeof(SSH_GPIO_MESSAGE_TX) - ); - - /* the number of the Tx pin, converted to a string. - * - * note despite Clang IntelliSense detecting duplicate code, - * it is NOT a duplicate. This one compares TxPin, - * the next one compares RxPin */ - if (TxPin <= 0x40) { - int_to_dec(numStr, TxPin); - Set_ExternalTransmitBuffer((byte*)&numStr, sizeof(numStr)); - } - else { - ESP_LOGE(TAG,"ERROR: bad value for TxPin"); - ret = 1; - } - - /* ", Rx GPIO " */ - Set_ExternalTransmitBuffer((byte*)SSH_GPIO_MESSAGE_RX, - sizeof(SSH_GPIO_MESSAGE_RX) - ); - - /* the number of the Rx pin, converted to a string */ - if (RxPin <= 0x40) - { - int_to_dec(numStr, RxPin); - Set_ExternalTransmitBuffer((byte*)&numStr, sizeof(numStr)); - } - else { - ESP_LOGE(TAG,"ERROR: bad value for RxPin"); - ret = 1; - } - - /* typically "Press [Enter] to start. Ctrl-C to exit" */ - Set_ExternalTransmitBuffer((byte*)SSH_READY_MESSAGE, - sizeof(SSH_READY_MESSAGE) - ); - - return ret; -} - - - +/* uart_hlper.c + * + * Copyright (C) 2014-2022 wolfSSL Inc. + * + * This file is part of wolfSSH. + * + * wolfSSH is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * wolfSSH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with wolfSSH. If not, see . + * + */ +#include "tx_rx_buffer.h" +#include "int_to_string.h" + +#include +#include + +#define SSH_WELCOME_MESSAGE "\r\n" \ + "Welcome to wolfSSL ESP32 SSH UART Server!" \ + "\n\r\n\r" +#define SSH_GPIO_MESSAGE "You are now connected to UART " +#define SSH_GPIO_MESSAGE_TX "Tx GPIO " +#define SSH_GPIO_MESSAGE_RX ", Rx GPIO " +#define SSH_READY_MESSAGE ".\r\n\r\n" \ + "Press [Enter] to start. Ctrl-C to exit." \ + "\r\n\r\n" + + +static const char *TAG = "tx_rx_buf"; + + +/* TODO define size and check when assigning */ +/* Shared external, non ssh buffers. typically the UART */ +volatile static char _ExternalReceiveBuffer[EXT_RX_BUF_MAX_SZ]; +volatile static char _ExternalTransmitBuffer[EXT_TX_BUF_MAX_SZ]; +volatile static int _ExternalReceiveBufferSz = 0; +volatile static int _ExternalTransmitBufferSz = 0; + + +static SemaphoreHandle_t _xExternalReceiveBuffer_Semaphore = NULL; +static SemaphoreHandle_t _xExternalTransmitBuffer_Semaphore = NULL; + + +/* + * initialize the external buffer (typically a UART) Receive Semaphore. + */ +int InitReceiveSemaphore(void) +{ + int ret = ESP_OK; + if (_xExternalReceiveBuffer_Semaphore == NULL) { + ESP_LOGV(TAG, "Enter InitReceiveSemaphore."); + + /* the case of recursive mutexes is interesting, so alert */ + #ifdef configUSE_RECURSIVE_MUTEXES + /* see semphr.h */ + ESP_LOGI(TAG,"InitSemaphore UART Rx configUSE_RECURSIVE_MUTEXES enabled"); + #endif + + _xExternalReceiveBuffer_Semaphore = xSemaphoreCreateMutex(); + #ifdef configUSE_RECURSIVE_MUTEXES + /* see semphr.h */ + ESP_LOGV(TAG,"_xExternalReceiveBuffer_Semaphore complete"); + #ifdef INCLUDE_uxTaskGetStackHighWaterMark + ESP_LOGV(TAG, "1 rx Stack HWM: %d\n", + uxTaskGetStackHighWaterMark(NULL)); + #endif + #endif + } + else { + ESP_LOGV(TAG, "Rx _xExternalTransmitBuffer_Semaphore already initialized"); + } + return ret; +} + +/* + * initialize the external buffer (typically a UART) Transmit Semaphore. + */ +int InitTransmitSemaphore(void) +{ + int ret = ESP_OK; + if (_xExternalTransmitBuffer_Semaphore == NULL) { + + /* the case of recursive mutexes is interesting, so alert */ + #ifdef configUSE_RECURSIVE_MUTEXES + /* see semphr.h */ + ESP_LOGI(TAG, "InitSemaphore Tx configUSE_RECURSIVE_MUTEXES enabled"); + #endif + #ifdef INCLUDE_uxTaskGetStackHighWaterMark + ESP_LOGV(TAG, "Tx Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); + #endif + + _xExternalTransmitBuffer_Semaphore = xSemaphoreCreateMutex(); + +#ifdef configUSE_RECURSIVE_MUTEXES + /* see semphr.h */ + ESP_LOGV(TAG, "_xExternalReceiveBuffer_Semaphore complete"); + #endif + } + else { + ESP_LOGV(TAG, "Tx _xExternalTransmitBuffer_Semaphore" + "already initialized"); + } + return ret; +} + +/* + * return true if the Rx buffer is exactly 1 char long and contains charValue + */ +bool __attribute__((optimize("O0"))) +ExternalReceiveBuffer_IsChar(char charValue) +{ + bool ret = false; /* assume not a match unless proven otherwise */ + char thisChar; /* typically looking at position 0, e.g. user typing */ + + InitReceiveSemaphore(); + if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, + (TickType_t) 10) == pdTRUE) { + + /* the entire thread-safety wrapper is for this code segment */ + { + if (_ExternalReceiveBufferSz == 1) + { + thisChar = _ExternalReceiveBuffer[0]; + ret = (thisChar == charValue); + } + } + xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); + } + else { + /* we could not get the semaphore to update the value! + * TODO how to handle this? */ + ret = false; + } + + return ret; +} + +volatile char* __attribute__((optimize("O0"))) ExternalReceiveBuffer() +{ + return _ExternalReceiveBuffer; +} + +volatile char* __attribute__((optimize("O0"))) ExternalTransmitBuffer() +{ + return _ExternalTransmitBuffer; +} + +/* RTOS-safe positional value of current receive buffer position. + * care should be take when using the number as more chars may have arrived! + */ +int ExternalReceiveBufferSz(void) +{ + int ret = 0; + + InitReceiveSemaphore(); + if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, + (TickType_t) 10) == pdTRUE) { + + /* the entire thread-safety wrapper is for this code statement */ + { + ret = _ExternalReceiveBufferSz; + } + xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); + } + else { + /* we could not get the semaphore to update the value! + * TODO how to handle this? */ + ret = 0; + } + +#ifdef SSH_SERVER_PROFILE + if (ret > MaxSeenRxSize) { + MaxSeenRxSize = ret; + } +#endif + return ret; +} + +/* RTOS-safe positional value of current transmit buffer position. + * care should be take when using the number as more chars may have been sent! + */ +int ExternalTransmitBufferSz(void) +{ + int ret; + + InitTransmitSemaphore(); + if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, + (TickType_t) 10) == pdTRUE) { + + /* the entire thread-safety wrapper is for this code statement */ + { + ret = _ExternalTransmitBufferSz; + } + + xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); + } + else { + /* we could not get the semaphore to update the value! + * TODO how to handle this? */ + ret = 0; + } + +#ifdef SSH_SERVER_PROFILE + if (ret > MaxSeenTxSize) { + MaxSeenTxSize = ret; + } +#endif + + return ret; +} + +/* + * returns zero if ExternalReceiveBufferSz successfully assigned + */ +int Set_ExternalReceiveBufferSz(int n) +{ + int ret = 0; /* we assume success unless proven otherwise */ + + InitReceiveSemaphore(); + if ((n >= 0) && (n < EXT_RX_BUF_MAX_SZ - 1)) { + /* only assign valid buffer sizes */ + if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, + (TickType_t) 10) == pdTRUE) { + + /* the entire thread-safety wrapper is for this code statement */ + { + _ExternalReceiveBufferSz = n; + + /* ensure the next char is zero, in case the stuffer of data + * does not do it */ + _ExternalReceiveBuffer[n + 1] = 0; + } + + xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); + } + else { + /* we could not get the semaphore to update the value! */ + ret = 1; + } + } + else { + /* the new length must be between zero and maximum length! */ + ret = 1; + } + return ret; +} + +/* + * returns zero if ExternalTransmitBufferSz successfully assigned + */ +int Set_ExternalTransmitBufferSz(int n) +{ + int ret = 0; /* we assume success unless proven otherwise */ + + InitTransmitSemaphore(); + + /* we look at ByteExternalTransmitBufferSz + 1 + * since we also append our own zero string termination + */ + if ( (n < 0) || (n > EXT_TX_BUF_MAX_SZ + 1) ) { + /* the new buffer size length must be between zero and maximum length! */ + ret = 1; + } + else { + /* only assign valid buffer sizes */ + if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, + (TickType_t) 10) == pdTRUE) { + + /* the entire thread-safety wrapper is for this code statement */ + { + _ExternalTransmitBufferSz = n; + + /* ensure the next char is zero, + * in case the stuffer of data does not do it */ + _ExternalTransmitBuffer[n + 1] = 0; + } + + xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); + } + else { + /* we could not get the semaphore to update the value! */ + ret = 1; + } + } /* valid value of n */ + return ret; +} + +/* Set the length of the external (typiclly UART) Rx buffer */ +int Set_ExternalReceiveBuffer(byte *FromData, int sz) +{ + /* TODO this block has not yet been fully tested */ + int ret = ESP_OK; /* we assume success unless proven otherwise */ + + if ( (sz < 0) || (sz > EXT_RX_BUF_MAX_SZ) ) { + /* we'll only do a copy for valid sizes, otherwise return an error */ + ret = 1; + } + else { + InitReceiveSemaphore(); + if (xSemaphoreTake(_xExternalReceiveBuffer_Semaphore, + (TickType_t) 10) == pdTRUE) { + + /* The entire thread-safety wrapper is for this code statement. + * in a multi-threaded environment, a different thread may be + * reading or writing from the data. We need to ensure it is + * static at the time of copy. + */ + { + memcpy( + (byte*)&_ExternalReceiveBuffer[_ExternalReceiveBufferSz], + FromData, + sz); + + _ExternalReceiveBufferSz = sz; + } /* thread safe */ + + xSemaphoreGive(_xExternalReceiveBuffer_Semaphore); + } + else { + /* we could not get the semaphore to update the value! + * TODO how to handle this? Will this ever occur? + * If so, adjust wait time, above. */ + ESP_LOGW(TAG, "Warning: Set_ExternalReceiveBuffer failed to " + "take semaphore. Consisder wait time adjustment." ); + ret = 1; + } + } + + return ret; +} + +/* + * Thread safe populate ToData with the contents of _ExternalTransmitBuffer + * returns the size of the data, negative values are errors. + */ +int Get_ExternalTransmitBuffer(byte **ToData) +{ + int ret = 0; + InitTransmitSemaphore(); + + if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, + (TickType_t) 10) == pdTRUE) { + + int thisSize = _ExternalTransmitBufferSz; + if (thisSize == 0) { + /* nothing to do */ + ESP_LOGI(TAG,"Get_ExternalTransmitBuffer size is already zero"); + } + + else { + if (*ToData == NULL) { + /* we could not allocate memory, so fail */ + ret = -1; + ESP_LOGI(TAG,"Get_ExternalTransmitBuffer *ToData == NULL"); + } + else { + memcpy(*ToData, + (byte*)_ExternalTransmitBuffer, + thisSize + ); + + _ExternalTransmitBufferSz = 0; + ret = thisSize; + } + } + xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); + } + else { + /* We could not get the semaphore to update the value! + * TODO how to handle this? Wait time adjust? */ + ret = -1; + ESP_LOGE(TAG,"ERROR: Get_ExternalTransmitBuffer SemaphoreTake " + "_xExternalTransmitBuffer_Semaphore failed."); + } + + return ret; +} + + +/* + * Thread safe populate FromData with the contents of _ExternalTransmitBuffer + * returns the size of the data, negative values are errors. + */ +int Set_ExternalTransmitBuffer(byte *FromData, int sz) +{ + int ret = 0; + + /* here we need to call the thread-safe ExternalTransmitBufferSz() */ + int thisNewSize = sz + ExternalTransmitBufferSz(); + + if ( (sz < 0) || (thisNewSize > EXT_TX_BUF_MAX_SZ) ) { + /* we'll only do a copy for valid sizes, otherwise return an error */ + ret = -1; + } + else { + InitTransmitSemaphore(); + if (xSemaphoreTake(_xExternalTransmitBuffer_Semaphore, (TickType_t) 10) == pdTRUE) { + + /* trim any trailing zeros from existing data by adjusting our array pointer */ + int thisStart = _ExternalTransmitBufferSz; + while (thisStart > 0 + && + (_ExternalTransmitBuffer[thisStart - 1] == 0x0)) { + thisStart--; + } + + /* the actual new size may be smaller that above if we trimmed some zeros */ + thisNewSize = thisStart + sz; + + /* the entire thread-safety wrapper is for this code statement. + * in a multi-threaded environment, a different thread may be reading + * or writing from the data. we need to ensure it is static at the + * time of copy. + */ + { + memcpy((byte*)&_ExternalTransmitBuffer[thisStart], + FromData, + sz); + + _ExternalTransmitBufferSz = thisNewSize; + ret = thisNewSize; + } + xSemaphoreGive(_xExternalTransmitBuffer_Semaphore); + } + else { + /* we could not get the semaphore to update the value! TODO how to handle this? */ + ret = -1; + } + } + + return ret; +} + + +/* + * initialize external buffers and show welcome message. + * TxPin and RxPin are for display purposes only. + */ +int init_tx_rx_buffer(byte TxPin, byte RxPin) +{ + int ret = 0; + + char numStr[3] = { ' ', ' ', ' ' }; /* printable 2-digit GPIO numbers */ + + /* these inits need to be called only once, + * but can be repeatedly called as needed */ + InitReceiveSemaphore(); + InitTransmitSemaphore(); + + /* + * init and stuff startup message in buffer + */ + Set_ExternalReceiveBufferSz(0); + Set_ExternalTransmitBufferSz(0); + + /* typically "Welcome to wolfSSL ESP32 SSH UART Server!" */ + Set_ExternalTransmitBuffer((byte*)SSH_WELCOME_MESSAGE, + sizeof(SSH_WELCOME_MESSAGE) + ); + + /* typically "You are now connected to UART " */ + Set_ExternalTransmitBuffer((byte*)SSH_GPIO_MESSAGE, + sizeof(SSH_GPIO_MESSAGE) + ); + + /* "Tx GPIO " */ + Set_ExternalTransmitBuffer((byte*)SSH_GPIO_MESSAGE_TX, + sizeof(SSH_GPIO_MESSAGE_TX) + ); + + /* the number of the Tx pin, converted to a string. + * + * note despite Clang IntelliSense detecting duplicate code, + * it is NOT a duplicate. This one compares TxPin, + * the next one compares RxPin */ + if (TxPin <= 0x40) { + int_to_dec((char*)&numStr, TxPin); + numStr[2] = 0; + Set_ExternalTransmitBuffer((byte*)&numStr, sizeof(numStr)); + } + else { + ESP_LOGE(TAG,"ERROR: bad value for TxPin"); + ret = 1; + } + + /* ", Rx GPIO " */ + Set_ExternalTransmitBuffer((byte*)SSH_GPIO_MESSAGE_RX, + sizeof(SSH_GPIO_MESSAGE_RX) + ); + + /* the number of the Rx pin, converted to a string */ + if (RxPin <= 0x40) + { + int_to_dec((char*)&numStr, RxPin); + numStr[2] = 0; + Set_ExternalTransmitBuffer((byte*)&numStr, sizeof(numStr)); + } + else { + ESP_LOGE(TAG,"ERROR: bad value for RxPin"); + ret = 1; + } +#ifdef INCLUDE_uxTaskGetStackHighWaterMark + ESP_LOGI(TAG, "8 Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); +#endif + /* typically "Press [Enter] to start. Ctrl-C to exit" */ + Set_ExternalTransmitBuffer((byte*)SSH_READY_MESSAGE, + sizeof(SSH_READY_MESSAGE) + ); +#ifdef INCLUDE_uxTaskGetStackHighWaterMark + ESP_LOGI(TAG, "9 Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); +#endif + return ret; +} diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/uart_helper.c b/Espressif/ESP32/ESP32-SSH-Server/main/uart_helper.c index b2faedf..9969439 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/main/uart_helper.c +++ b/Espressif/ESP32/ESP32-SSH-Server/main/uart_helper.c @@ -1,185 +1,230 @@ -/* uart_helper.c - * - * Copyright (C) 2014-2022 wolfSSL Inc. - * - * This file is part of wolfSSH. - * - * wolfSSH is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * wolfSSH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with wolfSSH. If not, see . - * - */ -#include - -#include "uart_helper.h" -#include "tx_rx_buffer.h" - -#include "driver/uart.h" -#include "esp_log.h" -#include "string.h" -#include "ssh_server.h" - - -/* portTICK_PERIOD_MS is ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) - * configTICK_RATE_HZ is CONFIG_FREERTOS_HZ - * CONFIG_FREERTOS_HZ is 100 - **/ -#define UART_TICKS_TO_WAIT (20 / portTICK_RATE_MS) - -/* - * see examples: https://github.com/espressif/esp-idf/blob/master/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c - */ - - -/* we are going to use a real backspace instead of 0x7f observed */ -const char backspace[1] = { (char)0x08 }; -static SemaphoreHandle_t xUART_Semaphore = NULL; -static char* TAG = "uart_helper"; - -/* - * startupMessage is the message before actually connecting to UART in server task thread. - */ -static char startupMessage[] = - "\n" - "Welcome to ESP32 SSH Server!" - "\n\n" - "Press [Enter]\n\n"; - -/* - * welcome message - */ -void uart_send_welcome() { - static const char *TX_TASK_TAG = "TX_TASK_WELCOME"; - sendData(TX_TASK_TAG, startupMessage); -} - - -/* - * send character string at char* data to UART - */ -int sendData(const char* logName, const char* data) { - const int len = strlen(data); - - /* note we are always using UART_NUM_1 but the GPIO pins may vary */ - const int txBytes = uart_write_bytes(UART_NUM_1, data, len); - - ESP_LOGI(logName, "Wrote %d bytes", txBytes); - - return txBytes; -} - -/* - * if the external Receive Buffer has data (e.g. from SSH client) - * then send that data to the UART (ExternalReceiveBufferSz bytes) - */ -void uart_tx_task(void *arg) { - /* - * when we receive chars from ssh, we'll send them out the UART - */ - static const char *TX_TASK_TAG = "TX_TASK"; - esp_log_level_set(TX_TASK_TAG, ESP_LOG_INFO); - - /* this RTOS task will never exit */ - while (1) { - if (ExternalReceiveBufferSz() > 0) - { - ESP_LOGI(TAG,"UART Send Data"); - - /* we don't want to send 0x7f as a backspace, we want a real backspace - * TODO: optional character mapping */ - if (ExternalReceiveBuffer_IsChar(0x7f)) { - sendData(TX_TASK_TAG, backspace); - } - else - { - sendData(TX_TASK_TAG, (char*)ExternalReceiveBuffer()); - } - - /* once we sent data, reset the pointer to zero to indicate empty queue */ - Set_ExternalReceiveBufferSz(0); - } - - /* yield. let's not be greedy */ - taskYIELD(); - } -} - -/* - * reading and writing memory from different threads requires coordination. - * we'll use exclusive mutex semaphores for this. - */ -void InitSemaphore() -{ - if (xUART_Semaphore == NULL) { - xUART_Semaphore = xSemaphoreCreateMutex(); - } - -#ifdef configUSE_RECURSIVE_MUTEXES - /* this may be interesting; see semphr.h */ - ESP_LOGI(TAG,"InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled"); -#endif -} - -/* - * for any data received FROM the UART, put it in the External Transmit - * buffer to SEND (typically out to the SSH client) - */ -void uart_rx_task(void *arg) { - InitSemaphore(); - - /* TODO do we really want malloc? probably not. - * but in this thread, it only gets allocated once. - **/ - uint8_t* data = (uint8_t*) malloc(ExternalReceiveBufferMaxLength + 1); - - /* - * when we receive chars from UART, we'll send them out SSH - */ - static const char *RX_TASK_TAG = "RX_TASK"; - esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO); - - - /* TODO this should be interrupt driven, rather than polling */ - while (1) { - /* note some examples have UART_TICKS_TO_WAIT = 1000, - * which results in very sluggish response. - * a known good value is (20 / portTICK_RATE_MS) */ - const int rxBytes = uart_read_bytes(UART_NUM_1, - data, - ExternalReceiveBufferMaxLength, - UART_TICKS_TO_WAIT); - - if (rxBytes > 0) { - ESP_LOGI(TAG,"UART Rx Data!"); - data[rxBytes] = 0; - - ESP_LOGI(RX_TASK_TAG, "Read %d bytes:", rxBytes); - - /* this can be helpful during debug, but causes a bit of - * sluggish performance as it is not very RTOS friendly: - - ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, data); - ESP_LOG_BUFFER_HEXDUMP(RX_TASK_TAG, data, rxBytes, ESP_LOG_INFO); - - * - */ - - Set_ExternalTransmitBuffer(data, rxBytes); - } /* (rxBytes > 0) */ - - /* yield. let's not be greedy */ - taskYIELD(); - } - - /* we never actually get here */ - free(data); +/* uart_helper.c + * + * Copyright (C) 2014-2022 wolfSSL Inc. + * + * This file is part of wolfSSH. + * + * wolfSSH is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * wolfSSH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with wolfSSH. If not, see . + * + */ + +/* This is a specialized UART helper for the SSH to UART example*/ +/* See "sdkconfig-debug.h for ESP8266 " */ + +#include "sdkconfig.h" + +#if defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO */ +#endif + +#include "uart_helper.h" +#include "tx_rx_buffer.h" +#include "ssh_server_config.h" +#include "ssh_server.h" + +#include +#include +#include +#include + +/* portTICK_PERIOD_MS is ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) + * configTICK_RATE_HZ is CONFIG_FREERTOS_HZ + * CONFIG_FREERTOS_HZ is 100 + **/ +#define UART_TICKS_TO_WAIT (20 / portTICK_PERIOD_MS) + +/* + * see examples: https://github.com/espressif/esp-idf/blob/master/examples/peripherals/uart/uart_echo/main/uart_echo_example_main.c + */ + + +/* we are going to use a real backspace instead of 0x7f observed */ +const char backspace[1] = { (char)0x08 }; +static SemaphoreHandle_t xUART_Semaphore = NULL; +static const char* TAG = "uart_helper"; + +/* + * startupMessage is the message before actually connecting to UART in server task thread. + */ +static char startupMessage[] = + "\n" + "Welcome to ESP32 SSH Server!" + "\n\n" + "Press [Enter]\n\n"; + +void init_UART(void) +{ +#if defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO */ + ESP_LOGE(TAG, "Error: init_UART not implemented for ESP8266."); +#else + /* not ESP8266 */ + ESP_LOGI(TAG, "Begin init_UART."); + int intr_alloc_flags = 0; + const uart_config_t uart_config = { + .baud_rate = BAUD_RATE, + .data_bits = UART_DATA_8_BITS, + .parity = UART_PARITY_DISABLE, + .stop_bits = UART_STOP_BITS_1, + .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, + #if !defined(CONFIG_IDF_TARGET_ESP8266) + .source_clk = UART_SCLK_DEFAULT, + #endif + }; + + #if CONFIG_UART_ISR_IN_IRAM + intr_alloc_flags = ESP_INTR_FLAG_IRAM; + #endif + /* We won't use a buffer for sending UART_NUM_1 data. */ + ESP_ERROR_CHECK(uart_driver_install(UART_NUM_1, 2048, 0, 0, NULL, intr_alloc_flags)); + ESP_ERROR_CHECK(uart_param_config(UART_NUM_1, &uart_config)); + ESP_ERROR_CHECK(uart_set_pin(UART_NUM_1, TXD_PIN, RXD_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); +#endif /* CONFIG_IDF_TARGET_ESP8266 */ + ESP_LOGI(TAG, "End init_UART."); +} + +/* + * welcome message + */ +void uart_send_welcome() { + static const char *TX_TASK_TAG = "TX_TASK_WELCOME"; + sendData(TX_TASK_TAG, startupMessage); +} + + +/* + * send character string at char* data to UART + */ +int sendData(const char* logName, const char* data) { + const int len = strlen(data); + + /* note we are always using UART_NUM_1 but the GPIO pins may vary */ + const int txBytes = uart_write_bytes(UART_NUM_1, data, len); + + ESP_LOGI(logName, "Wrote %d bytes", txBytes); + + return txBytes; +} + +/* + * if the external Receive Buffer has data (e.g. from SSH client) + * then send that data to the UART (ExternalReceiveBufferSz bytes) + */ +void uart_tx_task(void *arg) { + /* + * when we receive chars from ssh, we'll send them out the UART + */ + static const char *TX_TASK_TAG = "TX_TASK"; + esp_log_level_set(TX_TASK_TAG, ESP_LOG_INFO); + + /* this RTOS task will never exit */ + while (1) { + vTaskDelay(10); + + if (ExternalReceiveBufferSz() > 0) + { + ESP_LOGI(TAG,"UART Send Data"); + + /* we don't want to send 0x7f as a backspace, we want a real backspace + * TODO: optional character mapping */ + if (ExternalReceiveBuffer_IsChar(0x7f)) { + sendData(TX_TASK_TAG, backspace); + } + else + { + sendData(TX_TASK_TAG, (char*)ExternalReceiveBuffer()); + } + + /* once we sent data, reset the pointer to zero to indicate empty queue */ + Set_ExternalReceiveBufferSz(0); + } + + /* yield. let's not be greedy */ + taskYIELD(); + } +} + +/* + * reading and writing memory from different threads requires coordination. + * we'll use exclusive mutex semaphores for this. + */ +void InitSemaphore() +{ + if (xUART_Semaphore == NULL) { + xUART_Semaphore = xSemaphoreCreateMutex(); + } + +#ifdef configUSE_RECURSIVE_MUTEXES + /* this may be interesting; see semphr.h */ + ESP_LOGI(TAG,"InitSemaphore found UART configUSE_RECURSIVE_MUTEXES enabled"); +#endif +} + +/* + * for any data received FROM the UART, put it in the External Transmit + * buffer to SEND (typically out to the SSH client) + */ +void uart_rx_task(void *arg) { + vTaskDelay(1000000000); /* TODO */ + + InitSemaphore(); + + /* TODO do we really want malloc? probably not. + * but in this thread, it only gets allocated once. + **/ + uint8_t* data = (uint8_t*) malloc(EXT_RX_BUF_MAX_SZ + 1); + + /* + * when we receive chars from UART, we'll send them out SSH + */ + static const char *RX_TASK_TAG = "RX_TASK"; + esp_log_level_set(RX_TASK_TAG, ESP_LOG_INFO); + + + /* TODO this should be interrupt driven, rather than polling */ + while (1) { + /* note some examples have UART_TICKS_TO_WAIT = 1000, + * which results in very sluggish response. + * a known good value is (20 / portTICK_RATE_MS) */ + vTaskDelay(10); + const int rxBytes = uart_read_bytes(UART_NUM_1, + data, + EXT_RX_BUF_MAX_SZ, + UART_TICKS_TO_WAIT); + + if (rxBytes > 0) { + ESP_LOGI(TAG,"UART Rx Data!"); + data[rxBytes] = 0; + + ESP_LOGI(RX_TASK_TAG, "Read %d bytes:", rxBytes); + + /* this can be helpful during debug, but causes a bit of + * sluggish performance as it is not very RTOS friendly: + + ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, data); + ESP_LOG_BUFFER_HEXDUMP(RX_TASK_TAG, data, rxBytes, ESP_LOG_INFO); + + * + */ + + Set_ExternalTransmitBuffer(data, rxBytes); + } /* (rxBytes > 0) */ + + /* yield. let's not be greedy */ + taskYIELD(); + } + + /* we never actually get here */ + free(data); } \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/wifi.c b/Espressif/ESP32/ESP32-SSH-Server/main/wifi.c deleted file mode 100644 index c23f8d6..0000000 --- a/Espressif/ESP32/ESP32-SSH-Server/main/wifi.c +++ /dev/null @@ -1,304 +0,0 @@ -/* wifi.c - * - * Copyright (C) 2014-2022 wolfSSL Inc. - * - * This file is part of wolfSSH. - * - * wolfSSH is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * wolfSSH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with wolfSSH. If not, see . - */ -#include "wifi.h" - -/* The examples use WiFi configuration that you can set via project configuration menu - - If you'd rather not, just change the below entries to strings with - the config you want - ie #define EXAMPLE_WIFI_SSID "mywifissid" -*/ - -#define EXAMPLE_ESP_MAXIMUM_RETRY 10 - -#include "my_config.h" - - - - -#ifndef CONFIG_ESP_WIFI_CHANNEL - #define CONFIG_ESP_WIFI_CHANNEL 1 -#endif - -#ifndef CONFIG_ESP_MAX_STA_CONN - #define CONFIG_ESP_MAX_STA_CONN 2 -#endif - -#define EXAMPLE_ESP_WIFI_CHANNEL CONFIG_ESP_WIFI_CHANNEL -#define EXAMPLE_MAX_STA_CONN CONFIG_ESP_MAX_STA_CONN - - -/* FreeRTOS event group to signal when we are connected*/ -static EventGroupHandle_t s_wifi_event_group; - -/* The event group allows multiple bits for each event, - * but we only care about two events: - * - * - we are connected to the AP with an IP - * - we failed to connect after the maximum amount of retries */ -#define WIFI_CONNECTED_BIT BIT0 -#define WIFI_FAIL_BIT BIT1 - -static const char *TAG = "wifi station"; - -static int s_retry_num = 0; - -/* we'll change WiFiEthernetReady in event handler - * - * see also wifi_ready() - */ -static volatile bool WiFiEthernetReady = 0; - -/* - * WiFi event_handler() Public Domain Sample Code Credit Espressif - * - * See https://github.com/espressif/esp-idf/blob/master/examples/wifi/getting_started/station/main/station_example_main.c - * - */ -void event_handler(void* arg, - esp_event_base_t event_base, - int32_t event_id, - void* event_data) -{ - - if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { - WiFiEthernetReady = 0; - esp_wifi_connect(); - } - - else if (event_base == WIFI_EVENT - && - event_id == WIFI_EVENT_STA_DISCONNECTED) { - - if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) { - esp_wifi_connect(); - s_retry_num++; - ESP_LOGI(TAG, "retry to connect to the AP"); - } - - else { - xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); - } - - ESP_LOGI(TAG, "connect to the AP fail"); - WiFiEthernetReady = 0; - } - - else if (event_base == IP_EVENT - && - event_id == IP_EVENT_STA_GOT_IP) { - - ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; - ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); - s_retry_num = 0; - xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); - WiFiEthernetReady = 1; - } -} - -/* - * WiFi wifi_init_sta() Public Domain Sample Code Credit Espressif - * - * See https://github.com/espressif/esp-idf/blob/master/examples/wifi/getting_started/station/main/station_example_main.c - * - */ -void wifi_init_sta(void) -{ - EventBits_t bits; - esp_event_handler_instance_t instance_any_id; - esp_event_handler_instance_t instance_got_ip; - - wifi_config_t wifi_config = { - .sta = { - .ssid = EXAMPLE_ESP_WIFI_SSID, - .password = EXAMPLE_ESP_WIFI_PASS, - /* Setting a password implies station will connect to all security modes including WEP/WPA. - * However these modes are deprecated and not advisable to be used. Incase your Access point - * doesn't support WPA2, these mode can be enabled by commenting below line */ - .threshold.authmode = WIFI_AUTH_WPA2_PSK, - - .pmf_cfg = { - .capable = true, - .required = false - }, - }, - }; - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - - s_wifi_event_group = xEventGroupCreate(); - - ESP_ERROR_CHECK(esp_netif_init()); - - ESP_ERROR_CHECK(esp_event_loop_create_default()); - esp_netif_create_default_wifi_sta(); - - ESP_ERROR_CHECK(esp_wifi_init(&cfg)); - - ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, - ESP_EVENT_ANY_ID, - &event_handler, - NULL, - &instance_any_id)); - - ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, - IP_EVENT_STA_GOT_IP, - &event_handler, - NULL, - &instance_got_ip)); - - - ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); - ESP_ERROR_CHECK(esp_wifi_start()); - - ESP_LOGI(TAG, "wifi_init_sta finished."); - - /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum - * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */ - bits = xEventGroupWaitBits(s_wifi_event_group, - WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, - pdFALSE, - pdFALSE, - portMAX_DELAY); - - /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually - * happened. */ - if (bits & WIFI_CONNECTED_BIT) { - ESP_LOGI(TAG, - "connected to ap SSID:%s password:%s", - EXAMPLE_ESP_WIFI_SSID, - EXAMPLE_ESP_WIFI_PASS); - } - else if (bits & WIFI_FAIL_BIT) { - ESP_LOGI(TAG, - "Failed to connect to SSID:%s, password:%s", - EXAMPLE_ESP_WIFI_SSID, - EXAMPLE_ESP_WIFI_PASS); - } - else { - ESP_LOGE(TAG, "UNEXPECTED EVENT"); - } - - /* The event will not be processed after unregister */ - ESP_ERROR_CHECK(esp_event_handler_instance_unregister( - IP_EVENT, - IP_EVENT_STA_GOT_IP, - instance_got_ip) - ); - - ESP_ERROR_CHECK(esp_event_handler_instance_unregister( - WIFI_EVENT, - ESP_EVENT_ANY_ID, - instance_any_id) - ); - - vEventGroupDelete(s_wifi_event_group); -} - - - -/* - * WiFi wifi_ap_event_handler() Public Domain Sample Code Credit Espressif - * - * See https://github.com/espressif/esp-idf/blob/master/examples/wifi/getting_started/softAP/main/softap_example_main.c - * - */ -static void wifi_ap_event_handler(void* arg, - esp_event_base_t event_base, - int32_t event_id, - void* event_data) -{ - if (event_id == WIFI_EVENT_AP_STACONNECTED) { - wifi_event_ap_staconnected_t* event = - (wifi_event_ap_staconnected_t*) event_data; - - ESP_LOGI(TAG, - "station "MACSTR" join, AID=%d", - MAC2STR(event->mac), - event->aid); - } - else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) { - wifi_event_ap_stadisconnected_t* event = - (wifi_event_ap_stadisconnected_t*) event_data; - - ESP_LOGI(TAG, - "station "MACSTR" leave, AID=%d", - MAC2STR(event->mac), - event->aid); - } - - /* when acting as AP, we're always ready, as we're not awaiting connection or IP addy */ - WiFiEthernetReady = 1; -} - - -/* - * WiFi wifi_init_softap() Public Domain Sample Code Credit Espressif - * - * See https://github.com/espressif/esp-idf/blob/master/examples/wifi/getting_started/softAP/main/softap_example_main.c - * - */ -void wifi_init_softap(void) -{ - wifi_config_t wifi_config = { - .ap = { - .ssid = EXAMPLE_ESP_WIFI_AP_SSID, - .ssid_len = strlen(EXAMPLE_ESP_WIFI_AP_SSID), - .channel = EXAMPLE_ESP_WIFI_CHANNEL, - .password = EXAMPLE_ESP_WIFI_AP_PASS, - .max_connection = EXAMPLE_MAX_STA_CONN, - .authmode = WIFI_AUTH_WPA2_PSK - }, - }; - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - - ESP_ERROR_CHECK(esp_netif_init()); - ESP_ERROR_CHECK(esp_event_loop_create_default()); - esp_netif_create_default_wifi_ap(); - - ESP_ERROR_CHECK(esp_wifi_init(&cfg)); - - ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, - ESP_EVENT_ANY_ID, - &wifi_ap_event_handler, - NULL, - NULL)); - - if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) { - wifi_config.ap.authmode = WIFI_AUTH_OPEN; - } - - ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config)); - ESP_ERROR_CHECK(esp_wifi_start()); - - ESP_LOGI(TAG, - "wifi_init_softap finished. SSID:%s password:%s channel:%d", - EXAMPLE_ESP_WIFI_AP_SSID, - EXAMPLE_ESP_WIFI_AP_PASS, - EXAMPLE_ESP_WIFI_CHANNEL); -} - -/* - * return true when above events determined that WiFi is actually ready. - */ -bool wifi_ready() -{ - return WiFiEthernetReady; -} \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/wifi.h b/Espressif/ESP32/ESP32-SSH-Server/main/wifi.h deleted file mode 100644 index fc4c659..0000000 --- a/Espressif/ESP32/ESP32-SSH-Server/main/wifi.h +++ /dev/null @@ -1,45 +0,0 @@ -/* wifi.h - * - * Copyright (C) 2014-2022 wolfSSL Inc. - * - * This file is part of wolfSSH. - * - * wolfSSH is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * wolfSSH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with wolfSSH. If not, see . - */ -#pragma once - -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/event_groups.h" -#include "esp_system.h" -#include "esp_wifi.h" -#include "esp_event.h" -#include "esp_log.h" -#include "nvs_flash.h" - -#include "lwip/err.h" -#include "lwip/sys.h" - - -void event_handler(void* arg, - esp_event_base_t event_base, - int32_t event_id, - void* event_data); - -void wifi_init_softap(void); - -void wifi_init_sta(void); - -bool wifi_ready(); diff --git a/Espressif/ESP32/ESP32-SSH-Server/main/wifi_connect.c b/Espressif/ESP32/ESP32-SSH-Server/main/wifi_connect.c new file mode 100644 index 0000000..7f7e159 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/main/wifi_connect.c @@ -0,0 +1,408 @@ +/* wifi_connect.c + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ +#include "wifi_connect.h" +#include "my_config.h" + +#ifndef CONFIG_ESP_WIFI_CHANNEL + #define CONFIG_ESP_WIFI_CHANNEL 1 +#endif + +#ifndef CONFIG_ESP_MAX_STA_CONN + #define CONFIG_ESP_MAX_STA_CONN 2 +#endif + +#define EXAMPLE_ESP_WIFI_CHANNEL CONFIG_ESP_WIFI_CHANNEL +#define EXAMPLE_MAX_STA_CONN CONFIG_ESP_MAX_STA_CONN + +#include +#include +#include +#include +#include + +/* wolfSSL */ +#include +#include +#include +#ifndef WOLFSSL_ESPIDF + #warning "Problem with wolfSSL user_settings." + #warning "Check components/wolfssl/include" +#endif + +#if ESP_IDF_VERSION_MAJOR >= 5 +#elif ESP_IDF_VERSION_MAJOR >= 4 + #include "protocol_examples_common.h" +#elif defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO */ +#else + const static int CONNECTED_BIT = BIT0; + static EventGroupHandle_t wifi_event_group; +#endif + +#if defined(ESP_IDF_VERSION_MAJOR) && defined(ESP_IDF_VERSION_MINOR) + #if ESP_IDF_VERSION_MAJOR >= 4 + /* likely using examples, see wifi_connect.h */ + #elif defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO */ + #else + /* TODO - still supporting pre V4 ? */ + const static int CONNECTED_BIT = BIT0; + static EventGroupHandle_t wifi_event_group; + #endif + #if (ESP_IDF_VERSION_MAJOR == 5) + #define HAS_WPA3_FEATURES + #else + #undef HAS_WPA3_FEATURES + #endif +#else + /* TODO Consider pre IDF v5? */ +#endif + +/* breadcrumb prefix for logging */ +static const char *TAG = "wifi_connect"; + +/* we'll change WiFiEthernetReady in event handler + * + * see also wifi_ready() + */ +static volatile bool WiFiEthernetReady = 0; + +#if ESP_IDF_VERSION_MAJOR < 4 + #if defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO */ + #else + /* event handler for wifi events */ + static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) + { + switch (event->event_id) + { + case SYSTEM_EVENT_STA_START: + esp_wifi_connect(); + break; + case SYSTEM_EVENT_STA_GOT_IP: + #if ESP_IDF_VERSION_MAJOR >= 4 + ESP_LOGI(TAG, "got ip:" IPSTR "\n", + IP2STR(&event->event_info.got_ip.ip_info.ip)); + #else + ESP_LOGI(TAG, "got ip:%s", + ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip)); + #endif + /* see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos_idf.html */ + xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); + break; + case SYSTEM_EVENT_STA_DISCONNECTED: + esp_wifi_connect(); + xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); + break; + default: + break; + } + return ESP_OK; + } + /* not ESP8266 */ + #endif +#else + +#ifdef CONFIG_ESP_MAXIMUM_RETRY + #define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY +#else + #define CONFIG_ESP_MAXIMUM_RETRY 5 +#endif + +#if CONFIG_ESP_WIFI_AUTH_OPEN +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN +#elif CONFIG_ESP_WIFI_AUTH_WEP +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP +#elif CONFIG_ESP_WIFI_AUTH_WPA_PSK +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK +#elif CONFIG_ESP_WIFI_AUTH_WPA2_PSK +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK +#elif CONFIG_ESP_WIFI_AUTH_WPA_WPA2_PSK +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK +#elif CONFIG_ESP_WIFI_AUTH_WPA3_PSK +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK +#elif CONFIG_ESP_WIFI_AUTH_WPA2_WPA3_PSK +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK +#elif CONFIG_ESP_WIFI_AUTH_WAPI_PSK +#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK +#endif + +#ifndef ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD + #define CONFIG_ESP_WIFI_AUTH_WPA2_PSK 1 + #define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD CONFIG_ESP_WIFI_AUTH_WPA2_PSK +#endif + +/* FreeRTOS event group to signal when we are connected*/ +static EventGroupHandle_t s_wifi_event_group; + +/* The event group allows multiple bits for each event, but we only care about two events: + * - we are connected to the AP with an IP + * - we failed to connect after the maximum amount of retries */ +#define WIFI_CONNECTED_BIT BIT0 +#define WIFI_FAIL_BIT BIT1 + + +static int s_retry_num = 0; +ip_event_got_ip_t* event; + +static void event_handler(void* arg, + esp_event_base_t event_base, + int32_t event_id, + void* event_data) +{ + if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { + WiFiEthernetReady = 0; + esp_wifi_connect(); + } + else if (event_base == WIFI_EVENT && + event_id == WIFI_EVENT_STA_DISCONNECTED) { + if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) { + esp_wifi_connect(); + s_retry_num++; + ESP_LOGI(TAG, "retry to connect to the AP"); + } + else { + xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); + } + ESP_LOGI(TAG, "connect to the AP fail"); + WiFiEthernetReady = 0; + } + else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { + event = (ip_event_got_ip_t*) event_data; + wifi_show_ip(); + s_retry_num = 0; + xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); + WiFiEthernetReady = 1; + } +} + +int wifi_init_sta(void) +{ + int ret = ESP_OK; +#if defined(CONFIG_IDF_TARGET_ESP8266) + ESP_LOGE(TAG, "Error: wifi_init_sta not implemented for ESP8266"); +#else + /* ESP32, non-ESP8266 WiFi begin */ + s_wifi_event_group = xEventGroupCreate(); + + ESP_ERROR_CHECK(esp_netif_init()); + + ESP_ERROR_CHECK(esp_event_loop_create_default()); + esp_netif_create_default_wifi_sta(); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + + esp_event_handler_instance_t instance_any_id; + esp_event_handler_instance_t instance_got_ip; + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &event_handler, + NULL, + &instance_any_id)); + ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, + IP_EVENT_STA_GOT_IP, + &event_handler, + NULL, + &instance_got_ip)); + + wifi_config_t wifi_config = { + .sta = { + .ssid = EXAMPLE_ESP_WIFI_SSID, + .password = EXAMPLE_ESP_WIFI_PASS, + /* Authmode threshold resets to WPA2 as default if password matches + * WPA2 standards (pasword len => 8). If you want to connect the + * device to deprecated WEP/WPA networks, Please set the threshold + * value WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with + * length and format matching to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK + * standards. */ + .threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD, + #ifdef HAS_WPA3_FEATURES + .sae_pwe_h2e = WPA3_SAE_PWE_BOTH, + #endif + }, + }; + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); + + #ifdef CONFIG_EXAMPLE_WIFI_SSID + if (XSTRCMP(CONFIG_EXAMPLE_WIFI_SSID, "myssid") == 0) { + ESP_LOGW(TAG, "WARNING: CONFIG_EXAMPLE_WIFI_SSID is \"myssid\"."); + ESP_LOGW(TAG, " Do you have a WiFi AP called \"myssid\", "); + ESP_LOGW(TAG, " or did you forget the ESP-IDF configuration?"); + } + #else + ESP_LOGW(TAG, "WARNING: CONFIG_EXAMPLE_WIFI_SSID not defined."); + #endif + + ESP_ERROR_CHECK(esp_wifi_start() ); + + ESP_LOGI(TAG, "wifi_init_sta finished."); + + /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) + * or connection failed for the maximum number of re-tries (WIFI_FAIL_BIT). + * The bits are set by event_handler() (see above) */ + EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, + WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, + pdFALSE, + pdFALSE, + portMAX_DELAY); + + /* xEventGroupWaitBits() returns the bits before the call returned, + * hence we can test which event actually happened. */ + #if defined(SHOW_SSID_AND_PASSWORD) + ESP_LOGW(TAG, "Undefine SHOW_SSID_AND_PASSWORD to not show SSID/password"); + if (bits & WIFI_CONNECTED_BIT) { + ESP_LOGI(TAG, "connected to ap SSID:%s password:%s", + EXAMPLE_ESP_WIFI_SSID, + EXAMPLE_ESP_WIFI_PASS); + } + else if (bits & WIFI_FAIL_BIT) { + ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s", + EXAMPLE_ESP_WIFI_SSID, + EXAMPLE_ESP_WIFI_PASS); + } + else { + ESP_LOGE(TAG, "UNEXPECTED EVENT"); + } + #else + if (bits & WIFI_CONNECTED_BIT) { + ESP_LOGI(TAG, "Connected to AP"); + } + else if (bits & WIFI_FAIL_BIT) { + ESP_LOGI(TAG, "Failed to connect to AP"); + ret = -1; + } + else { + ESP_LOGE(TAG, "AP UNEXPECTED EVENT"); + ret = -2; + } + #endif /* SHOW_SSID_AND_PASSWORD */ +#endif /* ESP32 or ESP8266 implementation */ + + return ret; +} + +int wifi_show_ip(void) +{ + /* TODO Causes panic: + * ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); */ + return ESP_OK; +} +#endif + +/* + * WiFi wifi_ap_event_handler() Public Domain Sample Code Credit Espressif + * + * See https://github.com/espressif/esp-idf/blob/master/examples/wifi/getting_started/softAP/main/softap_example_main.c + * + */ +#ifndef MACSTR + #define MACSTR "00:04:a3:12:34:56" +#endif + +#if defined(USE_AP) +static void wifi_ap_event_handler(void* arg, + esp_event_base_t event_base, + int32_t event_id, + void* event_data) +{ + if (event_id == WIFI_EVENT_AP_STACONNECTED) { + wifi_event_ap_staconnected_t* event = + (wifi_event_ap_staconnected_t*) event_data; + + ESP_LOGI(TAG, + "station "MACSTR" join, AID=%d", + MAC2STR(event->mac), + event->aid); + } + else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) { + wifi_event_ap_stadisconnected_t* event = + (wifi_event_ap_stadisconnected_t*) event_data; + + ESP_LOGI(TAG, + "station "MACSTR" leave, AID=%d", + MAC2STR(event->mac), + event->aid); + } + + /* when acting as AP, we're always ready, as we're not awaiting connection or IP addy */ + WiFiEthernetReady = 1; +} + + +/* + * WiFi wifi_init_softap() Public Domain Sample Code Credit Espressif + * + * See https://github.com/espressif/esp-idf/blob/master/examples/wifi/getting_started/softAP/main/softap_example_main.c + * + */ +void wifi_init_softap(void) +{ + wifi_config_t wifi_config = { + .ap = { + .ssid = EXAMPLE_ESP_WIFI_AP_SSID, + .ssid_len = strlen(EXAMPLE_ESP_WIFI_AP_SSID), + .channel = EXAMPLE_ESP_WIFI_CHANNEL, + .password = EXAMPLE_ESP_WIFI_AP_PASS, + .max_connection = EXAMPLE_MAX_STA_CONN, + .authmode = WIFI_AUTH_WPA2_PSK + }, + }; + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + esp_netif_create_default_wifi_ap(); + + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + + ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, + ESP_EVENT_ANY_ID, + &wifi_ap_event_handler, + NULL, + NULL)); + + if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) { + wifi_config.ap.authmode = WIFI_AUTH_OPEN; + } + + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config)); + ESP_ERROR_CHECK(esp_wifi_start()); + + ESP_LOGI(TAG, + "wifi_init_softap finished. SSID:%s password:%s channel:%d", + EXAMPLE_ESP_WIFI_AP_SSID, + EXAMPLE_ESP_WIFI_AP_PASS, + EXAMPLE_ESP_WIFI_CHANNEL); +} +#endif + +/* + * return true when above events determined that WiFi is actually ready. + */ +bool wifi_ready() +{ + ESP_LOGV(TAG, "wifi_ready check"); + + return WiFiEthernetReady; +} \ No newline at end of file diff --git a/Espressif/ESP32/ESP32-SSH-Server/partitions_singleapp_large.csv b/Espressif/ESP32/ESP32-SSH-Server/partitions_singleapp_large.csv new file mode 100644 index 0000000..0b2fcd1 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/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/Espressif/ESP32/ESP32-SSH-Server/sdkconfig b/Espressif/ESP32/ESP32-SSH-Server/sdkconfig deleted file mode 100644 index 3400a72..0000000 --- a/Espressif/ESP32/ESP32-SSH-Server/sdkconfig +++ /dev/null @@ -1,1402 +0,0 @@ -# -# Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -CONFIG_IDF_CMAKE=y -CONFIG_IDF_TARGET_ARCH_XTENSA=y -CONFIG_IDF_TARGET="esp32" -CONFIG_IDF_TARGET_ESP32=y -CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 - -# -# SDK tool configuration -# -CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-" -# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set -# end of SDK tool configuration - -# -# Build type -# -CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y -# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set -CONFIG_APP_BUILD_GENERATE_BINARIES=y -CONFIG_APP_BUILD_BOOTLOADER=y -CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y -# end of Build type - -# -# Application manager -# -CONFIG_APP_COMPILE_TIME_DATE=y -# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set -# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set -# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set -CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 -# end of Application manager - -# -# Bootloader config -# -CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 -CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set -CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y -# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set -CONFIG_BOOTLOADER_LOG_LEVEL=3 -# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set -CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y -# CONFIG_BOOTLOADER_FACTORY_RESET is not set -# CONFIG_BOOTLOADER_APP_TEST is not set -CONFIG_BOOTLOADER_WDT_ENABLE=y -# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set -CONFIG_BOOTLOADER_WDT_TIME_MS=9000 -# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set -CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 -# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set -CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y -# end of Bootloader config - -# -# Security features -# -# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set -# CONFIG_SECURE_BOOT is not set -# CONFIG_SECURE_FLASH_ENC_ENABLED is not set -# end of Security features - -# -# Serial flasher config -# -CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 -# CONFIG_ESPTOOLPY_NO_STUB is not set -# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set -# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set -CONFIG_ESPTOOLPY_FLASHMODE_DIO=y -# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set -CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y -CONFIG_ESPTOOLPY_FLASHMODE="dio" -# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_40M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -CONFIG_ESPTOOLPY_FLASHFREQ="40m" -# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="4MB" -CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y -CONFIG_ESPTOOLPY_BEFORE_RESET=y -# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" -CONFIG_ESPTOOLPY_AFTER_RESET=y -# CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" -# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y -# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -# end of Serial flasher config - -# -# Partition Table -# -CONFIG_PARTITION_TABLE_SINGLE_APP=y -# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set -# 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.csv" -CONFIG_PARTITION_TABLE_OFFSET=0x8000 -CONFIG_PARTITION_TABLE_MD5=y -# end of Partition Table - -# -# Example Configuration -# -CONFIG_EXAMPLE_GPIO_RANGE_MIN=0 -CONFIG_EXAMPLE_GPIO_RANGE_MAX=33 -CONFIG_EXAMPLE_ENC28J60_SPI_HOST=1 -CONFIG_EXAMPLE_ENC28J60_SCLK_GPIO=19 -CONFIG_EXAMPLE_ENC28J60_MOSI_GPIO=23 -CONFIG_EXAMPLE_ENC28J60_MISO_GPIO=25 -CONFIG_EXAMPLE_ENC28J60_CS_GPIO=22 -CONFIG_EXAMPLE_ENC28J60_SPI_CLOCK_MHZ=6 -CONFIG_EXAMPLE_ENC28J60_INT_GPIO=4 -# CONFIG_EXAMPLE_ENC28J60_DUPLEX_FULL is not set -CONFIG_EXAMPLE_ENC28J60_DUPLEX_HALF=y -# end of Example Configuration - -# -# Compiler options -# -CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set -# CONFIG_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_COMPILER_OPTIMIZATION_NONE is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 -# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set -CONFIG_COMPILER_HIDE_PATHS_MACROS=y -# CONFIG_COMPILER_CXX_EXCEPTIONS is not set -# CONFIG_COMPILER_CXX_RTTI is not set -CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y -# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set -# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set -# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set -# CONFIG_COMPILER_DUMP_RTL_FILES is not set -# end of Compiler options - -# -# Component config -# - -# -# Application Level Tracing -# -# CONFIG_APPTRACE_DEST_JTAG is not set -CONFIG_APPTRACE_DEST_NONE=y -CONFIG_APPTRACE_LOCK_ENABLE=y -# end of Application Level Tracing - -# -# ESP-ASIO -# -# CONFIG_ASIO_SSL_SUPPORT is not set -# end of ESP-ASIO - -# -# Bluetooth -# -# CONFIG_BT_ENABLED is not set -# end of Bluetooth - -# -# CoAP Configuration -# -CONFIG_COAP_MBEDTLS_PSK=y -# CONFIG_COAP_MBEDTLS_PKI is not set -# CONFIG_COAP_MBEDTLS_DEBUG is not set -CONFIG_COAP_LOG_DEFAULT_LEVEL=0 -# end of CoAP Configuration - -# -# Driver configurations -# - -# -# ADC configuration -# -# CONFIG_ADC_FORCE_XPD_FSM is not set -CONFIG_ADC_DISABLE_DAC=y -# end of ADC configuration - -# -# MCPWM configuration -# -# CONFIG_MCPWM_ISR_IN_IRAM is not set -# end of MCPWM configuration - -# -# SPI configuration -# -# CONFIG_SPI_MASTER_IN_IRAM is not set -CONFIG_SPI_MASTER_ISR_IN_IRAM=y -# CONFIG_SPI_SLAVE_IN_IRAM is not set -CONFIG_SPI_SLAVE_ISR_IN_IRAM=y -# end of SPI configuration - -# -# TWAI configuration -# -# CONFIG_TWAI_ISR_IN_IRAM is not set -# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set -# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set -# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set -# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set -# end of TWAI configuration - -# -# UART configuration -# -# CONFIG_UART_ISR_IN_IRAM is not set -# end of UART configuration - -# -# RTCIO configuration -# -# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set -# end of RTCIO configuration - -# -# GPIO Configuration -# -# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set -# end of GPIO Configuration - -# -# GDMA Configuration -# -# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set -# CONFIG_GDMA_ISR_IRAM_SAFE is not set -# end of GDMA Configuration -# end of Driver configurations - -# -# eFuse Bit Manager -# -# CONFIG_EFUSE_CUSTOM_TABLE is not set -# CONFIG_EFUSE_VIRTUAL is not set -# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set -CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y -# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set -CONFIG_EFUSE_MAX_BLK_LEN=192 -# end of eFuse Bit Manager - -# -# ESP-TLS -# -CONFIG_ESP_TLS_USING_MBEDTLS=y -# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set -# CONFIG_ESP_TLS_SERVER is not set -# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set -# CONFIG_ESP_TLS_PSK_VERIFICATION is not set -# CONFIG_ESP_TLS_INSECURE is not set -# end of ESP-TLS - -# -# ESP32-specific -# -CONFIG_ESP32_REV_MIN_0=y -# CONFIG_ESP32_REV_MIN_1 is not set -# CONFIG_ESP32_REV_MIN_2 is not set -# CONFIG_ESP32_REV_MIN_3 is not set -CONFIG_ESP32_REV_MIN=0 -CONFIG_ESP32_DPORT_WORKAROUND=y -# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set -CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y -# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set -CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 -# CONFIG_ESP32_SPIRAM_SUPPORT is not set -# CONFIG_ESP32_TRAX is not set -CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 -# CONFIG_ESP32_ULP_COPROC_ENABLED is not set -CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 -CONFIG_ESP32_DEBUG_OCDAWARE=y -CONFIG_ESP32_BROWNOUT_DET=y -CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set -CONFIG_ESP32_BROWNOUT_DET_LVL=0 -CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y -# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set -CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y -# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set -# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set -# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set -CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 -CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 -CONFIG_ESP32_XTAL_FREQ_40=y -# CONFIG_ESP32_XTAL_FREQ_26 is not set -# CONFIG_ESP32_XTAL_FREQ_AUTO is not set -CONFIG_ESP32_XTAL_FREQ=40 -# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set -# CONFIG_ESP32_NO_BLOBS is not set -# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set -# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set -# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set -CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 -# end of ESP32-specific - -# -# ADC-Calibration -# -CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y -CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y -CONFIG_ADC_CAL_LUT_ENABLE=y -# end of ADC-Calibration - -# -# Common ESP-related -# -CONFIG_ESP_ERR_TO_NAME_LOOKUP=y -# end of Common ESP-related - -# -# Ethernet -# -CONFIG_ETH_ENABLED=y -CONFIG_ETH_USE_ESP32_EMAC=y -CONFIG_ETH_PHY_INTERFACE_RMII=y -CONFIG_ETH_RMII_CLK_INPUT=y -# CONFIG_ETH_RMII_CLK_OUTPUT is not set -CONFIG_ETH_RMII_CLK_IN_GPIO=0 -CONFIG_ETH_DMA_BUFFER_SIZE=512 -CONFIG_ETH_DMA_RX_BUFFER_NUM=10 -CONFIG_ETH_DMA_TX_BUFFER_NUM=10 -CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set -# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set -# CONFIG_ETH_USE_OPENETH is not set -# end of Ethernet - -# -# Event Loop Library -# -# CONFIG_ESP_EVENT_LOOP_PROFILING is not set -CONFIG_ESP_EVENT_POST_FROM_ISR=y -CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y -# end of Event Loop Library - -# -# GDB Stub -# -# end of GDB Stub - -# -# ESP HTTP client -# -CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y -# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set -CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH=y -# end of ESP HTTP client - -# -# HTTP Server -# -CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 -CONFIG_HTTPD_MAX_URI_LEN=512 -CONFIG_HTTPD_ERR_RESP_NO_DELAY=y -CONFIG_HTTPD_PURGE_BUF_LEN=32 -# CONFIG_HTTPD_LOG_PURGE_DATA is not set -# CONFIG_HTTPD_WS_SUPPORT is not set -# end of HTTP Server - -# -# ESP HTTPS OTA -# -# CONFIG_OTA_ALLOW_HTTP is not set -# end of ESP HTTPS OTA - -# -# ESP HTTPS server -# -# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set -# end of ESP HTTPS server - -# -# Hardware Settings -# - -# -# MAC Config -# -CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y -# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set -CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y -CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 -# end of MAC Config - -# -# Sleep Config -# -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y -CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y -# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set -# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set -# end of Sleep Config - -# -# RTC Clock Config -# -# end of RTC Clock Config -# end of Hardware Settings - -# -# IPC (Inter-Processor Call) -# -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 -CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y -CONFIG_ESP_IPC_ISR_ENABLE=y -# end of IPC (Inter-Processor Call) - -# -# LCD and Touch Panel -# - -# -# LCD Peripheral Configuration -# -CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 -# end of LCD Peripheral Configuration -# end of LCD and Touch Panel - -# -# ESP NETIF Adapter -# -CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 -CONFIG_ESP_NETIF_TCPIP_LWIP=y -# CONFIG_ESP_NETIF_LOOPBACK is not set -# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set -# end of ESP NETIF Adapter - -# -# PHY -# -CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y -# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set -CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 -CONFIG_ESP_PHY_MAX_TX_POWER=20 -CONFIG_ESP_PHY_REDUCE_TX_POWER=y -# end of PHY - -# -# Power Management -# -# CONFIG_PM_ENABLE is not set -# end of Power Management - -# -# ESP System Settings -# -# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set -CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y -# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set -# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set -# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set - -# -# Memory protection -# -# end of Memory protection - -CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_ESP_MAIN_TASK_STACK_SIZE=20584 -CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y -# CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set -# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 -CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_NONE is not set -CONFIG_ESP_CONSOLE_UART=y -CONFIG_ESP_CONSOLE_MULTIPLE_UART=y -CONFIG_ESP_CONSOLE_UART_NUM=0 -CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 -CONFIG_ESP_INT_WDT=y -CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 -CONFIG_ESP_INT_WDT_CHECK_CPU1=y -CONFIG_ESP_TASK_WDT=y -# CONFIG_ESP_TASK_WDT_PANIC is not set -CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y -# CONFIG_ESP_PANIC_HANDLER_IRAM is not set -# CONFIG_ESP_DEBUG_STUBS_ENABLE is not set -# CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set -CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y -# end of ESP System Settings - -# -# High resolution timer (esp_timer) -# -# CONFIG_ESP_TIMER_PROFILING is not set -CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y -CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y -CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 -CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 -# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set -# CONFIG_ESP_TIMER_IMPL_FRC2 is not set -CONFIG_ESP_TIMER_IMPL_TG0_LAC=y -# end of High resolution timer (esp_timer) - -# -# Wi-Fi -# -CONFIG_ESP32_WIFI_ENABLED=y -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 -CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 -# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y -CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 -# CONFIG_ESP32_WIFI_CSI_ENABLED is not set -CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y -CONFIG_ESP32_WIFI_TX_BA_WIN=6 -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_RX_BA_WIN=6 -CONFIG_ESP32_WIFI_NVS_ENABLED=y -CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y -# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set -CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 -CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 -CONFIG_ESP32_WIFI_IRAM_OPT=y -CONFIG_ESP32_WIFI_RX_IRAM_OPT=y -CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y -# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set -# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set -# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set -CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y -# end of Wi-Fi - -# -# Core dump -# -# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set -# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set -CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y -# end of Core dump - -# -# FAT Filesystem support -# -# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set -CONFIG_FATFS_CODEPAGE_437=y -# CONFIG_FATFS_CODEPAGE_720 is not set -# CONFIG_FATFS_CODEPAGE_737 is not set -# CONFIG_FATFS_CODEPAGE_771 is not set -# CONFIG_FATFS_CODEPAGE_775 is not set -# CONFIG_FATFS_CODEPAGE_850 is not set -# CONFIG_FATFS_CODEPAGE_852 is not set -# CONFIG_FATFS_CODEPAGE_855 is not set -# CONFIG_FATFS_CODEPAGE_857 is not set -# CONFIG_FATFS_CODEPAGE_860 is not set -# CONFIG_FATFS_CODEPAGE_861 is not set -# CONFIG_FATFS_CODEPAGE_862 is not set -# CONFIG_FATFS_CODEPAGE_863 is not set -# CONFIG_FATFS_CODEPAGE_864 is not set -# CONFIG_FATFS_CODEPAGE_865 is not set -# CONFIG_FATFS_CODEPAGE_866 is not set -# CONFIG_FATFS_CODEPAGE_869 is not set -# CONFIG_FATFS_CODEPAGE_932 is not set -# CONFIG_FATFS_CODEPAGE_936 is not set -# CONFIG_FATFS_CODEPAGE_949 is not set -# CONFIG_FATFS_CODEPAGE_950 is not set -CONFIG_FATFS_CODEPAGE=437 -CONFIG_FATFS_LFN_NONE=y -# CONFIG_FATFS_LFN_HEAP is not set -# CONFIG_FATFS_LFN_STACK is not set -CONFIG_FATFS_FS_LOCK=0 -CONFIG_FATFS_TIMEOUT_MS=10000 -CONFIG_FATFS_PER_FILE_CACHE=y -# CONFIG_FATFS_USE_FASTSEEK is not set -# end of FAT Filesystem support - -# -# Modbus configuration -# -CONFIG_FMB_COMM_MODE_TCP_EN=y -CONFIG_FMB_TCP_PORT_DEFAULT=502 -CONFIG_FMB_TCP_PORT_MAX_CONN=5 -CONFIG_FMB_TCP_CONNECTION_TOUT_SEC=20 -CONFIG_FMB_COMM_MODE_RTU_EN=y -CONFIG_FMB_COMM_MODE_ASCII_EN=y -CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 -CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 -CONFIG_FMB_QUEUE_LENGTH=20 -CONFIG_FMB_PORT_TASK_STACK_SIZE=4096 -CONFIG_FMB_SERIAL_BUF_SIZE=256 -CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 -CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 -CONFIG_FMB_PORT_TASK_PRIO=10 -# CONFIG_FMB_PORT_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_FMB_PORT_TASK_AFFINITY_CPU0=y -# CONFIG_FMB_PORT_TASK_AFFINITY_CPU1 is not set -CONFIG_FMB_PORT_TASK_AFFINITY=0x0 -CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y -CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233 -CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 -CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 -CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 -CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 -# CONFIG_FMB_TIMER_PORT_ENABLED is not set -CONFIG_FMB_TIMER_GROUP=0 -CONFIG_FMB_TIMER_INDEX=0 -CONFIG_FMB_MASTER_TIMER_GROUP=0 -CONFIG_FMB_MASTER_TIMER_INDEX=0 -# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set -# end of Modbus configuration - -# -# FreeRTOS -# -# CONFIG_FREERTOS_UNICORE is not set -CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF -CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y -CONFIG_FREERTOS_CORETIMER_0=y -# CONFIG_FREERTOS_CORETIMER_1 is not set -CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y -CONFIG_FREERTOS_HZ=100 -CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set -CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y -# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set -CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y -CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 -CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y -# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set -# CONFIG_FREERTOS_ASSERT_DISABLE is not set -CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=20304 -CONFIG_FREERTOS_ISR_STACKSIZE=11536 -# CONFIG_FREERTOS_LEGACY_HOOKS is not set -CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 -CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y -# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set -CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=12048 -CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 -CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 -# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set -# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set -CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y -CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y -# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set -CONFIG_FREERTOS_DEBUG_OCDAWARE=y -# CONFIG_FREERTOS_FPU_IN_ISR is not set -CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y -# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set -# end of FreeRTOS - -# -# Hardware Abstraction Layer (HAL) and Low Level (LL) -# -CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y -# CONFIG_HAL_ASSERTION_DISABLE is not set -# CONFIG_HAL_ASSERTION_SILIENT is not set -# CONFIG_HAL_ASSERTION_ENABLE is not set -CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 -# end of Hardware Abstraction Layer (HAL) and Low Level (LL) - -# -# Heap memory debugging -# -CONFIG_HEAP_POISONING_DISABLED=y -# CONFIG_HEAP_POISONING_LIGHT is not set -# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set -CONFIG_HEAP_TRACING_OFF=y -# CONFIG_HEAP_TRACING_STANDALONE is not set -# CONFIG_HEAP_TRACING_TOHOST is not set -# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set -# end of Heap memory debugging - -# -# jsmn -# -# CONFIG_JSMN_PARENT_LINKS is not set -# CONFIG_JSMN_STRICT is not set -# end of jsmn - -# -# libsodium -# -# end of libsodium - -# -# Log output -# -# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set -# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set -# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set -CONFIG_LOG_DEFAULT_LEVEL_INFO=y -# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set -# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set -CONFIG_LOG_DEFAULT_LEVEL=3 -CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y -# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set -# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set -CONFIG_LOG_MAXIMUM_LEVEL=3 -CONFIG_LOG_COLORS=y -CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y -# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set -# end of Log output - -# -# LWIP -# -CONFIG_LWIP_LOCAL_HOSTNAME="espressif" -# CONFIG_LWIP_NETIF_API is not set -# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set -CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y -# CONFIG_LWIP_L2_TO_L3_COPY is not set -# CONFIG_LWIP_IRAM_OPTIMIZATION is not set -CONFIG_LWIP_TIMERS_ONDEMAND=y -CONFIG_LWIP_MAX_SOCKETS=10 -# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set -# CONFIG_LWIP_SO_LINGER is not set -CONFIG_LWIP_SO_REUSE=y -CONFIG_LWIP_SO_REUSE_RXTOALL=y -# CONFIG_LWIP_SO_RCVBUF is not set -# CONFIG_LWIP_NETBUF_RECVINFO is not set -CONFIG_LWIP_IP4_FRAG=y -CONFIG_LWIP_IP6_FRAG=y -# CONFIG_LWIP_IP4_REASSEMBLY is not set -# CONFIG_LWIP_IP6_REASSEMBLY is not set -# CONFIG_LWIP_IP_FORWARD is not set -# CONFIG_LWIP_STATS is not set -# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set -CONFIG_LWIP_ESP_GRATUITOUS_ARP=y -CONFIG_LWIP_GARP_TMR_INTERVAL=60 -CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 -CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y -# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set -CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y -# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set -CONFIG_LWIP_DHCP_OPTIONS_LEN=68 - -# -# DHCP server -# -CONFIG_LWIP_DHCPS=y -CONFIG_LWIP_DHCPS_LEASE_UNIT=60 -CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 -# end of DHCP server - -# CONFIG_LWIP_AUTOIP is not set -CONFIG_LWIP_IPV6=y -# CONFIG_LWIP_IPV6_AUTOCONFIG is not set -CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 -# CONFIG_LWIP_IPV6_FORWARD is not set -# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set -CONFIG_LWIP_NETIF_LOOPBACK=y -CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 - -# -# TCP -# -CONFIG_LWIP_MAX_ACTIVE_TCP=16 -CONFIG_LWIP_MAX_LISTENING_TCP=16 -CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y -CONFIG_LWIP_TCP_MAXRTX=12 -CONFIG_LWIP_TCP_SYNMAXRTX=12 -CONFIG_LWIP_TCP_MSS=1440 -CONFIG_LWIP_TCP_TMR_INTERVAL=250 -CONFIG_LWIP_TCP_MSL=60000 -CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 -CONFIG_LWIP_TCP_WND_DEFAULT=5744 -CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 -CONFIG_LWIP_TCP_QUEUE_OOSEQ=y -# CONFIG_LWIP_TCP_SACK_OUT is not set -# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set -CONFIG_LWIP_TCP_OVERSIZE_MSS=y -# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set -# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set -CONFIG_LWIP_TCP_RTO_TIME=1500 -# end of TCP - -# -# UDP -# -CONFIG_LWIP_MAX_UDP_PCBS=16 -CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 -# end of UDP - -# -# Checksums -# -# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set -# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set -CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y -# end of Checksums - -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set -# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set -CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_LWIP_PPP_SUPPORT is not set -CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 -CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 -# CONFIG_LWIP_SLIP_SUPPORT is not set - -# -# ICMP -# -CONFIG_LWIP_ICMP=y -# CONFIG_LWIP_MULTICAST_PING is not set -# CONFIG_LWIP_BROADCAST_PING is not set -# end of ICMP - -# -# LWIP RAW API -# -CONFIG_LWIP_MAX_RAW_PCBS=16 -# end of LWIP RAW API - -# -# SNTP -# -CONFIG_LWIP_SNTP_MAX_SERVERS=1 -# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set -CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 -# end of SNTP - -CONFIG_LWIP_ESP_LWIP_ASSERT=y - -# -# Hooks -# -# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set -CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y -# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set -CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y -# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set -# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set -CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y -# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set -# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set -CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y -# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set -# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set -# end of Hooks - -# CONFIG_LWIP_DEBUG is not set -# end of LWIP - -# -# mbedTLS -# -CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y -# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set -# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set -CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 -# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set -# CONFIG_MBEDTLS_DEBUG is not set - -# -# mbedTLS v2.28.x related -# -# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set -# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set -# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set -CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y -# end of mbedTLS v2.28.x related - -# -# Certificate Bundle -# -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set -# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set -# end of Certificate Bundle - -# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set -# CONFIG_MBEDTLS_CMAC_C is not set -CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_HARDWARE_MPI=y -CONFIG_MBEDTLS_HARDWARE_SHA=y -CONFIG_MBEDTLS_ROM_MD5=y -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set -CONFIG_MBEDTLS_HAVE_TIME=y -# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set -CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y -CONFIG_MBEDTLS_SHA512_C=y -CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y -# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set -# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set -# CONFIG_MBEDTLS_TLS_DISABLED is not set -CONFIG_MBEDTLS_TLS_SERVER=y -CONFIG_MBEDTLS_TLS_CLIENT=y -CONFIG_MBEDTLS_TLS_ENABLED=y - -# -# TLS Key Exchange Methods -# -# CONFIG_MBEDTLS_PSK_MODES is not set -CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y -# end of TLS Key Exchange Methods - -CONFIG_MBEDTLS_SSL_RENEGOTIATION=y -# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set -CONFIG_MBEDTLS_SSL_PROTO_TLS1=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y -# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set -CONFIG_MBEDTLS_SSL_ALPN=y -CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y -CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y -CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y -CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y - -# -# Symmetric Ciphers -# -CONFIG_MBEDTLS_AES_C=y -# CONFIG_MBEDTLS_CAMELLIA_C is not set -# CONFIG_MBEDTLS_DES_C is not set -CONFIG_MBEDTLS_RC4_DISABLED=y -# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set -# CONFIG_MBEDTLS_RC4_ENABLED is not set -# CONFIG_MBEDTLS_BLOWFISH_C is not set -# CONFIG_MBEDTLS_XTEA_C is not set -CONFIG_MBEDTLS_CCM_C=y -CONFIG_MBEDTLS_GCM_C=y -# CONFIG_MBEDTLS_NIST_KW_C is not set -# end of Symmetric Ciphers - -# CONFIG_MBEDTLS_RIPEMD160_C is not set - -# -# Certificates -# -CONFIG_MBEDTLS_PEM_PARSE_C=y -CONFIG_MBEDTLS_PEM_WRITE_C=y -CONFIG_MBEDTLS_X509_CRL_PARSE_C=y -CONFIG_MBEDTLS_X509_CSR_PARSE_C=y -# end of Certificates - -CONFIG_MBEDTLS_ECP_C=y -CONFIG_MBEDTLS_ECDH_C=y -CONFIG_MBEDTLS_ECDSA_C=y -# CONFIG_MBEDTLS_ECJPAKE_C is not set -CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y -CONFIG_MBEDTLS_ECP_NIST_OPTIM=y -# CONFIG_MBEDTLS_POLY1305_C is not set -# CONFIG_MBEDTLS_CHACHA20_C is not set -# CONFIG_MBEDTLS_HKDF_C is not set -# CONFIG_MBEDTLS_THREADING_C is not set -# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set -# CONFIG_MBEDTLS_SECURITY_RISKS is not set -# end of mbedTLS - -# -# mDNS -# -CONFIG_MDNS_MAX_SERVICES=10 -CONFIG_MDNS_TASK_PRIORITY=1 -CONFIG_MDNS_TASK_STACK_SIZE=4096 -# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_MDNS_TASK_AFFINITY_CPU0=y -# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set -CONFIG_MDNS_TASK_AFFINITY=0x0 -CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 -# CONFIG_MDNS_STRICT_MODE is not set -CONFIG_MDNS_TIMER_PERIOD_MS=100 -# CONFIG_MDNS_NETWORKING_SOCKET is not set -CONFIG_MDNS_MULTIPLE_INSTANCE=y -# end of mDNS - -# -# ESP-MQTT Configurations -# -CONFIG_MQTT_PROTOCOL_311=y -CONFIG_MQTT_TRANSPORT_SSL=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y -# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set -# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set -# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set -# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set -# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set -# CONFIG_MQTT_CUSTOM_OUTBOX is not set -# end of ESP-MQTT Configurations - -# -# Newlib -# -CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set -CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y -# CONFIG_NEWLIB_NANO_FORMAT is not set -# end of Newlib - -# -# NVS -# -# end of NVS - -# -# OpenSSL -# -# CONFIG_OPENSSL_DEBUG is not set -CONFIG_OPENSSL_ERROR_STACK=y -# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set -CONFIG_OPENSSL_ASSERT_EXIT=y -# end of OpenSSL - -# -# OpenThread -# -# CONFIG_OPENTHREAD_ENABLED is not set -# end of OpenThread - -# -# PThreads -# -CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=13072 -CONFIG_PTHREAD_STACK_MIN=768 -CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y -# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set -# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set -CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 -CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" -# end of PThreads - -# -# SPI Flash driver -# -# CONFIG_SPI_FLASH_VERIFY_WRITE is not set -# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set -CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y -CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y -# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set -# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set -# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set -# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set -# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set -CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y -CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 -CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 -CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 -# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set -# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set -# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set - -# -# Auto-detect flash chips -# -CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y -# CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP is not set -# CONFIG_SPI_FLASH_SUPPORT_TH_CHIP is not set -# end of Auto-detect flash chips - -CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y -# end of SPI Flash driver - -# -# SPIFFS Configuration -# -CONFIG_SPIFFS_MAX_PARTITIONS=3 - -# -# SPIFFS Cache Configuration -# -CONFIG_SPIFFS_CACHE=y -CONFIG_SPIFFS_CACHE_WR=y -# CONFIG_SPIFFS_CACHE_STATS is not set -# end of SPIFFS Cache Configuration - -CONFIG_SPIFFS_PAGE_CHECK=y -CONFIG_SPIFFS_GC_MAX_RUNS=10 -# CONFIG_SPIFFS_GC_STATS is not set -CONFIG_SPIFFS_PAGE_SIZE=256 -CONFIG_SPIFFS_OBJ_NAME_LEN=32 -# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set -CONFIG_SPIFFS_USE_MAGIC=y -CONFIG_SPIFFS_USE_MAGIC_LENGTH=y -CONFIG_SPIFFS_META_LENGTH=4 -CONFIG_SPIFFS_USE_MTIME=y - -# -# Debug Configuration -# -# CONFIG_SPIFFS_DBG is not set -# CONFIG_SPIFFS_API_DBG is not set -# CONFIG_SPIFFS_GC_DBG is not set -# CONFIG_SPIFFS_CACHE_DBG is not set -# CONFIG_SPIFFS_CHECK_DBG is not set -# CONFIG_SPIFFS_TEST_VISUALISATION is not set -# end of Debug Configuration -# end of SPIFFS Configuration - -# -# TCP Transport -# - -# -# Websocket -# -CONFIG_WS_TRANSPORT=y -CONFIG_WS_BUFFER_SIZE=1024 -# end of Websocket -# end of TCP Transport - -# -# Unity unit testing library -# -CONFIG_UNITY_ENABLE_FLOAT=y -CONFIG_UNITY_ENABLE_DOUBLE=y -# CONFIG_UNITY_ENABLE_64BIT is not set -# CONFIG_UNITY_ENABLE_COLOR is not set -CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y -# CONFIG_UNITY_ENABLE_FIXTURE is not set -# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set -# end of Unity unit testing library - -# -# Virtual file system -# -CONFIG_VFS_SUPPORT_IO=y -CONFIG_VFS_SUPPORT_DIR=y -CONFIG_VFS_SUPPORT_SELECT=y -CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y -CONFIG_VFS_SUPPORT_TERMIOS=y - -# -# Host File System I/O (Semihosting) -# -CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 -# end of Host File System I/O (Semihosting) -# end of Virtual file system - -# -# Wear Levelling -# -# CONFIG_WL_SECTOR_SIZE_512 is not set -CONFIG_WL_SECTOR_SIZE_4096=y -CONFIG_WL_SECTOR_SIZE=4096 -# end of Wear Levelling - -# -# Wi-Fi Provisioning Manager -# -CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 -CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 -# end of Wi-Fi Provisioning Manager - -# -# Supplicant -# -CONFIG_WPA_MBEDTLS_CRYPTO=y -# CONFIG_WPA_WAPI_PSK is not set -# CONFIG_WPA_SUITE_B_192 is not set -# CONFIG_WPA_DEBUG_PRINT is not set -# CONFIG_WPA_TESTING_OPTIONS is not set -# CONFIG_WPA_WPS_STRICT is not set -# CONFIG_WPA_11KV_SUPPORT is not set -# end of Supplicant -# end of Component config - -# -# Compatibility options -# -# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set -# end of Compatibility options - -# Deprecated options for backward compatibility -CONFIG_TOOLPREFIX="xtensa-esp32-elf-" -# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set -CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y -# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set -CONFIG_LOG_BOOTLOADER_LEVEL=3 -# CONFIG_APP_ROLLBACK_ENABLE is not set -# CONFIG_FLASH_ENCRYPTION_ENABLED is not set -# CONFIG_FLASHMODE_QIO is not set -# CONFIG_FLASHMODE_QOUT is not set -CONFIG_FLASHMODE_DIO=y -# CONFIG_FLASHMODE_DOUT is not set -# CONFIG_MONITOR_BAUD_9600B is not set -# CONFIG_MONITOR_BAUD_57600B is not set -CONFIG_MONITOR_BAUD_115200B=y -# CONFIG_MONITOR_BAUD_230400B is not set -# CONFIG_MONITOR_BAUD_921600B is not set -# CONFIG_MONITOR_BAUD_2MB is not set -# CONFIG_MONITOR_BAUD_OTHER is not set -CONFIG_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_MONITOR_BAUD=115200 -CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y -# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set -CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y -# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set -CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 -# CONFIG_CXX_EXCEPTIONS is not set -CONFIG_STACK_CHECK_NONE=y -# CONFIG_STACK_CHECK_NORM is not set -# CONFIG_STACK_CHECK_STRONG is not set -# CONFIG_STACK_CHECK_ALL is not set -# CONFIG_WARN_WRITE_STRINGS is not set -# CONFIG_DISABLE_GCC8_WARNINGS is not set -# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set -CONFIG_ESP32_APPTRACE_DEST_NONE=y -CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y -CONFIG_ADC2_DISABLE_DAC=y -# CONFIG_SPIRAM_SUPPORT is not set -CONFIG_TRACEMEM_RESERVE_DRAM=0x0 -# CONFIG_ULP_COPROC_ENABLED is not set -CONFIG_ULP_COPROC_RESERVE_MEM=0 -CONFIG_BROWNOUT_DET=y -CONFIG_BROWNOUT_DET_LVL_SEL_0=y -# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set -CONFIG_BROWNOUT_DET_LVL=0 -CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y -# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL is not set -# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC is not set -# CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set -# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set -# CONFIG_NO_BLOBS is not set -# CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set -# CONFIG_EVENT_LOOP_PROFILING is not set -CONFIG_POST_EVENTS_FROM_ISR=y -CONFIG_POST_EVENTS_FROM_IRAM_ISR=y -# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set -CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y -CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 -CONFIG_ESP_SYSTEM_PD_FLASH=y -# CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND is not set -CONFIG_IPC_TASK_STACK_SIZE=1024 -CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y -# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set -CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 -CONFIG_ESP32_PHY_MAX_TX_POWER=20 -CONFIG_ESP32_REDUCE_PHY_TX_POWER=y -# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set -CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y -# CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set -# CONFIG_ESP32S2_PANIC_GDBSTUB is not set -CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_MAIN_TASK_STACK_SIZE=20584 -CONFIG_CONSOLE_UART_DEFAULT=y -# CONFIG_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_UART_NONE is not set -CONFIG_CONSOLE_UART=y -CONFIG_CONSOLE_UART_NUM=0 -CONFIG_CONSOLE_UART_BAUDRATE=115200 -CONFIG_INT_WDT=y -CONFIG_INT_WDT_TIMEOUT_MS=300 -CONFIG_INT_WDT_CHECK_CPU1=y -CONFIG_TASK_WDT=y -# CONFIG_TASK_WDT_PANIC is not set -CONFIG_TASK_WDT_TIMEOUT_S=5 -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y -# CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set -CONFIG_TIMER_TASK_STACK_SIZE=3584 -# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set -# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set -CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y -CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150 -CONFIG_MB_MASTER_DELAY_MS_CONVERT=200 -CONFIG_MB_QUEUE_LENGTH=20 -CONFIG_MB_SERIAL_TASK_STACK_SIZE=4096 -CONFIG_MB_SERIAL_BUF_SIZE=256 -CONFIG_MB_SERIAL_TASK_PRIO=10 -CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT=y -CONFIG_MB_CONTROLLER_SLAVE_ID=0x00112233 -CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 -CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 -CONFIG_MB_CONTROLLER_STACK_SIZE=4096 -CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 -# CONFIG_MB_TIMER_PORT_ENABLED is not set -CONFIG_MB_TIMER_GROUP=0 -CONFIG_MB_TIMER_INDEX=0 -# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set -CONFIG_TIMER_TASK_PRIORITY=1 -CONFIG_TIMER_TASK_STACK_DEPTH=12048 -CONFIG_TIMER_QUEUE_LENGTH=10 -# CONFIG_L2_TO_L3_COPY is not set -# CONFIG_USE_ONLY_LWIP_SELECT is not set -CONFIG_ESP_GRATUITOUS_ARP=y -CONFIG_GARP_TMR_INTERVAL=60 -CONFIG_TCPIP_RECVMBOX_SIZE=32 -CONFIG_TCP_MAXRTX=12 -CONFIG_TCP_SYNMAXRTX=12 -CONFIG_TCP_MSS=1440 -CONFIG_TCP_MSL=60000 -CONFIG_TCP_SND_BUF_DEFAULT=5744 -CONFIG_TCP_WND_DEFAULT=5744 -CONFIG_TCP_RECVMBOX_SIZE=6 -CONFIG_TCP_QUEUE_OOSEQ=y -# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set -CONFIG_TCP_OVERSIZE_MSS=y -# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set -# CONFIG_TCP_OVERSIZE_DISABLE is not set -CONFIG_UDP_RECVMBOX_SIZE=6 -CONFIG_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set -# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set -CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_PPP_SUPPORT is not set -CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=13072 -CONFIG_ESP32_PTHREAD_STACK_MIN=768 -CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y -# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set -# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set -CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 -CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" -CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y -# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set -# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set -CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y -CONFIG_SUPPORT_TERMIOS=y -CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 -# End of deprecated options diff --git a/Espressif/ESP32/ESP32-SSH-Server/sdkconfig-debug b/Espressif/ESP32/ESP32-SSH-Server/sdkconfig-debug new file mode 100644 index 0000000..e6fa143 --- /dev/null +++ b/Espressif/ESP32/ESP32-SSH-Server/sdkconfig-debug @@ -0,0 +1,532 @@ +# +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_TARGET_ESP8266=y +CONFIG_IDF_TARGET="esp8266" + +# +# SDK tool configuration +# +CONFIG_SDK_TOOLPREFIX="xtensa-lx106-elf-" +CONFIG_SDK_PYTHON="python" +# CONFIG_SDK_MAKE_WARN_UNDEFINED_VARIABLES is not set +CONFIG_BOOTLOADER_INIT_SPI_FLASH=y +# CONFIG_BOOTLOADER_DISABLE_JTAG_IO is not set +# CONFIG_BOOTLOADER_FAST_BOOT is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set +CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y +# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set +CONFIG_LOG_BOOTLOADER_LEVEL=3 +# CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_STORE_OFFSET=0x0 +CONFIG_ESPTOOLPY_PORT="COM55" +CONFIG_ESPTOOLPY_BAUD_115200B=y +# CONFIG_ESPTOOLPY_BAUD_230400B is not set +# CONFIG_ESPTOOLPY_BAUD_921600B is not set +# CONFIG_ESPTOOLPY_BAUD_2MB is not set +# CONFIG_ESPTOOLPY_BAUD_OTHER is not set +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_BAUD=115200 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_FLASHMODE_QIO=y +# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set +# CONFIG_ESPTOOLPY_FLASHMODE_DIO is not set +# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE="dio" +CONFIG_SPI_FLASH_MODE=0x0 +# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set +CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set +# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +CONFIG_ESPTOOLPY_FLASHFREQ="40m" +CONFIG_SPI_FLASH_FREQ=0x0 +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="2MB" +CONFIG_SPI_FLASH_SIZE=0x200000 +CONFIG_ESPTOOLPY_BEFORE_RESET=y +# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_HARD_RESET=y +# CONFIG_ESPTOOLPY_AFTER_SOFT_RESET is not set +# CONFIG_ESPTOOLPY_AFTER_NORESET is not set +CONFIG_ESPTOOLPY_AFTER="hard_reset" +# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_74880B=y +# CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=74880 +CONFIG_ESPTOOLPY_MONITOR_BAUD=74880 +CONFIG_EXAMPLE_GPIO_RANGE_MIN=0 +CONFIG_EXAMPLE_ENC28J60_SPI_HOST=1 +CONFIG_EXAMPLE_ENC28J60_SCLK_GPIO= +CONFIG_EXAMPLE_ENC28J60_MOSI_GPIO= +CONFIG_EXAMPLE_ENC28J60_MISO_GPIO= +CONFIG_EXAMPLE_ENC28J60_CS_GPIO= +CONFIG_EXAMPLE_ENC28J60_SPI_CLOCK_MHZ=8 +CONFIG_EXAMPLE_ENC28J60_INT_GPIO= +# CONFIG_EXAMPLE_ENC28J60_DUPLEX_FULL is not set +CONFIG_EXAMPLE_ENC28J60_DUPLEX_HALF=y +CONFIG_PARTITION_TABLE_SINGLE_APP=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_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" +CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# CONFIG_COMPILER_STACK_CHECK is not set +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +CONFIG_APP_UPDATE_CHECK_APP_SUM=y +# CONFIG_APP_UPDATE_CHECK_APP_HASH is not set +CONFIG_APP_COMPILE_TIME_DATE=y +# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set +# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set +# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set +# CONFIG_ENABLE_COAP is not set +CONFIG_ESP_TLS_USING_MBEDTLS=y +# CONFIG_ESP_TLS_USING_WOLFSSL is not set +# CONFIG_ESP_TLS_SERVER is not set +# CONFIG_ESP_TLS_PSK_VERIFICATION is not set +# CONFIG_ESP_WOLFSSL_INTERNAL is not set +# CONFIG_WOLFSSL_DEBUG is not set +CONFIG_ESP8266_NMI_WDT=y +# CONFIG_ESP8266_XTAL_FREQ_40 is not set +CONFIG_ESP8266_XTAL_FREQ_26=y +CONFIG_ESP8266_XTAL_FREQ=26 +# CONFIG_ESP8266_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP8266_DEFAULT_CPU_FREQ_160=y +CONFIG_ESP8266_DEFAULT_CPU_FREQ_MHZ=160 +CONFIG_ESP_FILENAME_MACRO_NO_PATH=y +# CONFIG_ESP_FILENAME_MACRO_RAW is not set +# CONFIG_ESP_FILENAME_MACRO_NULL is not set +CONFIG_USING_NEW_ETS_VPRINTF=y +# CONFIG_LINK_ETS_PRINTF_TO_IRAM is not set +CONFIG_ETS_PRINTF_EXIT_WHEN_FLASH_RW=y +# CONFIG_SOC_FULL_ICACHE is not set +CONFIG_SOC_IRAM_SIZE=0xC000 +# CONFIG_DISABLE_ROM_UART_PRINT is not set +# CONFIG_ESP_PANIC_PRINT_HALT is not set +CONFIG_ESP_PANIC_PRINT_REBOOT=y +# CONFIG_ESP_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP_PANIC_GDBSTUB is not set +CONFIG_RESET_REASON=y +CONFIG_WIFI_PPT_TASKSTACK_SIZE=5120 +CONFIG_ESP8266_CORE_GLOBAL_DATA_LINK_IRAM=y +# CONFIG_ESP8266_OTA_FROM_OLD is not set +# CONFIG_ESP8266_BOOT_COPY_APP is not set +CONFIG_ESP8266_TIME_SYSCALL_USE_FRC1=y +# CONFIG_ESP8266_TIME_SYSCALL_USE_NONE is not set +# CONFIG_PM_ENABLE is not set +CONFIG_SCAN_AP_MAX=99 +CONFIG_WIFI_TX_RATE_SEQUENCE_FROM_HIGH=y +# CONFIG_ESP8266_WIFI_QOS_ENABLED is not set +# CONFIG_ESP8266_WIFI_AMPDU_RX_ENABLED is not set +# CONFIG_ESP8266_WIFI_AMSDU_ENABLED is not set +CONFIG_ESP8266_WIFI_RX_BUFFER_NUM=16 +CONFIG_ESP8266_WIFI_LEFT_CONTINUOUS_RX_BUFFER_NUM=16 +CONFIG_ESP8266_WIFI_RX_PKT_NUM=7 +CONFIG_ESP8266_WIFI_TX_PKT_NUM=6 +CONFIG_ESP8266_WIFI_NVS_ENABLED=y +CONFIG_ESP8266_WIFI_CONNECT_OPEN_ROUTER_WHEN_PWD_IS_SET=y +CONFIG_ESP8266_WIFI_ENABLE_WPA3_SAE=y +# CONFIG_ESP8266_WIFI_DEBUG_LOG_ENABLE is not set +CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP_PHY_INIT_DATA_VDD33_CONST=33 +CONFIG_ESP8266_PHY_MAX_WIFI_TX_POWER=20 +# CONFIG_ESP8266_HSPI_HIGH_THROUGHPUT is not set +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2048 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 +CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=74880 +# CONFIG_ESP_UART0_SWAP_IO is not set +# CONFIG_ESP_TASK_WDT is not set +# CONFIG_ESP_TASK_WDT_TIMEOUT_13N is not set +# CONFIG_ESP_TASK_WDT_TIMEOUT_14N is not set +CONFIG_ESP_TASK_WDT_TIMEOUT_15N=y +CONFIG_ESP_TASK_WDT_TIMEOUT_S=15 +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set +CONFIG_ESP_EVENT_POST_FROM_ISR=y +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y +# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set +CONFIG_HTTP_BUF_SIZE=512 +CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 +CONFIG_HTTPD_MAX_URI_LEN=512 +CONFIG_OTA_BUF_SIZE=256 +# CONFIG_OTA_ALLOW_HTTP is not set +# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set +CONFIG_FATFS_CODEPAGE_437=y +# CONFIG_FATFS_CODEPAGE_720 is not set +# CONFIG_FATFS_CODEPAGE_737 is not set +# CONFIG_FATFS_CODEPAGE_771 is not set +# CONFIG_FATFS_CODEPAGE_775 is not set +# CONFIG_FATFS_CODEPAGE_850 is not set +# CONFIG_FATFS_CODEPAGE_852 is not set +# CONFIG_FATFS_CODEPAGE_855 is not set +# CONFIG_FATFS_CODEPAGE_857 is not set +# CONFIG_FATFS_CODEPAGE_860 is not set +# CONFIG_FATFS_CODEPAGE_861 is not set +# CONFIG_FATFS_CODEPAGE_862 is not set +# CONFIG_FATFS_CODEPAGE_863 is not set +# CONFIG_FATFS_CODEPAGE_864 is not set +# CONFIG_FATFS_CODEPAGE_865 is not set +# CONFIG_FATFS_CODEPAGE_866 is not set +# CONFIG_FATFS_CODEPAGE_869 is not set +# CONFIG_FATFS_CODEPAGE_932 is not set +# CONFIG_FATFS_CODEPAGE_936 is not set +# CONFIG_FATFS_CODEPAGE_949 is not set +# CONFIG_FATFS_CODEPAGE_950 is not set +CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_LFN_NONE=y +# CONFIG_FATFS_LFN_HEAP is not set +# CONFIG_FATFS_LFN_STACK is not set +CONFIG_FATFS_FS_LOCK=0 +CONFIG_FATFS_TIMEOUT_MS=10000 +CONFIG_FATFS_PER_FILE_CACHE=y +CONFIG_FMB_COMM_MODE_TCP_EN=y +CONFIG_FMB_TCP_PORT_DEFAULT=502 +CONFIG_FMB_TCP_PORT_MAX_CONN=5 +CONFIG_FMB_TCP_CONNECTION_TOUT_SEC=20 +CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_FMB_QUEUE_LENGTH=20 +CONFIG_FMB_PORT_TASK_STACK_SIZE=4096 +CONFIG_FMB_SERIAL_BUF_SIZE=256 +CONFIG_FMB_PORT_TASK_PRIO=10 +CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y +CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233 +CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 +CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_FMB_TIMER_GROUP=0 +CONFIG_FMB_TIMER_INDEX=0 +# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set +# CONFIG_DISABLE_FREERTOS is not set +CONFIG_FREERTOS_UNICORE=y +# CONFIG_FREERTOS_ENABLE_REENT is not set +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_HZ=1000 +CONFIG_FREERTOS_MAX_HOOK=2 +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024 +CONFIG_FREERTOS_ISR_STACKSIZE=512 +# CONFIG_FREERTOS_EXTENED_HOOKS is not set +CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y +# CONFIG_FREERTOS_CODE_LINK_TO_IRAM is not set +CONFIG_FREERTOS_TIMER_STACKSIZE=2048 +CONFIG_TASK_SWITCH_FASTER=y +# CONFIG_USE_QUEUE_SETS is not set +# CONFIG_ENABLE_FREERTOS_SLEEP is not set +# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set +# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y +# CONFIG_HEAP_DISABLE_IRAM is not set +# CONFIG_HEAP_TRACING is not set +CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set +# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set +# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_COLORS=y +# CONFIG_LOG_SET_LEVEL is not set +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# CONFIG_LWIP_L2_TO_L3_COPY is not set +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set +CONFIG_LWIP_TIMERS_ONDEMAND=y +CONFIG_LWIP_MAX_SOCKETS=10 +# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +# CONFIG_LWIP_SO_LINGER is not set +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y +# CONFIG_LWIP_SO_RCVBUF is not set +# CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP4_FRAG=y +CONFIG_LWIP_IP6_FRAG=y +# CONFIG_LWIP_IP4_REASSEMBLY is not set +# CONFIG_LWIP_IP6_REASSEMBLY is not set +# CONFIG_LWIP_IP_FORWARD is not set +# CONFIG_LWIP_STATS is not set +# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set +CONFIG_LWIP_ESP_GRATUITOUS_ARP=y +CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# CONFIG_LWIP_AUTOIP is not set +# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 +CONFIG_LWIP_MAX_ACTIVE_TCP=16 +CONFIG_LWIP_MAX_LISTENING_TCP=16 +CONFIG_LWIP_TCP_MAXRTX=12 +CONFIG_LWIP_TCP_SYNMAXRTX=6 +CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_TMR_INTERVAL=250 +CONFIG_LWIP_TCP_MSL=60000 +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=2880 +CONFIG_LWIP_TCP_WND_DEFAULT=5760 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +# CONFIG_LWIP_TCP_SACK_OUT is not set +# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_LWIP_TCP_OVERSIZE_MSS=y +# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set +CONFIG_LWIP_TCP_RTO_TIME=3000 +CONFIG_LWIP_MAX_UDP_PCBS=16 +CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2048 +CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_LWIP_PPP_SUPPORT is not set +CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 +CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# CONFIG_LWIP_MULTICAST_PING is not set +# CONFIG_LWIP_BROADCAST_PING is not set +CONFIG_LWIP_MAX_RAW_PCBS=16 +# CONFIG_LWIP_IPV6 is not set +CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +CONFIG_LWIP_ESP_LWIP_ASSERT=y +# CONFIG_LWIP_DEBUG is not set +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set +# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 +# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# CONFIG_MBEDTLS_DEBUG is not set +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y +# CONFIG_MBEDTLS_PSK_MODES is not set +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +CONFIG_MBEDTLS_RC4_DISABLED=y +# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set +# CONFIG_MBEDTLS_RC4_ENABLED is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# CONFIG_MBEDTLS_RIPEMD160_C is not set +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y +# CONFIG_util_assert is not set +# CONFIG_ESP_SHA is not set +CONFIG_ESP_AES=y +CONFIG_ESP_MD5=y +CONFIG_ESP_ARC4=y +# CONFIG_ENABLE_MDNS is not set +CONFIG_MQTT_PROTOCOL_311=y +CONFIG_MQTT_TRANSPORT_SSL=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y +# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set +# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set +# CONFIG_MQTT_CUSTOM_OUTBOX is not set +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_NANO_FORMAT is not set +# CONFIG_OPENSSL_DEBUG is not set +CONFIG_OPENSSL_ASSERT_DO_NOTHING=y +# CONFIG_OPENSSL_ASSERT_EXIT is not set +CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 +CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" +CONFIG_SPIFFS_MAX_PARTITIONS=3 +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +# CONFIG_SPIFFS_CACHE_STATS is not set +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +# CONFIG_SPIFFS_GC_STATS is not set +CONFIG_SPIFFS_PAGE_SIZE=256 +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y +# CONFIG_SPIFFS_DBG is not set +# CONFIG_SPIFFS_API_DBG is not set +# CONFIG_SPIFFS_GC_DBG is not set +# CONFIG_SPIFFS_CACHE_DBG is not set +# CONFIG_SPIFFS_CHECK_DBG is not set +# CONFIG_SPIFFS_TEST_VISUALISATION is not set +CONFIG_IP_LOST_TIMER_INTERVAL=120 +CONFIG_TCPIP_ADAPTER_GLOBAL_DATA_LINK_IRAM=y +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_VFS_SUPPORT_TERMIOS=y +CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# CONFIG_WL_SECTOR_SIZE_512 is not set +CONFIG_WL_SECTOR_SIZE_4096=y +CONFIG_WL_SECTOR_SIZE=4096 +# CONFIG_ENABLE_UNIFIED_PROVISIONING is not set +CONFIG_LTM_FAST=y +CONFIG_WPA_MBEDTLS_CRYPTO=y +# CONFIG_WPA_DEBUG_PRINT is not set +# CONFIG_WPA_TESTING_OPTIONS is not set +# CONFIG_WPA_WPS_WARS is not set +# CONFIG_WPA_11KV_SUPPORT is not set + +# Deprecated options for backward compatibility +CONFIG_TARGET_PLATFORM="esp8266" +CONFIG_TOOLPREFIX="xtensa-lx106-elf-" +# CONFIG_MAKE_WARN_UNDEFINED_VARIABLES is not set +CONFIG_FLASHMODE_QIO=y +# CONFIG_FLASHMODE_QOUT is not set +# CONFIG_FLASHMODE_DIO is not set +# CONFIG_FLASHMODE_DOUT is not set +# CONFIG_MONITOR_BAUD_9600B is not set +# CONFIG_MONITOR_BAUD_57600B is not set +CONFIG_MONITOR_BAUD_74880B=y +# CONFIG_MONITOR_BAUD_115200B is not set +# CONFIG_MONITOR_BAUD_230400B is not set +# CONFIG_MONITOR_BAUD_921600B is not set +# CONFIG_MONITOR_BAUD_2MB is not set +# CONFIG_MONITOR_BAUD_OTHER is not set +CONFIG_MONITOR_BAUD_OTHER_VAL=74880 +CONFIG_MONITOR_BAUD=74880 +CONFIG_OPTIMIZATION_LEVEL_DEBUG=y +# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set +CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y +# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +# CONFIG_CXX_EXCEPTIONS is not set +CONFIG_STACK_CHECK_NONE=y +# CONFIG_STACK_CHECK_NORM is not set +# CONFIG_STACK_CHECK_STRONG is not set +# CONFIG_STACK_CHECK_ALL is not set +# CONFIG_STACK_CHECK is not set +# CONFIG_WARN_WRITE_STRINGS is not set +CONFIG_MAIN_TASK_STACK_SIZE=3584 +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=74880 +# CONFIG_UART0_SWAP_IO is not set +# CONFIG_TASK_WDT is not set +CONFIG_TASK_WDT_TIMEOUT_S=15 +CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_MB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_MB_QUEUE_LENGTH=20 +CONFIG_MB_SERIAL_TASK_STACK_SIZE=4096 +CONFIG_MB_SERIAL_BUF_SIZE=256 +CONFIG_MB_SERIAL_TASK_PRIO=10 +CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT=y +CONFIG_MB_CONTROLLER_SLAVE_ID=0x00112233 +CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_MB_CONTROLLER_STACK_SIZE=4096 +CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_MB_TIMER_GROUP=0 +CONFIG_MB_TIMER_INDEX=0 +# CONFIG_L2_TO_L3_COPY is not set +# CONFIG_USE_ONLY_LWIP_SELECT is not set +CONFIG_ESP_GRATUITOUS_ARP=y +CONFIG_GARP_TMR_INTERVAL=60 +CONFIG_TCPIP_RECVMBOX_SIZE=32 +CONFIG_TCP_MAXRTX=12 +CONFIG_TCP_SYNMAXRTX=6 +CONFIG_TCP_MSS=1440 +CONFIG_TCP_MSL=60000 +CONFIG_TCP_SND_BUF_DEFAULT=2880 +CONFIG_TCP_WND_DEFAULT=5760 +CONFIG_TCP_RECVMBOX_SIZE=6 +CONFIG_TCP_QUEUE_OOSEQ=y +# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_TCP_OVERSIZE_MSS=y +# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_TCP_OVERSIZE_DISABLE is not set +CONFIG_UDP_RECVMBOX_SIZE=6 +CONFIG_TCPIP_TASK_STACK_SIZE=2048 +CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set +CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_PPP_SUPPORT is not set +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_SUPPORT_TERMIOS=y +# End of deprecated options diff --git a/Espressif/ESP32/ESP32-SSH-Server/sdkconfig.defaults b/Espressif/ESP32/ESP32-SSH-Server/sdkconfig.defaults index e9f32fd..68d148f 100644 --- a/Espressif/ESP32/ESP32-SSH-Server/sdkconfig.defaults +++ b/Espressif/ESP32/ESP32-SSH-Server/sdkconfig.defaults @@ -1 +1,60 @@ -CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n +# 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 +CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y + +# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n +# +# Default main stack size +# +# This is typically way bigger than needed for stack size. See user_settings.h +# +CONFIG_ESP_MAIN_TASK_STACK_SIZE=5500 + +# Legacy stack size for older ESP-IDF versions +CONFIG_MAIN_TASK_STACK_SIZE=5500 + +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 +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 + +# debugging: these should NOT be required, but currently are: +# CONFIG_COMPILER_OPTIMIZATION_SIZE=y + +# CONFIG_CXX_EXCEPTIONS=y +# CONFIG_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 +# CONFIG_STACK_CHECK_ALL=y +# CONFIG_COMPILER_CXX_EXCEPTIONS=y +# CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0 +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL=y +CONFIG_HEAP_POISONING_COMPREHENSIVE=y + +# no default? y from found error file +CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=n + +# Disable CONFIG_STACK_CHECK_ALL and CONFIG_COMPILER_STACK_CHECK_MODE_ALL +# for error + +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=4096 +CONFIG_PTHREAD_STACK_MIN=1768 \ No newline at end of file diff --git a/Espressif/ESP32/lib/README.md b/Espressif/ESP32/lib/README.md new file mode 100644 index 0000000..7fe189b --- /dev/null +++ b/Espressif/ESP32/lib/README.md @@ -0,0 +1,5 @@ +# Example lib files: wolfssh-examples/Espressif/ESP32/lib + +This directory contains known-working, default example files. + +- [user_settings.h](./user_settings.h) diff --git a/Espressif/ESP32/lib/user_settings.h b/Espressif/ESP32/lib/user_settings.h new file mode 100644 index 0000000..02ec2ae --- /dev/null +++ b/Espressif/ESP32/lib/user_settings.h @@ -0,0 +1,589 @@ +/* user_settings.h (this is a special file specifically for ESP SSH to UART) + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +#include "sdkconfig.h" /* essential to chip set detection */ + +#undef WOLFSSL_ESPIDF +#undef WOLFSSL_ESP32 +#undef WOLFSSL_ESPWROOM32SE +#undef WOLFSSL_ESP32 +#undef WOLFSSL_ESP8266 + +#define WOLFSSL_ESPIDF + +#define DEBUG_WOLFSSH + +/* The Espressif sdkconfig will have chipset info. +** +** Possible values: +** +** CONFIG_IDF_TARGET_ESP32 +** CONFIG_IDF_TARGET_ESP32S2 +** CONFIG_IDF_TARGET_ESP32S3 +** CONFIG_IDF_TARGET_ESP32C3 +** CONFIG_IDF_TARGET_ESP32C6 +*/ +#define ESP_ENABLE_WOLFSSH +/* Optionally enable some wolfSSH settings */ + +#ifdef ESP_ENABLE_WOLFSSH + /* The default SSH Windows size is massive for an embedded target. Limit it: */ + #define DEFAULT_WINDOW_SZ 2000 + + /* These may be defined in cmake for other examples: */ + #undef WOLFSSH_TERM + #define WOLFSSH_TERM + + #undef DEBUG_WOLFSSH + #define DEBUG_WOLFSSH + + #undef WOLFSSL_KEY_GEN + #define WOLFSSL_KEY_GEN + + #undef WOLFSSL_PTHREADS + #define WOLFSSL_PTHREADS + + #define WOLFSSH_TEST_SERVER + + /* optional threading test code can be enabled: */ + /* #define WOLFSSH_TEST_THREADING */ + + /* The "no file system" for wolfSSL */ + #undef NO_FILESYSTEM + #define NO_FILESYSTEM + + /* The "no file system" for wolfSSH */ + #undef WOLFSSH_NO_FILESYSTEM + #define WOLFSSH_NO_FILESYSTEM + + /* WOLFSSL_NONBLOCK is a value assigned to threadCtx->nonBlock + * and should be a value 1 or 0 + */ + #define WOLFSSL_NONBLOCK 1 + + #ifndef WOLFSSL_FULL_WOLFSSH_SUPPORT + /* wolfSSL 5.6.6 SHA256 HW not supported with wolfSSH */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA256 + #endif +#endif /* ESP_ENABLE_WOLFSSH */ + +/* when you want to use SINGLE THREAD. Note Default ESP-IDF is FreeRTOS */ +/* TODO: previously saw depth mismatch when disabling SINGLE_THREADED ? + * (but putty cannot connect: server host key invalid when defined) + * fails for both `WOLFSSL_NONBLOCK 0` or `WOLFSSL_NONBLOCK 1` */ +#define SINGLE_THREADED + +/* Need to increase pthread stack size when using WOLFSSH_TEST_THREADING */ +/* Minimum defined size should be 20096, but not in SINGLE_THREADED */ +/* #define WOLFSSH_TEST_THREADING */ + +#if defined(WOLFSSH_TEST_THREADING) && defined(SINGLE_THREADED) + #error "Cannot enable both WOLFSSH_TEST_THREADING and SINGLE_THREADED" +#endif + +/* + * choose ONE of these Espressif chips to define: + * + * WOLFSSL_ESP32 + * WOLFSSL_ESPWROOM32SE + * WOLFSSL_ESP8266 + */ + +#define WOLFSSL_ESP32 + +/* optionally turn off SHA512/224 SHA512/256 */ +/* #define WOLFSSL_NOSHA512_224 */ +/* #define WOLFSSL_NOSHA512_256 */ + +/* When you don't want to use the old SHA */ +/* #define NO_SHA */ +/* #define NO_OLD_TLS */ + +#define BENCH_EMBEDDED + +#define NO_OLD_TLS + +/* TLS 1.3 */ +/* #define MY_USE_TLS13 */ +#ifdef MY_USE_TLS13 + #define WOLFSSL_TLS13 + #define HAVE_TLS_EXTENSIONS + #define WC_RSA_PSS + #define HAVE_SUPPORTED_CURVES + #define HAVE_FFDHE_2048 + + /* or one of the other supported FFDHE sizes [2048, 3072, 4096, 6144, 8192] */ + /* #define HAVE_FFDHE_8192 */ + +#endif +#define HAVE_HKDF +#define HAVE_AEAD + +/* note "file system": "load keys and certificate from files" vs NO_FILESYSTEM + * and "access an actual file system via SFTP/SCP" vs WOLFSSH_NO_FILESYSTEM + * we'll typically have neither on an embedded device: + */ +#define NO_FILESYSTEM + +#define HAVE_AESGCM + +#define WOLFSSL_RIPEMD +/* when you want to use SHA224 */ +/* #define WOLFSSL_SHA224 */ + +/* when you want to use SHA384 */ +/* #define WOLFSSL_SHA384 */ + +/* #define WOLFSSL_SHA3 */ + +#define MY_USE_ECC 1 +#define MY_USE_RSA 0 + +/* Define DEMO_SERVER_384 to use ecdsa-sha2-nistp384 + * if DEMO_SERVER_384 is not defined then ecdsa-sha2-nistp256 is default. */ +/* #define DEMO_SERVER_384 */ + +/* We can use either or both ECC and RSA, but must use at least one. */ +/* RSA not yet implemented for SSH to UART demo */ +#if MY_USE_ECC || MY_USE_RSA + #if MY_USE_ECC + /* ---- ECDSA / ECC ---- */ + #define HAVE_ECC + #define HAVE_CURVE25519 + #define HAVE_ED25519 + /* ED25519 requires SHA512 */ + #undef WOLFSSL_SHA512 + #define WOLFSSL_SHA512 + + /* + #define HAVE_ECC384 + #define CURVE25519_SMALL + */ + + #ifdef DEMO_SERVER_384 + /* we'll connect with ecdsa-sha2-nistp384 */ + /* confirmed working with both HW / SW ESP32 wolfcrypt */ + + /* First, we need to force off the [ECDH/ECDSA]'NISTP256 items */ + #define WOLFSSH_NO_ECDH_SHA2_NISTP256 + #define WOLFSSH_NO_ECDSA_SHA2_NISTP256 + /* SHA256 still needed */ + + #define WOLFSSL_SHA384 + #define HAVE_ECC384 + + /* TODO confirm these are needed: */ + #define WOLFSSL_SHA512 + #define HAVE_ECC521 + + #else + /* default ecdsa-sha2-nistp256 needs no special settings */ + + /* TODO: SHA256 HW enabled causes error: + * "signature from server's host key is invalid + * + * Software SHA256 works. + */ + #endif + #else + /* Warning: only ECC implemented for SSH UART demo at this time */ + #define WOLFSSH_NO_ECC + /* WOLFSSH_NO_ECDSA is typically defined automatically, + * here for clarity: */ + #define WOLFSSH_NO_ECDSA + #endif + + #if MY_USE_RSA + /* Warning: RSA not implemented for SSH UART demo at this time */ + + /* ---- RSA ----- */ + /* #define RSA_LOW_MEM */ + + /* DH disabled by default, needed if ECDSA/ECC also turned off */ + #define HAVE_DH + + /* WC_RSA_PSS */ + #else + #undef WOLFSSH_NO_RSA + #define WOLFSSH_NO_RSA + + #undef NO_RSA + #define NO_RSA + #endif +#else + #error "Either RSA or ECC must be enabled" +#endif + + +/* when you want to use pkcs7 */ +/* #define HAVE_PKCS7 */ + +#if defined(HAVE_PKCS7) + #define HAVE_AES_KEYWRAP + #define HAVE_X963_KDF + #define WOLFSSL_AES_DIRECT +#endif + +/* when you want to use aes counter mode */ +/* #define WOLFSSL_AES_DIRECT */ +/* #define WOLFSSL_AES_COUNTER */ + +/* debug options */ +/* #define DEBUG_WOLFSSL */ +/* #define WOLFSSL_ESP32_CRYPT_DEBUG */ +/* #define WOLFSSL_ATECC508A_DEBUG */ + +/* date/time */ +/* if it cannot adjust time in the device, */ +/* enable macro below */ +/* #define NO_ASN_TIME */ +/* #define XTIME time */ + +/* adjust wait-timeout count if you see timeout in RSA HW acceleration */ +#define ESP_RSA_TIMEOUT_CNT 0x249F00 + + +/* USE_FAST_MATH is default */ +#define USE_FAST_MATH + +/***** Use SP_MATH *****/ +/* #undef USE_FAST_MATH */ +/* #define SP_MATH */ +/* #define WOLFSSL_SP_MATH_ALL */ +/* #define WOLFSSL_SP_RISCV32 */ + +/***** Use Integer Heap Math *****/ +/* #undef USE_FAST_MATH */ +/* #define USE_INTEGER_HEAP_MATH */ + + +#define WOLFSSL_SMALL_STACK + +/* The ESP32 has some detailed statup information available:*/ +#define HAVE_VERSION_EXTENDED_INFO + +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm */ +/* +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + /* SM settings, possible cipher suites: + + TLS13-AES128-GCM-SHA256 + TLS13-CHACHA20-POLY1305-SHA256 + TLS13-SM4-GCM-SM3 + TLS13-SM4-CCM-SM3 + + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CBC-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-GCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "ECDHE-ECDSA-SM4-CCM-SM3" + #define WOLFSSL_ESP32_CIPHER_SUITE "TLS13-SM4-GCM-SM3:" \ + "TLS13-SM4-CCM-SM3:" + */ + + /* WOLFSSL_BASE16 required for WOLFSSL_SM2 */ + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 + + #undef WOLFSSL_SM4_ECB + #define WOLFSSL_SM4_ECB + + #undef WOLFSSL_SM4_CBC + #define WOLFSSL_SM4_CBC + + #undef WOLFSSL_SM4_CTR + #define WOLFSSL_SM4_CTR + + #undef WOLFSSL_SM4_GCM + #define WOLFSSL_SM4_GCM + + #undef WOLFSSL_SM4_CCM + #define WOLFSSL_SM4_CCM + + #define HAVE_POLY1305 + #define HAVE_CHACHA + + #undef HAVE_AESGCM + #define HAVE_AESGCM +#else + /* default settings */ +#endif + +/* esp32-wroom-32se specific definition */ +#if defined(WOLFSSL_ESPWROOM32SE) + #define WOLFSSL_ATECC508A + #define HAVE_PK_CALLBACKS + /* when you want to use a custom slot allocation for ATECC608A */ + /* unless your configuration is unusual, you can use default */ + /* implementation. */ + /* #define CUSTOM_SLOT_ALLOCATION */ +#endif + +/* Default is HW enabled unless turned off. +** Uncomment these lines to force SW instead of HW acceleration */ +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(WOLFSSL_ESPWROOM32SE) + /* wolfSSL HW Acceleration supported on ESP32. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + + /* These are defined automatically in esp32-crypt.h, here for clarity: */ + /* no SHA224 HW on ESP32 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA224 + + /* Define USE_FAST_MATH and SMALL_STACK */ + #define ESP32_USE_RSA_PRIMITIVE + + /* threshold for performance adjustment for HW primitive use */ + /* X bits of G^X mod P greater than */ + #define EPS_RSA_EXPT_XBTIS 32 + + /* X and Y of X * Y mod P greater than */ + #undef ESP_RSA_MULM_BITS + #define ESP_RSA_MULM_BITS 16 + + /***** END CONFIG_IDF_TARGET_ESP32 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32S2) + /* wolfSSL HW Acceleration supported on ESP32-S2. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* Note: There's no AES192 HW on the ESP32-S2; falls back to SW */ + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32S2 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32S3) + /* wolfSSL HW Acceleration supported on ESP32-S3. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* Note: There's no AES192 HW on the ESP32-S3; falls back to SW */ + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32S3 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32C2) || \ + defined(CONFIG_IDF_TARGET_ESP8684) + /* ESP8684 is essentially ESP32-C2 chip + flash embedded together in a + * single QFN 4x4 mm package. Out of released documentation, Technical + * Reference Manual as well as ESP-IDF Programming Guide is applicable + * to both ESP32-C2 and ESP8684. + * + * See: https://www.esp32.com/viewtopic.php?f=5&t=27926#:~:text=ESP8684%20is%20essentially%20ESP32%2DC2,both%20ESP32%2DC2%20and%20ESP8684. */ + + /* wolfSSL HW Acceleration supported on ESP32-C2. Uncomment to disable: */ + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ /* to disable all SHA HW */ + + /* These are defined automatically in esp32-crypt.h, here for clarity */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C2 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C2 */ + + /* There's no AES or RSA/Math accelerator on the ESP32-C2 + * Auto defined with NO_WOLFSSL_ESP32_CRYPT_RSA_PRI, for clarity: */ + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD + /***** END CONFIG_IDF_TARGET_ESP32C2 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32C3) + /* wolfSSL HW Acceleration supported on ESP32-C3. Uncomment to disable: */ + + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ /* to disable all SHA HW */ + + /* These are defined automatically in esp32-crypt.h, here for clarity: */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C6 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C6 */ + + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32C3 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32C6) + /* wolfSSL HW Acceleration supported on ESP32-C6. Uncomment to disable: */ + + /* #define NO_ESP32_CRYPT */ + /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ + /* These are defined automatically in esp32-crypt.h, here for clarity: */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA384 /* no SHA384 HW on C6 */ + #define NO_WOLFSSL_ESP32_CRYPT_HASH_SHA512 /* no SHA512 HW on C6 */ + + /* #define NO_WOLFSSL_ESP32_CRYPT_AES */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + /* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + /***** END CONFIG_IDF_TARGET_ESP32C6 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP32H2) + /* wolfSSL Hardware Acceleration not yet implemented */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + /***** END CONFIG_IDF_TARGET_ESP32H2 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP8266) + /* TODO: Revisit ESP8266 */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + /***** END CONFIG_IDF_TARGET_ESP266 *****/ + +#elif defined(CONFIG_IDF_TARGET_ESP8684) + /* There's no Hardware Acceleration available on ESP8684 */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI + /***** END CONFIG_IDF_TARGET_ESP8684 *****/ + +#else + /* Anything else encountered, disable HW accleration */ + #define NO_ESP32_CRYPT + #define NO_WOLFSSL_ESP32_CRYPT_HASH + #define NO_WOLFSSL_ESP32_CRYPT_AES + #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI +#endif /* CONFIG_IDF_TARGET Check */ + +/* Debug options: + +#define ESP_VERIFY_MEMBLOCK +#define DEBUG_WOLFSSL +#define DEBUG_WOLFSSL_VERBOSE +#define DEBUG_WOLFSSL_SHA_MUTEX +#define WOLFSSL_ESP32_CRYPT_DEBUG +#define WOLFSSL_ESP32_CRYPT_HASH_SHA224_DEBUG +#define NO_RECOVER_SOFTWARE_CALC +#define WOLFSSL_TEST_STRAY 1 +#define USE_ESP_DPORT_ACCESS_READ_BUFFER +#define WOLFSSL_ESP32_HW_LOCK_DEBUG +#define WOLFSSL_DEBUG_ESP_RSA_MULM_BITS +#define ESP_DISABLE_HW_TASK_LOCK +*/ + +/* Pause in a loop rather than exit. */ +#define WOLFSSL_ESPIDF_ERROR_PAUSE + +/* #define WOLFSSL_HW_METRICS */ + +/* for test.c */ +/* #define HASH_SIZE_LIMIT */ + +/* Optionally turn off HW math checks */ +/* #define NO_HW_MATH_TEST */ + +/* Optionally include alternate HW test library: alt_hw_test.h */ +/* When enabling, the ./components/wolfssl/CMakeLists.txt file + * will need the name of the library in the idf_component_register + * for the PRIV_REQUIRES list. */ +/* #define INCLUDE_ALT_HW_TEST */ + +/* optionally turn off individual math HW acceleration features */ + +/* Turn off Large Number ESP32 HW Multiplication: +** [Z = X * Y] in esp_mp_mul() */ +/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MP_MUL */ + +/* Turn off Large Number ESP32 HW Modular Exponentiation: +** [Z = X^Y mod M] in esp_mp_exptmod() */ +/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_EXPTMOD */ + +/* Turn off Large Number ESP32 HW Modular Multiplication +** [Z = X * Y mod M] in esp_mp_mulmod() */ +/* #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI_MULMOD */ + +#define WOLFSSL_PUBLIC_MP /* used by benchmark */ + +/* when turning on ECC508 / ECC608 support +#define WOLFSSL_ESPWROOM32SE +#define HAVE_PK_CALLBACKS +#define WOLFSSL_ATECC508A +#define ATCA_WOLFSSL +*/ + +/* optional SM4 Ciphers. See https://github.com/wolfSSL/wolfsm +#define WOLFSSL_SM2 +#define WOLFSSL_SM3 +#define WOLFSSL_SM4 +*/ + +#if defined(WOLFSSL_SM2) || defined(WOLFSSL_SM3) || defined(WOLFSSL_SM4) + #include + #define CTX_CA_CERT root_sm2 + #define CTX_CA_CERT_SIZE sizeof_root_sm2 + #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_PEM + #define CTX_SERVER_CERT server_sm2 + #define CTX_SERVER_CERT_SIZE sizeof_server_sm2 + #define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_PEM + #define CTX_SERVER_KEY server_sm2_priv + #define CTX_SERVER_KEY_SIZE sizeof_server_sm2_priv + #define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_PEM + + #undef WOLFSSL_BASE16 + #define WOLFSSL_BASE16 +#else + #define USE_CERT_BUFFERS_2048 + #define USE_CERT_BUFFERS_256 + #define CTX_CA_CERT ca_cert_der_2048 + #define CTX_CA_CERT_SIZE sizeof_ca_cert_der_2048 + #define CTX_CA_CERT_TYPE WOLFSSL_FILETYPE_ASN1 + #define CTX_SERVER_CERT server_cert_der_2048 + #define CTX_SERVER_CERT_SIZE sizeof_server_cert_der_2048 + #define CTX_SERVER_CERT_TYPE WOLFSSL_FILETYPE_ASN1 + #define CTX_SERVER_KEY server_key_der_2048 + #define CTX_SERVER_KEY_SIZE sizeof_server_key_der_2048 + #define CTX_SERVER_KEY_TYPE WOLFSSL_FILETYPE_ASN1 +#endif + +/* See settings.h for some of the possible hardening options: + * + * #define NO_ESPIDF_DEFAULT + * #define WC_NO_CACHE_RESISTANT + * #define WC_AES_BITSLICED + * #define HAVE_AES_ECB + * #define HAVE_AES_DIRECT + */ + +/* Custom stack check (experimental) */ +#define WOLFSSL_STACK_CHECK diff --git a/Espressif/README.md b/Espressif/README.md new file mode 100644 index 0000000..7e85082 --- /dev/null +++ b/Espressif/README.md @@ -0,0 +1,14 @@ +# Example wolfSSH Projects for Espressif + +In addition to the [core wolfSSL examples for Espressif](https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif), +here are additional examples: + +- [SSH to UART for ESP32](./Espressif/ESP32/ESP32-SSH-Server/README.md) +- [SSH to UART for ESP8266](./Espressif/ESP8266/ESP8266-SSH-Server) + +## Getting Started + +If you are new to wolfSSL on the Espressif ESP32, [this video](https://www.youtube.com/watch?v=CzwA3ZBZBZ8) +can help to get started: + +[![Video Preview](https://img.youtube.com/vi/CzwA3ZBZBZ8/0.jpg)](https://www.youtube.com/watch?v=CzwA3ZBZBZ8)