Skip to content

Commit 39ad676

Browse files
authored
Merge pull request #7240 from gojimmypi/PR-wolfssl_client_ESP8266
Update TLS client example for Espressif ESP8266
2 parents 21b82a2 + 68fb183 commit 39ad676

26 files changed

Lines changed: 1467 additions & 326 deletions

File tree

Lines changed: 125 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,134 @@
1+
# ESP8266 Project Makefile for wolfssl_client
12
#
2-
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
3-
# project subdirectory.
3+
# Copyright (C) 2006-2024 wolfSSL Inc.
4+
#
5+
# This file is part of wolfSSL.
6+
#
7+
# wolfSSL is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# wolfSSL is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
420
#
521

22+
#
23+
# This is a project Makefile.
24+
# It is assumed the directory this Makefile resides in is a
25+
# project subdirectory containing an entire project.
26+
#
27+
# Optional private config headers. Define environment variables
28+
# to include various default header files that are typically
29+
# not in a git path, and thus excluded from being checked in.
30+
#
31+
# Environment Variable Name | Header file name included
32+
# ---------------------------------- | ---------------------------------------
33+
# MY_PRIVATE_CONFIG (files detected / selected in header)
34+
# USE_MY_PRIVATE_WSL_CONFIG /mnt/c/workspace/my_private_config.h
35+
# USE_MY_PRIVATE_MAC_CONFIG ~/Documents/my_private_config.h
36+
# USE_MY_PRIVATE_LINUX_CONFIG ~/workspace/my_private_config.h
37+
# USE_MY_PRIVATE_WINDOWS_CONFIG /workspace/my_private_config.h
38+
#
39+
#
640
PROJECT_NAME := wolfssl_client
741

42+
MY_PRIVATE_CONFIG ?= n
43+
USE_MY_PRIVATE_WSL_CONFIG ?= n
44+
USE_MY_PRIVATE_MAC_CONFIG ?= n
45+
USE_MY_PRIVATE_LINUX_CONFIG ?= n
46+
USE_MY_PRIVATE_WINDOWS_CONFIG ?= n
47+
48+
# Calling shell causes unintuitive error in Windows:
49+
# OS := $(shell uname -s)
50+
#
51+
# But OS, or MY_PRIVATE_CONFIG should already be defined:
52+
$(info ************* wolfssl_client *************)
53+
54+
ifeq ($(MY_PRIVATE_CONFIG),y)
55+
CFLAGS += -DMY_PRIVATE_CONFIG
56+
$(info Enabled MY_PRIVATE_CONFIG")
57+
endif
58+
59+
# Check for Windows environment variable: USE_MY_PRIVATE_WINDOWS_CONFIG
60+
ifeq ($(USE_MY_PRIVATE_WINDOWS_CONFIG),y)
61+
# This hard coded MY_CONFIG_FILE value must match that in the header file.
62+
MY_CONFIG_FILE := /workspace/my_private_config.h
63+
ifeq ($(wildcard $(MY_CONFIG_FILE)),)
64+
$(info File does not exist: $(MY_CONFIG_FILE))
65+
else
66+
CFLAGS += -DUSE_MY_PRIVATE_WINDOWS_CONFIG
67+
$(info Using private config file for: Windows)
68+
endif
69+
endif
70+
71+
# Check for WSL environment variable: USE_MY_PRIVATE_WSL_CONFIG
72+
ifeq ($(USE_MY_PRIVATE_WSL_CONFIG),y)
73+
# This hard coded MY_CONFIG_FILE value must match that in the header file.
74+
MY_CONFIG_FILE := /mnt/c/workspace/my_private_config.h
75+
ifeq ($(wildcard $(MY_CONFIG_FILE)),)
76+
$(info File does not exist: $(MY_CONFIG_FILE))
77+
else
78+
CFLAGS += -DUSE_MY_PRIVATE_WSL_CONFIG
79+
$(info Using private config file for: WSL)
80+
endif
81+
endif
82+
83+
# Check for Linux environment variable: USE_MY_PRIVATE_LINUX_CONFIG
84+
ifeq ($(USE_MY_PRIVATE_LINUX_CONFIG),y)
85+
# This hard coded MY_CONFIG_FILE value must match that in the header file.
86+
MY_CONFIG_FILE := ~/workspace/my_private_config.h
87+
ifeq ($(wildcard $(MY_CONFIG_FILE)),)
88+
$(info File does not exist: $(MY_CONFIG_FILE))
89+
else
90+
CFLAGS += -DUSE_MY_PRIVATE_LINUX_CONFIG
91+
$(info Using private config file for: Linux)
92+
endif
93+
endif
94+
95+
# Check for Mac environment variable: USE_MY_PRIVATE_MAC_CONFIG
96+
ifeq ($(USE_MY_PRIVATE_MAC_CONFIG),y)
97+
# This hard coded MY_CONFIG_FILE value must match that in the header file.
98+
MY_CONFIG_FILE := ~/Documents/my_private_config.h
99+
ifeq ($(wildcard $(MY_CONFIG_FILE)),)
100+
$(info File does not exist: $(MY_CONFIG_FILE))
101+
else
102+
CFLAGS += -DUSE_MY_PRIVATE_MAC_CONFIG
103+
$(info Using private config file for: Mac)
104+
endif
105+
endif
106+
107+
ifneq ($(OS),MY_PRIVATE_CONFIG)
108+
CFLAGS += -DMY_PRIVATE_CONFIG="$(MY_PRIVATE_CONFIG)"
109+
else
110+
ifeq ($(OS),Linux)
111+
CFLAGS += -DOS_LINUX
112+
endif
113+
ifeq ($(OS),Windows_NT)
114+
CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_WINDOWS
115+
endif
116+
ifeq ($(OS),Darwin)
117+
CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_APPLE
118+
endif
119+
ifneq (,$(findstring MINGW,$(OS)))
120+
CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_MINGW
121+
endif
122+
ifneq (,$(findstring CYGWIN,$(OS)))
123+
CFLAGS += -DWOLFSSL_MAKE_SYSTEM_NAME_CYGWIN
124+
endif
125+
endif
126+
127+
# It is essential that the build process sees the WOLFSSL_USER_SETTINGS
8128
CFLAGS += -DWOLFSSL_USER_SETTINGS
9-
# if there isn't the directory, please disable the line below.
129+
130+
# if directory not available, please disable the line below.
10131
EXTRA_COMPONENT_DIRS = $(IDF_PATH)/examples/common_components/protocol_examples_common
11132

133+
# The Standard Espressif IDF include:
12134
include $(IDF_PATH)/make/project.mk

IDE/Espressif/ESP-IDF/examples/wolfssl_client/README.md

Lines changed: 116 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,50 @@ When using the CLI, see the [example parameters](/IDE/Espressif/ESP-IDF/examples
88
For general information on [wolfSSL examples for Espressif](../README.md), see the
99
[README](https://github.com/wolfSSL/wolfssl/blob/master/IDE/Espressif/ESP-IDF/README.md) file.
1010

11-
## VisualGDB
11+
## Quick Start
12+
13+
Use the [ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html)
14+
for ESP32 or [RTOS SDK](https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html)
15+
for the ESP8266.
16+
17+
Run `menuconfig` utility (`idf.py menuconfig` for ESP32 or `make menuconfig` for the ESP8266)
18+
and set the various parameters for the target device, along with local WiFi settings:
19+
20+
* Target Host: `CONFIG_WOLFSSL_TARGET_HOST` (The IP address of a listening server)
21+
* Target Port: `CONFIG_WOLFSSL_TARGET_PORT` (Typically `11111`)
22+
* Example WiFi SSID: `CONFIG_EXAMPLE_WIFI_SSID` (The WiFi that you want to connect to)
23+
* Example WiFi Password: `CONFIG_EXAMPLE_WIFI_PASSWORD` (The WiFi password)
24+
25+
The latest examples use makefiles that do not require local file copy installation of wolfSSL.
26+
27+
Build and flash the software to see the example in action.
28+
29+
## Quick Start with VisualGDB
30+
31+
There are optional [VisualGDB](https://visualgdb.com/tutorials/esp8266/) project files in the
32+
[VisualGDB](./VisualGDB) project subdirectory, and an ESP8266 project file in the project directory,
33+
called `wolfssl_client_ESP8266.vgdbproj`.
1234

1335
Open the VisualGDB Visual Studio Project file in the VisualGDB directory and click the "Start" button.
14-
No wolfSSL setup is needed. You may need to adjust your specific COM port. The default is `COM20`.
36+
No wolfSSL setup is needed. You may need to adjust your specific COM port. The default is `COM19`.
37+
38+
## Troubleshooting
39+
40+
Weird results, odd messages, unexpected compiler errors? Manually delete the build directory and
41+
any locally generated files (`sdkconfig`, `sdkconfig-debug`, etc.) and start over.
42+
43+
The `build` directory is typically located in the root of the project directory: `[project]/build`.
44+
45+
46+
Difficulty flashing:
47+
48+
* Ensure the target device has a robust, stable, clean power supply.
49+
* Check that quality USB cables are being used.
50+
* Try lowering the flash baud rate in the `menuconfig`. The 115200 is typically reliable.
51+
* Review board specifications: some require manual boot mode via on-board buttons.
52+
* See [Espressif ESP Frequently Asked Questions](https://docs.espressif.com/projects/esp-faq/en/latest/esp-faq-en-master.pdf)
1553

16-
## ESP-IDF Commandline
54+
## ESP-IDF Commandline v5.x
1755

1856

1957
1. `idf.py menuconfig` to config the project
@@ -38,17 +76,90 @@ When you want to test the wolfSSL client
3876

3977
e.g. Launch ./examples/server/server -v 4 -b -i -d
4078

79+
80+
## VisualGDB for ESP8266
81+
82+
Reminder that we build with `make` and not `cmake` in VisualGDB.
83+
84+
Build files will be created in `[project directory]\build`
85+
86+
## ESP-IDF make Commandline (version 3.5 or earlier for the ESP8266)
87+
88+
```
89+
export IDF_PATH=~/esp/ESP8266_RTOS_SDK
90+
91+
```
92+
93+
94+
## ESP-IDF CMake Commandline (version 3.5 or earlier for the ESP8266)
95+
96+
Build files will be created in `[project directory]\build\debug`
97+
98+
```
99+
# Set your path to RTOS SDK, shown here for default from WSL with VisualGDB
100+
WRK_IDF_PATH=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4
101+
# or
102+
WRK_IDF_PATH=~/esp/ESP8266_RTOS_SDK
103+
104+
# Setup the environment
105+
. $WRK_IDF_PATH/export.sh
106+
107+
# install as needed / prompted
108+
/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4/install.sh
109+
110+
# Fetch wolfssl from GitHub if needed:
111+
cd /workspace
112+
git clone https://github.com/wolfSSL/wolfssl.git
113+
114+
# change directory to wolfssl client example.
115+
cd wolfssl/IDE/Espressif/ESP-IDF/examples/wolfssl_client
116+
117+
# or for example, WSL with C:\workspace as home for git clones:
118+
# cd /mnt/c/workspace/wolfssl-$USER/IDE/Espressif/ESP-IDF/examples/wolfssl_client
119+
120+
# adjust settings as desired
121+
idf.py menuconfig
122+
123+
124+
idf.py build flash -p /dev/ttyS70 -b 115200
125+
idf.py monitor -p /dev/ttyS70 -b 74880
126+
```
127+
41128
## SM Ciphers
42129

43-
#### Working Linux Client to ESP32 Server
130+
(TODO coming soon)
131+
See https://github.com/wolfSSL/wolfsm
132+
133+
#### Working Linux Client to ESP32 Server Example:
134+
135+
```
136+
./examples/client/client -h 192.168.1.37 -p 11111 -v 3
137+
```
138+
139+
```text
140+
-c <file> Certificate file, default ./certs/client-cert.pem
141+
-k <file> Key file, default ./certs/client-key.pem
142+
-A <file> Certificate Authority file, default ./certs/ca-cert.pem
143+
```
144+
145+
Example client, with default certs explicitly given:
146+
147+
```bash
148+
./examples/client/client -h 192.168.1.37 -p 11111 -v 3 -c ./certs/client-cert.pem -k ./certs/client-key.pem -A ./certs/ca-cert.pem
149+
```
150+
151+
Example client, with RSA 1024 certs explicitly given:
152+
153+
```
154+
./examples/client/client -h 192.168.1.37 -p 11111 -v 3 -c ./certs/1024/client-cert.pem -k ./certs/1024/client-key.pem -A ./certs/1024/ca-cert.pem
155+
```
44156

45157
Command:
46158

47159
```
48160
cd /mnt/c/workspace/wolfssl-$USER/IDE/Espressif/ESP-IDF/examples/wolfssl_server
49161
. /mnt/c/SysGCC/esp32/esp-idf/v5.1/export.sh
50162
idf.py flash -p /dev/ttyS19 -b 115200 monitor
51-
52163
```
53164

54165
```
@@ -75,4 +186,3 @@ I hear you fa shizzle!
75186
```
76187

77188
See the README.md file in the upper level 'examples' directory for [more information about examples](../README.md).
78-

IDE/Espressif/ESP-IDF/examples/wolfssl_client/VisualGDB/wolfssl_client_IDF_v5_ESP32.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "include", "include", "{5326
1818
EndProject
1919
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A51226B3-88A7-4463-B443-0E321C4A3D53}"
2020
ProjectSection(SolutionItems) = preProject
21+
..\..\..\..\..\..\wolfssl\wolfcrypt\error-crypt.h = ..\..\..\..\..\..\wolfssl\wolfcrypt\error-crypt.h
22+
..\..\..\..\..\..\wolfssl\error-ssl.h = ..\..\..\..\..\..\wolfssl\error-ssl.h
23+
..\main\Kconfig.projbuild = ..\main\Kconfig.projbuild
24+
..\build\VisualGDB\Debug\esp-idf\esp_system\ld\memory.ld = ..\build\VisualGDB\Debug\esp-idf\esp_system\ld\memory.ld
2125
..\..\..\..\..\..\..\my_private_config.h = ..\..\..\..\..\..\..\my_private_config.h
2226
..\partitions_singleapp_large.csv = ..\partitions_singleapp_large.csv
2327
..\README.md = ..\README.md
2428
..\sdkconfig = ..\sdkconfig
2529
..\build\VisualGDB\Debug\config\sdkconfig.cmake = ..\build\VisualGDB\Debug\config\sdkconfig.cmake
2630
..\sdkconfig.defaults = ..\sdkconfig.defaults
2731
..\build\VisualGDB\Debug\config\sdkconfig.h = ..\build\VisualGDB\Debug\config\sdkconfig.h
32+
..\build\VisualGDB\Debug\esp-idf\esp_system\ld\sections.ld = ..\build\VisualGDB\Debug\esp-idf\esp_system\ld\sections.ld
2833
EndProjectSection
2934
EndProject
3035
Global

IDE/Espressif/ESP-IDF/examples/wolfssl_client/components/wolfssl/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ if(CMAKE_BUILD_EARLY_EXPANSION)
158158
idf_component_register(
159159
REQUIRES "${COMPONENT_REQUIRES}"
160160
PRIV_REQUIRES # esp_hw_support
161-
esp_timer
162-
driver # this will typically only be needed for wolfSSL benchmark
161+
# esp_timer
162+
# driver # this will typically only be needed for wolfSSL benchmark
163163
)
164164

165165
else()

0 commit comments

Comments
 (0)