Skip to content

Commit 7782f8e

Browse files
authored
Merge pull request #7528 from gojimmypi/PR-PlatformIO-FreeRTOS
Introduce IDE/PlatformIO; add wolfSSL Benchmark and Test Examples
2 parents c0015cb + 439d81e commit 7782f8e

29 files changed

+1797
-7
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,11 @@ MagicCrypto
433433
debian/changelog
434434
debian/control
435435
*.deb
436+
437+
# PlatformIO
438+
/**/.pio
439+
/**/.vscode/.browse.c_cpp.db*
440+
/**/.vscode/c_cpp_properties.json
441+
/**/.vscode/launch.json
442+
/**/.vscode/ipch
443+
/**/sdkconfig.esp32dev

IDE/PlatformIO/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# PlatformIO
2+
3+
Follow the [instructions](https://docs.platformio.org/en/latest/core/installation/methods/index.html) to install PlatformIO.
4+
5+
Note there are two options:
6+
7+
- [Core CLI](https://docs.platformio.org/en/latest/core/index.html)
8+
- [VSCode IDE](https://docs.platformio.org/en/latest/integration/ide/vscode.html#ide-vscode)
9+
10+
11+
## Publishing
12+
13+
The PlatformIO Core CLI is needed to publish wolfSSL:
14+
15+
See also the [Arduino](../ARDUINO/README.md) publishing notes.
16+
17+
18+
### Publish PlatformIO Arduino Library with Windows
19+
20+
The wolfSSL publishing is done from the `scripts`. Here are somple examples:
21+
22+
Setup the PlatformIO CLI:
23+
24+
```dos
25+
set PATH=%PATH%;C:\Users\%USERNAME%\.platformio\penv\Scripts\
26+
pio --help
27+
pio account show
28+
```
29+
30+
Publish
31+
32+
```dos
33+
pio pkg publish --owner wolfSSL C:\workspace\Arduino-wolfSSL
34+
```
35+
36+
### Publish with Linux
37+
38+
```bash
39+
set PATH=%PATH%;C:\Users\%USERNAME%\.platformio\penv\Scripts\
40+
pio --help
41+
pio account show
42+
```
43+
44+
```bash
45+
pio pkg publish --owner wolfSSL ~\workspace\Arduino-wolfSSL
46+
```
47+
48+
### Create a staging / preview wolfssl org
49+
50+
See
51+
52+
```
53+
pio org create wolfssl-staging --email [email protected] --displayname "testing preview wolfssl"
54+
```
55+
56+
### Add user to org
57+
58+
The creator of an org is automatically added as user / owner at org creation time. Others can be added:
59+
60+
```
61+
pio org add wolfssl-staging gojimmypi
62+
```
63+
64+
### Publish Arduino wolfSSL to staging / preview site:
65+
66+
```
67+
pio pkg publish --owner wolfssl-staging C:\workspace\Arduino-wolfSSL
68+
```
69+
70+
### Publish Regular wolfSSL to staging / preview site:
71+
72+
```
73+
pio pkg publish --owner wolfssl-staging C:\workspace\wolfssl-gojimmypi\IDE\PlatformIO\PlatformIO_wolfSSL
74+
```
75+
76+
### Remove published version from staging site:
77+
78+
`pio pkg unpublish [<organization>/]<pkgname>[@<version>] [OPTIONS]`
79+
80+
```
81+
pio pkg unpublish wolfssl-staging/[email protected]
82+
```

IDE/PlatformIO/examples/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# PlatformIO
2+
3+
Follow the [instructions](https://docs.platformio.org/en/latest/core/installation/methods/index.html) to install PlatformIO.
4+
5+
Note there are two options:
6+
7+
- [Core CLI](https://docs.platformio.org/en/latest/core/index.html)
8+
- [VSCode IDE](https://docs.platformio.org/en/latest/integration/ide/vscode.html#ide-vscode)
9+
10+
# Examples
11+
12+
- [wolfssl_benchmark](./wolfssl_benchmark/README.md)
13+
- [wolfssl_test](./wolfssl_test/README.md)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.16.0)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
project(ESP_IDF_Hello_World)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# wolfSSL Benchmark Example
2+
3+
This ESP32 example uses the [wolfSSL wolfcrypt Benchmark Application](https://github.com/wolfSSL/wolfssl/tree/master/wolfcrypt/benchmark).
4+
5+
Other target boards _should_ work, but have not yet been tested.
6+
7+
For general information on [wolfSSL examples for Espressif](../README.md), see the
8+
[README](https://github.com/wolfSSL/wolfssl/blob/master/IDE/Espressif/ESP-IDF/README.md) file.
9+
10+
## Example Output
11+
12+
Note the default wolfSSL `user_settings.h` is configured by default to be the most
13+
compatible across the widest ranges of targets. Contact wolfSSL at [email protected]
14+
for help in optimizing for your particular application, or see the
15+
[docs](https://www.wolfssl.com/documentation/manuals/wolfssl/index.html).
16+
17+
Compiled and flashed with `idf.py build flash -p /dev/ttyS7 -b 115200 monitor`:
18+
19+
```
20+
--- idf_monitor on /dev/ttyS7 115200 ---
21+
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
22+
(377) cpu_start: Starting scheduler ets Jun 8 2016 00:22:57
23+
24+
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
25+
configsip: 0, SPIWP:0xee
26+
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
27+
mode:DIO, clock div:2
28+
load:0x3fff0030,len:6664
29+
load:0x40078000,len:14848
30+
load:0x40080400,len:3792
31+
0x40080400: _init at ??:?
32+
33+
entry 0x40080694
34+
I (27) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
35+
I (27) boot: compile time 13:41:41
36+
I (27) boot: chip revision: 1
37+
I (30) boot_comm: chip revision: 1, min. bootloader chip revision: 0
38+
I (37) boot.esp32: SPI Speed : 40MHz
39+
I (42) boot.esp32: SPI Mode : DIO
40+
I (46) boot.esp32: SPI Flash Size : 2MB
41+
I (51) boot: Enabling RNG early entropy source...
42+
I (56) boot: Partition Table:
43+
I (60) boot: ## Label Usage Type ST Offset Length
44+
I (67) boot: 0 nvs WiFi data 01 02 00009000 00006000
45+
I (75) boot: 1 phy_init RF data 01 01 0000f000 00001000
46+
I (82) boot: 2 factory factory app 00 00 00010000 00100000
47+
I (90) boot: End of partition table
48+
I (94) boot_comm: chip revision: 1, min. application chip revision: 0
49+
I (101) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=12bf4h ( 76788) map
50+
I (137) esp_image: segment 1: paddr=00022c1c vaddr=3ffb0000 size=02420h ( 9248) load
51+
I (141) esp_image: segment 2: paddr=00025044 vaddr=40080000 size=0afd4h ( 45012) load
52+
I (161) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=33148h (209224) map
53+
I (237) esp_image: segment 4: paddr=00063170 vaddr=4008afd4 size=00550h ( 1360) load
54+
I (238) esp_image: segment 5: paddr=000636c8 vaddr=50000000 size=00010h ( 16) load
55+
I (249) boot: Loaded app from partition at offset 0x10000
56+
I (249) boot: Disabling RNG early entropy source...
57+
I (266) cpu_start: Pro cpu up.
58+
I (266) cpu_start: Starting app cpu, entry point is 0x40081098
59+
0x40081098: call_start_cpu1 at /mnt/c/SysGCC/esp32/esp-idf/v4.4.2/components/esp_system/port/cpu_start.c:160
60+
61+
I (0) cpu_start: App cpu up.
62+
I (280) cpu_start: Pro cpu start user code
63+
I (280) cpu_start: cpu freq: 240000000
64+
I (280) cpu_start: Application information:
65+
I (285) cpu_start: Project name: wolfssl_benchmark
66+
I (291) cpu_start: App version: v5.5.3-stable-108-gbd7b442df-di
67+
I (298) cpu_start: Compile time: Nov 17 2022 14:10:03
68+
I (304) cpu_start: ELF file SHA256: fbb520f5bbf963a0...
69+
I (310) cpu_start: ESP-IDF: v4.4.2-dirty
70+
I (316) heap_init: Initializing. RAM available for dynamic allocation:
71+
I (323) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
72+
I (329) heap_init: At 3FFB3DE8 len 0002C218 (176 KiB): DRAM
73+
I (335) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
74+
I (341) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
75+
I (348) heap_init: At 4008B524 len 00014ADC (82 KiB): IRAM
76+
I (355) spi_flash: detected chip: generic
77+
I (359) spi_flash: flash io: dio
78+
W (362) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
79+
I (377) cpu_start: Starting scheduler on PRO CPU.
80+
I (0) cpu_start: Starting scheduler on APP CPU.
81+
I (391) wolfssl_benchmark: app_main CONFIG_BENCH_ARGV = -lng 0
82+
I (397) wolfssl_benchmark: construct_argv arg:-lng 0
83+
84+
------------------------------------------------------------------------------
85+
wolfSSL version 5.5.3
86+
------------------------------------------------------------------------------
87+
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
88+
RNG 1 MiB took 1.017 seconds, 1.320 MiB/s
89+
AES-128-CBC-enc 6 MiB took 1.002 seconds, 5.726 MiB/s
90+
AES-128-CBC-dec 5 MiB took 1.000 seconds, 5.347 MiB/s
91+
AES-192-CBC-enc 6 MiB took 1.004 seconds, 5.714 MiB/s
92+
AES-192-CBC-dec 5 MiB took 1.001 seconds, 5.341 MiB/s
93+
AES-256-CBC-enc 6 MiB took 1.000 seconds, 5.713 MiB/s
94+
AES-256-CBC-dec 5 MiB took 1.002 seconds, 5.336 MiB/s
95+
AES-128-GCM-enc 300 KiB took 1.004 seconds, 298.805 KiB/s
96+
AES-128-GCM-dec 300 KiB took 1.004 seconds, 298.805 KiB/s
97+
AES-192-GCM-enc 300 KiB took 1.007 seconds, 297.915 KiB/s
98+
AES-192-GCM-dec 300 KiB took 1.008 seconds, 297.619 KiB/s
99+
AES-256-GCM-enc 300 KiB took 1.011 seconds, 296.736 KiB/s
100+
AES-256-GCM-dec 300 KiB took 1.011 seconds, 296.736 KiB/s
101+
GMAC Default 403 KiB took 1.002 seconds, 402.196 KiB/s
102+
3DES 450 KiB took 1.028 seconds, 437.743 KiB/s
103+
MD5 14 MiB took 1.001 seconds, 13.756 MiB/s
104+
SHA 14 MiB took 1.001 seconds, 14.463 MiB/s
105+
SHA-256 14 MiB took 1.000 seconds, 14.233 MiB/s
106+
SHA-512 17 MiB took 1.000 seconds, 16.626 MiB/s
107+
HMAC-MD5 14 MiB took 1.000 seconds, 13.599 MiB/s
108+
HMAC-SHA 14 MiB took 1.000 seconds, 13.989 MiB/s
109+
HMAC-SHA256 14 MiB took 1.000 seconds, 13.940 MiB/s
110+
HMAC-SHA512 16 MiB took 1.000 seconds, 16.064 MiB/s
111+
PBKDF2 640 bytes took 1.009 seconds, 634.291 bytes/s
112+
RSA 2048 public 52 ops took 1.022 sec, avg 19.654 ms, 50.881 ops/sec
113+
RSA 2048 private 4 ops took 1.056 sec, avg 264.000 ms, 3.788 ops/sec
114+
ECC [ SECP256R1] 256 key gen 4 ops took 1.216 sec, avg 304.000 ms, 3.289 ops/sec
115+
ECDHE [ SECP256R1] 256 agree 4 ops took 1.215 sec, avg 303.750 ms, 3.292 ops/sec
116+
ECDSA [ SECP256R1] 256 sign 4 ops took 1.226 sec, avg 306.500 ms, 3.263 ops/sec
117+
ECDSA [ SECP256R1] 256 verify 2 ops took 1.172 sec, avg 586.000 ms, 1.706 ops/sec
118+
CURVE 25519 key gen 3 ops took 1.279 sec, avg 426.333 ms, 2.346 ops/sec
119+
CURVE 25519 agree 4 ops took 1.701 sec, avg 425.250 ms, 2.352 ops/sec
120+
ED 25519 key gen 46 ops took 1.008 sec, avg 21.913 ms, 45.635 ops/sec
121+
ED 25519 sign 42 ops took 1.038 sec, avg 24.714 ms, 40.462 ops/sec
122+
ED 25519 verify 26 ops took 1.009 sec, avg 38.808 ms, 25.768 ops/sec
123+
Benchmark complete
124+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the usual convention is to give header files names that end with `.h'.
29+
It is most portable to use only letters, digits, dashes, and underscores in
30+
header file names, and at most one dot.
31+
32+
Read more about using header files in official GCC documentation:
33+
34+
* Include Syntax
35+
* Include Operation
36+
* Once-Only Headers
37+
* Computed Includes
38+
39+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into executable file.
4+
5+
The source code of each library should be placed in an own separate directory
6+
("lib/your_library_name/[here are source files]").
7+
8+
For example, see a structure of the following two libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
and a contents of `src/main.c`:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:esp32dev]
12+
platform = espressif32
13+
board = esp32dev
14+
framework = espidf
15+
upload_port = COM82
16+
monitor_port = COM82
17+
monitor_speed = 115200
18+
build_flags = -DWOLFSSL_USER_SETTINGS, -DWOLFSSL_ESP32
19+
monitor_filters = direct
20+
lib_deps = wolfssl/wolfSSL@^5.7.0-rev.3b

0 commit comments

Comments
 (0)