diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile index 225e88d6f2..45d4b1d264 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/Makefile @@ -1,28 +1,127 @@ +# ESP8266 Project Makefile for wolfssl_client +# +# Copyright (C) 2006-2024 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 +# + # # This is a project Makefile. # It is assumed the directory this Makefile resides in is a # project subdirectory containing an entire project. # - +# Optional private config headers. Define environment variables +# to include various default header files that are typically +# not in a git path, and thus excluded from being checked in. +# +# Environment Variable Name | Header file name included +# ---------------------------------- | --------------------------------------- +# MY_PRIVATE_CONFIG (files detected / selected in header) +# USE_MY_PRIVATE_WSL_CONFIG /mnt/c/workspace/my_private_config.h +# USE_MY_PRIVATE_MAC_CONFIG ~/Documents/my_private_config.h +# USE_MY_PRIVATE_LINUX_CONFIG ~/workspace/my_private_config.h +# USE_MY_PRIVATE_WINDOWS_CONFIG /workspace/my_private_config.h +# +# PROJECT_NAME := wolfssl_client -# Calling shell causes unintuiive error in Windows: +MY_PRIVATE_CONFIG ?= n +USE_MY_PRIVATE_WSL_CONFIG ?= n +USE_MY_PRIVATE_MAC_CONFIG ?= n +USE_MY_PRIVATE_LINUX_CONFIG ?= n +USE_MY_PRIVATE_WINDOWS_CONFIG ?= n + +# Calling shell causes unintuitive error in Windows: # OS := $(shell uname -s) -# But OS should already be defined: -ifeq ($(OS),Linux) - CFLAGS += -DOS_LINUX +# +# But OS, or MY_PRIVATE_CONFIG should already be defined: +$(info ************* wolfssl_client *************) + +ifeq ($(MY_PRIVATE_CONFIG),y) + CFLAGS += -DMY_PRIVATE_CONFIG + $(info Enabled MY_PRIVATE_CONFIG") +endif + +# Check for Windows environment variable: USE_MY_PRIVATE_WINDOWS_CONFIG +ifeq ($(USE_MY_PRIVATE_WINDOWS_CONFIG),y) + # This hard coded MY_CONFIG_FILE value must match that in the header file. + MY_CONFIG_FILE := /workspace/my_private_config.h + ifeq ($(wildcard $(MY_CONFIG_FILE)),) + $(info File does not exist: $(MY_CONFIG_FILE)) + else + CFLAGS += -DUSE_MY_PRIVATE_WINDOWS_CONFIG + $(info Using private config file for: Windows) + endif endif -ifeq ($(OS),Windows_NT) - CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_WINDOWS + +# Check for WSL environment variable: USE_MY_PRIVATE_WSL_CONFIG +ifeq ($(USE_MY_PRIVATE_WSL_CONFIG),y) + # This hard coded MY_CONFIG_FILE value must match that in the header file. + MY_CONFIG_FILE := /mnt/c/workspace/my_private_config.h + ifeq ($(wildcard $(MY_CONFIG_FILE)),) + $(info File does not exist: $(MY_CONFIG_FILE)) + else + CFLAGS += -DUSE_MY_PRIVATE_WSL_CONFIG + $(info Using private config file for: WSL) + endif endif -ifeq ($(OS),Darwin) - CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_APPLE + +# Check for Linux environment variable: USE_MY_PRIVATE_LINUX_CONFIG +ifeq ($(USE_MY_PRIVATE_LINUX_CONFIG),y) + # This hard coded MY_CONFIG_FILE value must match that in the header file. + MY_CONFIG_FILE := ~/workspace/my_private_config.h + ifeq ($(wildcard $(MY_CONFIG_FILE)),) + $(info File does not exist: $(MY_CONFIG_FILE)) + else + CFLAGS += -DUSE_MY_PRIVATE_LINUX_CONFIG + $(info Using private config file for: Linux) + endif endif -ifneq (,$(findstring MINGW,$(OS))) - CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_MINGW + +# Check for Mac environment variable: USE_MY_PRIVATE_MAC_CONFIG +ifeq ($(USE_MY_PRIVATE_MAC_CONFIG),y) + # This hard coded MY_CONFIG_FILE value must match that in the header file. + MY_CONFIG_FILE := ~/Documents/my_private_config.h + ifeq ($(wildcard $(MY_CONFIG_FILE)),) + $(info File does not exist: $(MY_CONFIG_FILE)) + else + CFLAGS += -DUSE_MY_PRIVATE_MAC_CONFIG + $(info Using private config file for: Mac) + endif endif -ifneq (,$(findstring CYGWIN,$(OS))) - CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_CYGWIN + +ifneq ($(OS),MY_PRIVATE_CONFIG) + CFLAGS += -DMY_PRIVATE_CONFIG="$(MY_PRIVATE_CONFIG)" +else + ifeq ($(OS),Linux) + CFLAGS += -DOS_LINUX + endif + ifeq ($(OS),Windows_NT) + CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_WINDOWS + endif + ifeq ($(OS),Darwin) + CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_APPLE + endif + ifneq (,$(findstring MINGW,$(OS))) + CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_MINGW + endif + ifneq (,$(findstring CYGWIN,$(OS))) + CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_CYGWIN + endif endif # It is essential that the build process sees the WOLFSSL_USER_SETTINGS @@ -31,4 +130,5 @@ CFLAGS += -DWOLFSSL_USER_SETTINGS # if directory not available, please disable the line below. EXTRA_COMPONENT_DIRS = $(IDF_PATH)/examples/common_components/protocol_examples_common +# The Standard Espressif IDF include: include $(IDF_PATH)/make/project.mk diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md index c6667b5338..1bfd0cc88c 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md @@ -26,6 +26,15 @@ The latest examples use makefiles that do not require local file copy installati Build and flash the software to see the example in action. +## Quick Start with VisualGDB + +There are optional [VisualGDB](https://visualgdb.com/tutorials/esp8266/) project files in the +[VisualGDB](./VisualGDB) project subdirectory, and an ESP8266 project file in the project directory, +called `wolfssl_client_ESP8266.vgdbproj`. + +Open the VisualGDB Visual Studio Project file in the VisualGDB directory and click the "Start" button. +No wolfSSL setup is needed. You may need to adjust your specific COM port. The default is `COM19`. + ## Troubleshooting Weird results, odd messages, unexpected compiler errors? Manually delete the build directory and @@ -33,11 +42,6 @@ any locally generated files (`sdkconfig`, `sdkconfig-debug`, etc.) and start ove The `build` directory is typically located in the root of the project directory: `[project]/build`. -For Windows Arduino users, there is the set of hash-named directories located here: - -```text -C:\Users\%USERNAME%\AppData\Local\Temp\arduino\sketches -``` Difficulty flashing: @@ -47,11 +51,6 @@ Difficulty flashing: * Review board specifications: some require manual boot mode via on-board buttons. * See [Espressif ESP Frequently Asked Questions](https://docs.espressif.com/projects/esp-faq/en/latest/esp-faq-en-master.pdf) -## VisualGDB - -Open the VisualGDB Visual Studio Project file in the VisualGDB directory and click the "Start" button. -No wolfSSL setup is needed. You may need to adjust your specific COM port. The default is `COM20`. - ## ESP-IDF Commandline v5.x @@ -84,19 +83,36 @@ Reminder that we build with `make` and not `cmake` in VisualGDB. Build files will be created in `[project directory]\build` +## ESP-IDF make Commandline (version 3.5 or earlier for the ESP8266) + +``` +export IDF_PATH=~/esp/ESP8266_RTOS_SDK + +``` + + ## ESP-IDF CMake Commandline (version 3.5 or earlier for the ESP8266) Build files will be created in `[project directory]\build\debug` ``` -# Set your path to RTOS SDK, shown here for default from WSL vis VisualGDB +# Set your path to RTOS SDK, shown here for default from WSL with VisualGDB WRK_IDF_PATH=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 +# or +WRK_IDF_PATH=~/esp/ESP8266_RTOS_SDK + +# Setup the environment . $WRK_IDF_PATH/export.sh # install as needed / prompted /mnt/c/SysGCC/esp8266/rtos-sdk/v3.4/install.sh -cd IDE/Espressif/ESP-IDF/examples/wolfssl_client +# Fetch wolfssl from GitHub if needed: +cd /workspace +git clone https://github.com/wolfSSL/wolfssl.git + +# change directory to wolfssl client example. +cd wolfssl/IDE/Espressif/ESP-IDF/examples/wolfssl_client # or for example, WSL with C:\workspace as home for git clones: # cd /mnt/c/workspace/wolfssl-$USER/IDE/Espressif/ESP-IDF/examples/wolfssl_client @@ -104,7 +120,9 @@ cd IDE/Espressif/ESP-IDF/examples/wolfssl_client # adjust settings as desired idf.py menuconfig -idf.py build flash -p /dev/ttyS55 -b 115200 + +idf.py build flash -p /dev/ttyS70 -b 115200 +idf.py monitor -p /dev/ttyS70 -b 74880 ``` ## SM Ciphers diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h index 63c321fc8b..99b61e157c 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/include/user_settings.h @@ -1,6 +1,6 @@ /* user_settings.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +/* Standardized wolfSSL Espressif ESP32 + ESP8266 user_settings.h V5.6.6-01 */ + /* This user_settings.h is for Espressif ESP-IDF */ #include #define DEBUG_WOLFSSL @@ -214,10 +216,6 @@ * Uncomment lines to force SW instead of HW acceleration */ #if defined(CONFIG_IDF_TARGET_ESP32) #define WOLFSSL_ESP32 -// #define NO_ESP32_CRYPT - #define NO_WOLFSSL_ESP32_CRYPT_HASH -// #define NO_WOLFSSL_ESP32_CRYPT_AES -// #define NO_WOLFSSL_ESP32_CRYPT_RSA_PRI /* wolfSSL HW Acceleration supported on ESP32. Uncomment to disable: */ /* #define NO_ESP32_CRYPT */ /* #define NO_WOLFSSL_ESP32_CRYPT_HASH */ diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c index 6eacbbe83c..293febfd11 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/client-tls.c @@ -1,6 +1,6 @@ /* client-tls.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -334,7 +334,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) /* Fill in the server address */ servAddr.sin_family = AF_INET; /* using IPv4 */ - servAddr.sin_port = htons(11111); /* on DEFAULT_PORT */ + servAddr.sin_port = htons(TLS_SMP_DEFAULT_PORT); /* on DEFAULT_PORT */ if (*ch >= '1' && *ch <= '9') { /* Get the server IPv4 address from the command line call */ @@ -353,7 +353,7 @@ WOLFSSL_ESP_TASK tls_smp_client_task(void* args) sprintf(buff, "Connecting to server....%s(port:%d)", TLS_SMP_TARGET_HOST, - 11111); + TLS_SMP_DEFAULT_PORT); WOLFSSL_MSG(buff); printf("%s\n", buff); diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/component.mk b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/component.mk index 0adf45649a..c59edbee41 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/component.mk +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/component.mk @@ -3,6 +3,6 @@ # # This Makefile can be left empty. By default, it will take the sources in the # src/ directory, compile them and link them into lib(subdirectory_name).a -# in the build directory. This behaviour is entirely configurable, +# in the build directory. This behavior is entirely configurable, # please read the ESP-IDF documents if you need to do this. # diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h index 6a2fde47b7..5b92037e35 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/client-tls.h @@ -1,6 +1,6 @@ /* client-tls.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -18,8 +18,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ -#ifndef _SERVER_TLS_ -#define _SERVER_TLS_ +#ifndef _CLIENT_TLS_H_ +#define _CLIENT_TLS_H_ /* Local project, auto-generated configuration */ #include "sdkconfig.h" diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h index 94c3b5eba6..12c452d6e2 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/main.h @@ -1,6 +1,6 @@ -/* template main.h +/* wolfssl_client main.h * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h index c911147717..519c55de5e 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h @@ -33,10 +33,6 @@ #include "protocol_examples_common.h" /* see project CMakeLists.txt */ #endif -#ifdef OS_WINDOWS - // #error "OS_WINDOWS" -#endif - /** ****************************************************************************** ****************************************************************************** @@ -53,8 +49,20 @@ * Espressif SDK 3.4 on the ESP8266. Macros should still be defined. * See the project-level Makefile. Example found in: * https://github.com/wolfSSL/wolfssl/tree/master/IDE/Espressif/ESP-IDF/examples/template + * + * The USE_MY_PRIVATE_[OS]_CONFIG is typically an environment variable that + * triggers the make (not cmake) to add compiler defines. */ -#ifdef USE_MY_PRIVATE_CONFIG +#if defined(USE_MY_PRIVATE_WINDOWS_CONFIG) + #include "/workspace/my_private_config.h" +#elif defined(USE_MY_PRIVATE_WSL_CONFIG) + #include "/mnt/c/workspace/my_private_config.h" +#elif defined(USE_MY_PRIVATE_LINUX_CONFIG) + #include "~/workspace/my_private_config.h" +#elif defined(USE_MY_PRIVATE_MAC_CONFIG) + #include "~/Documents/my_private_config.h" +#elif defined(USE_MY_PRIVATE_CONFIG) + /* This section works best with cmake & non-environment variable setting */ #if defined(WOLFSSL_CMAKE_SYSTEM_NAME_WINDOWS) #define WOLFSSL_CMAKE #include "/workspace/my_private_config.h" @@ -81,7 +89,7 @@ #elif defined(OS_WINDOWS) #include "/workspace/my_private_config.h" #else - // #warning "did not detect environment. using ~/my_private_config.h" + #warning "default private config using /workspace/my_private_config.h" #include "/workspace/my_private_config.h" #endif #else diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c index bc06d12eff..fa116ed10f 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c index c05e3867e0..19ced33011 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c @@ -1,6 +1,6 @@ /* wifi_connect.c * - * Copyright (C) 2006-2023 wolfSSL Inc. + * Copyright (C) 2006-2024 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -44,6 +44,7 @@ #if defined(CONFIG_IDF_TARGET_ESP8266) #elif ESP_IDF_VERSION_MAJOR >= 5 + /* example path set in cmake file */ #elif ESP_IDF_VERSION_MAJOR >= 4 #include "protocol_examples_common.h" #else @@ -386,7 +387,8 @@ int wifi_init_sta(void) int wifi_show_ip(void) { - // TODO Causes panic: ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip)); + /* TODO Causes panic: ESP_LOGI(TAG, "got ip:" IPSTR, + * IP2STR(&event->ip_info.ip)); */ return ESP_OK; } #endif diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults index cf2c0b3c29..ff9a5d4c52 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/sdkconfig.defaults @@ -1,4 +1,4 @@ -# sdkconfig.defaults for ESP8266 +# sdkconfig.defaults for ESP8266 + ESP32 # CONFIG_ESP_PANIC_PRINT_REBOOT is not set CONFIG_ESP_PANIC_PRINT_REBOOT=n @@ -9,3 +9,16 @@ CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=n CONFIG_FREERTOS_GLOBAL_DATA_LINK_IRAM=y CONFIG_HEAP_DISABLE_IRAM=y +CONFIG_FREERTOS_HZ=1000 +# +# 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 diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/wolfssl_client_ESP8266.sln b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/wolfssl_client_ESP8266.sln index b9a0c3bd59..87214311a5 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/wolfssl_client_ESP8266.sln +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/wolfssl_client_ESP8266.sln @@ -26,6 +26,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ESP8266", "ESP8266", "{AE44 build\Debug\include\somfile.h = build\Debug\include\somfile.h EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Header Files", "Header Files", "{77C4818A-5B3E-45B3-9D9D-C10A39EC5A70}" + ProjectSection(SolutionItems) = preProject + main\include\client-tls.h = main\include\client-tls.h + main\include\main.h = main\include\main.h + main\include\time_helper.h = main\include\time_helper.h + main\include\wifi_connect.h = main\include\wifi_connect.h + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|VisualGDB = Debug|VisualGDB @@ -42,6 +50,7 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {AE44B1B2-A063-4740-8C7C-7F208BFD10E1} = {CD92F3A4-C5BA-4FA9-A0F7-4A415ABD4927} + {77C4818A-5B3E-45B3-9D9D-C10A39EC5A70} = {CD92F3A4-C5BA-4FA9-A0F7-4A415ABD4927} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AECC5442-55F3-4AC6-A5AB-81FBFDE0DAEB}