Skip to content

Commit 6f88ed0

Browse files
authored
Merge pull request #7177 from gojimmypi/PR-Arduino-Update
Improved Arduino Support: ESP32, Due
2 parents c8d0bb0 + e078e74 commit 6f88ed0

19 files changed

Lines changed: 1196 additions & 139 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ wolfcrypt/src/port/intel/qat_test
322322
# Arduino Generated Files
323323
/IDE/ARDUINO/wolfSSL
324324
scripts/memtest.txt
325+
/IDE/ARDUINO/Arduino_README_prepend.md.tmp
326+
/IDE/ARDUINO/library.properties.tmp
327+
/IDE/ARDUINO/library.properties.tmp.backup
328+
/IDE/ARDUINO/PREPENDED_README.md
325329

326330
# Doxygen generated files
327331
doc/doxygen_warnings
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Arduino wolfSSL Library
2+
3+
The library is modified from wolfSSL Release ${WOLFSSL_VERSION} for the Arduino platform.
4+

IDE/ARDUINO/README.md

Lines changed: 138 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,80 @@
1-
### wolfSSL with Arduino
1+
# wolfSSL with Arduino
22

3-
##### Reformatting wolfSSL as a compatible Arduino Library
4-
This is a shell script that will re-organize the wolfSSL library to be
5-
compatible with Arduino projects that use Arduino IDE 1.5.0 or newer.
6-
The Arduino IDE requires a library's source files to be in the library's root
7-
directory with a header file in the name of the library. This script moves all
8-
src/ files to the `IDE/ARDUINO/wolfSSL/src` directory and creates a stub header
9-
file called `wolfssl.h` inside that directory.
3+
Many of the supported boards are natively built-in to the [Arduino IDE Board Manager](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-board-manager/)
4+
and by adding [additional cores](https://docs.arduino.cc/learn/starting-guide/cores/) as needed.
105

11-
Step 1: To configure wolfSSL with Arduino, enter the following from within the
12-
wolfssl/IDE/ARDUINO directory:
6+
STM32 Support can be added by including this link in the "Additional Boards Managers URLs" field
7+
from [stm32duino/Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32?tab=readme-ov-file#getting-started) .
138

14-
`./wolfssl-arduino.sh`
9+
```
10+
https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
11+
```
1512

16-
Step 2: Copy the directory wolfSSL that was just created to:
17-
`~/Documents/Arduino/libraries/` directory so the Arduino IDE can find it.
13+
## Using wolfSSL from the Arduino IDE
1814

19-
Step 3: Edit `<arduino-libraries>/wolfSSL/src/user_settings.h`
15+
Coming soon! https://github.com/wolfSSL/arduino-wolfSSL See [PR #1](https://github.com/wolfSSL/Arduino-wolfSSL/pull/1).
16+
17+
This option will allow wolfSSL to be installed directly using the native Arduino tools.
18+
19+
## Manually Reformatting wolfSSL as a Compatible Arduino Library
20+
21+
Use [this](./wolfssl-arduino.sh) shell script that will re-organize the wolfSSL library to be
22+
compatible with [Arduino Library Specification](https://arduino.github.io/arduino-cli/0.35/library-specification/)
23+
for projects that use Arduino IDE 1.5.0 or newer.
24+
25+
The Arduino IDE requires a library's source files to be in the library's root directory with a
26+
header file in the name of the library. This script moves all `src/` files to the `IDE/ARDUINO/wolfSSL/src`
27+
directory and creates a stub header file called `wolfssl.h` inside that directory.
28+
29+
### Step 1:
30+
31+
To configure wolfSSL with Arduino, enter one of the following commands
32+
from within the `wolfssl/IDE/ARDUINO` directory:
33+
34+
1. `./wolfssl-arduino.sh`
35+
- Creates an Arduino Library directory structure in the local `wolfSSL` directory of `IDE/ARDUINO`.
36+
- You can add your own `user_settings.h`, or copy/rename the [default](../../examples/configs/user_settings_arduino.h).
37+
38+
2. `./wolfssl-arduino.sh INSTALL` (The most common option)
39+
- Creates an Arduino Library in the local `wolfSSL` directory
40+
- Moves that directory to the Arduino library directory:
41+
- `$HOME/Arduino/libraries` for most bash environments
42+
- `/mnt/c/Users/$USER/Documents/Arduino/libraries` (for WSL)
43+
- Adds the [default](../../examples/configs/user_settings_arduino.h) as `user_settings.h`.
44+
- The wolfSSL library is now available from the Arduino IDE.
45+
46+
3. `./wolfssl-arduino.sh INSTALL /path/to/repository` (Used to update [arduino-wolfSSL](https://github.com/wolfSSL/arduino-wolfSSL))
47+
- Creates an Arduino Library in `wolfSSL` directory
48+
- Copies that directory contents to the specified `/path/to/repository`
49+
- Adds the [default](../../examples/configs/user_settings_arduino.h) as `user_settings.h`.
50+
51+
4. `./wolfssl-arduino.sh INSTALL /path/to/any/other/directory`
52+
- Creates an Arduino Library in `wolfSSL` directory
53+
- Copies that directory contents to the specified `/path/to/any/other/directory`
54+
55+
### Step 2:
56+
57+
Edit `<arduino-libraries>/wolfSSL/src/user_settings.h`
2058
If building for Intel Galileo platform add: `#define INTEL_GALILEO`.
21-
Add any other custom settings, for a good start see the examples in wolfssl root
22-
"/examples/configs/user_settings_*.h"
59+
Add any other custom settings. For a good start see the examples in wolfssl root
60+
"[/examples/configs/user_settings_*.h](https://github.com/wolfssl/wolfssl/tree/master/examples/configs)"
61+
62+
### Step 3:
2363

24-
Step 4: If you experience any issues with custom user_settings.h see the wolfssl
64+
If you experience any issues with custom `user_settings.h` see the wolfssl
2565
porting guide here for more assistance: https://www.wolfssl.com/docs/porting-guide/
2666

27-
Step 5: If you still have any issues contact support@wolfssl.com for more help.
67+
If you have any issues contact support@wolfssl.com for help.
68+
69+
# Including wolfSSL in Arduino Libraries (for Arduino version 2.0 or greater)
70+
71+
1. In the Arduino IDE:
72+
73+
The wolfSSL library should automatically be detected when found in the `libraries`
74+
directory.
75+
76+
- In `Sketch -> Include Library` choose wolfSSL for new sketches.
77+
2878

2979
##### Including wolfSSL in Arduino Libraries (for Arduino version 1.6.6)
3080

@@ -33,6 +83,73 @@ Step 5: If you still have any issues contact support@wolfssl.com for more help.
3383
`IDE/ARDUNIO/wolfSSL` folder.
3484
- In `Sketch -> Include Library` choose wolfSSL.
3585

36-
2. Open an example Arduino sketch for wolfSSL:
37-
- wolfSSL Client INO sketch: `sketches/wolfssl_client/wolfssl_client.ino`
38-
- wolfSSL Server INO sketch: `sketches/wolfssl_server/wolfssl_server.ino`
86+
##### wolfSSL Examples
87+
88+
Open an example Arduino sketch for wolfSSL:
89+
90+
- wolfSSL [Client INO sketch](./sketches/wolfssl_client/README.md): `sketches/wolfssl_client/wolfssl_client.ino`
91+
92+
- wolfSSL [Server INO sketch](./sketches/wolfssl_server/README.md): `sketches/wolfssl_server/wolfssl_server.ino`
93+
94+
#### Script Examples
95+
96+
Publish wolfSSL from WSL to a repository.
97+
98+
```bash
99+
rm -rf /mnt/c/Users/$USER/Documents/Arduino/libraries/wolfSSL
100+
rm -rf /mnt/c/workspace/wolfssl-$USER/IDE/ARDUINO/wolfSSL
101+
./wolfssl-arduino.sh INSTALL /mnt/c/workspace/Arduino-wolfSSL-$USER/
102+
```
103+
104+
Publish wolfSSL from WSL to default Windows local library.
105+
106+
```bash
107+
rm -rf /mnt/c/Users/$USER/Documents/Arduino/libraries/wolfSSL
108+
rm -rf /mnt/c/workspace/wolfssl-arduino/IDE/ARDUINO/wolfSSL
109+
./wolfssl-arduino.sh INSTALL
110+
```
111+
112+
Test the TLS server by running a local command-line client.
113+
114+
```bash
115+
cd /mnt/c/workspace/wolfssl-$USER
116+
./examples/client/client -h 192.168.1.43 -p 11111 -v 3
117+
```
118+
119+
Build wolfSSL to include wolfSSH support to an alternate development directory.
120+
121+
```bash
122+
cd /mnt/c/workspace/wolfssl-$USER
123+
./configure --prefix=/mnt/c/workspace/wolfssh-$USER/wolfssl_install --enable-ssh
124+
make
125+
make install
126+
127+
```
128+
129+
Build wolfSSH with wolfSSL not installed to default directory.
130+
131+
```bash
132+
cd /mnt/c/workspace/wolfssh-$USER
133+
./configure --with-wolfssl=/mnt/c/workspace/wolfssh-$USER/wolfssl_install
134+
make
135+
./examples/client/client -u jill -h 192.168.1.34 -p 22222 -P upthehill
136+
```
137+
138+
Test the current wolfSSL.
139+
140+
```bash
141+
cd /mnt/c/workspace/wolfssl-arduino
142+
git status
143+
./autogen.sh
144+
./configure --enable-all
145+
make clean
146+
make && make test
147+
```
148+
149+
Build and run `testwolfcrypt`.
150+
151+
```bash
152+
./autogen.sh
153+
./configure --enable-all
154+
make clean && make && ./wolfcrypt/test/testwolfcrypt
155+
```

IDE/ARDUINO/include.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
# All paths should be given relative to the root
44

55
EXTRA_DIST+= IDE/ARDUINO/README.md
6+
EXTRA_DIST+= IDE/ARDUINO/Arduino_README_prepend.md
7+
EXTRA_DIST+= IDE/ARDUINO/keywords.txt
8+
EXTRA_DIST+= IDE/ARDUINO/library.properties.template
9+
EXTRA_DIST+= IDE/ARDUINO/sketches/README.md
10+
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/README.md
611
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino
12+
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/README.md
713
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino
814
EXTRA_DIST+= IDE/ARDUINO/wolfssl-arduino.sh

IDE/ARDUINO/keywords.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Syntax Coloring Map For wolfSSL
2+
# See https://arduino.github.io/arduino-cli/0.35/library-specification/#keywords
3+
#
4+
# Be sure to use tabs, not spaces. This might help:
5+
# tr ' ' '\t' < keywords1.txt > keywords.txt
6+
7+
#=============================================
8+
# Datatypes (KEYWORD1)
9+
#=============================================
10+
11+
12+
#=============================================
13+
# Methods and Functions (KEYWORD2)
14+
#=============================================
15+
wolfSSL_SetIORecv KEYWORD1
16+
17+
#=============================================
18+
# Instances (KEYWORD2)
19+
#=============================================
20+
ctx KEYWORD2
21+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=wolfSSL
2+
version=${WOLFSSL_VERSION}${WOLFSSL_VERSION_ARUINO_SUFFIX}
3+
author=wolfSSL inc
4+
maintainer=wolfSSL inc <support@wolfssl.com>
5+
sentence=A lightweight SSL/TLS library written in ANSI C and targeted for embedded, RTOS, and resource-constrained environments.
6+
paragraph=Manual: https://www.wolfssl.com/documentation/manuals/wolfssl/index.html.
7+
category=Communication
8+
url=https://www.wolfssl.com/
9+
architectures=*

IDE/ARDUINO/sketches/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# wolfSSL Arduino Examples
2+
3+
There are currently two example Arduino sketches:
4+
5+
* [wolfssl_client](./wolfssl_client/README.md): Basic TLS listening client.
6+
* [wolfssl_server](./wolfssl_server/README.md): Basic TLS server.
7+
8+
Examples have been most recently confirmed operational on the
9+
[Arduino IDE](https://www.arduino.cc/en/software) 2.2.1.
10+
11+
For examples on other platforms, see the [IDE directory](https://github.com/wolfssl/wolfssl/tree/master/IDE).
12+
Additional examples can be found on [wolfSSL/wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Arduino Basic TLS Listening Client
2+
3+
Open the [wolfssl_client.ino](./wolfssl_client.ino) file in the Arduino IDE.
4+
5+
Other IDE products are also supported, such as:
6+
7+
- [PlatformIO in VS Code](https://docs.platformio.org/en/latest/frameworks/arduino.html)
8+
- [VisualGDB](https://visualgdb.com/tutorials/arduino/)
9+
- [VisualMicro](https://www.visualmicro.com/)
10+
11+
For examples on other platforms, see the [IDE directory](https://github.com/wolfssl/wolfssl/tree/master/IDE).
12+
Additional examples can be found on [wolfSSL/wolfssl-examples](https://github.com/wolfSSL/wolfssl-examples/).
13+
14+
15+
### Troubleshooting
16+
17+
When encountering odd errors such as `undefined reference to ``_impure_ptr'`, try cleaning the Arduino
18+
cache directories. For Windows, that's typically in:
19+
20+
```text
21+
C:\Users\%USERNAME%\AppData\Local\Temp\arduino\sketches
22+
```

0 commit comments

Comments
 (0)