Skip to content

Commit 38d5eec

Browse files
author
gojimmypi
committed
Introduce WOLFSSL_ESPIDF_EXIT_MESSAGE macro (+code review edits)
1 parent f011012 commit 38d5eec

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

  • IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main
  • wolfssl/wolfcrypt/port/Espressif

IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/main/main.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,25 @@
2424
#include "sdkconfig.h"
2525

2626
/* wolfSSL */
27+
/* The wolfSSL user_settings.h file is automatically included by the settings.h
28+
* file and should never be explicitly included in any other source files.
29+
* The settings.h should also be listed above wolfssl library include files. */
2730
#include <wolfssl/wolfcrypt/settings.h>
28-
#include <user_settings.h>
2931
#include <wolfssl/version.h>
30-
#include "wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h"
32+
#include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
3133
#ifndef WOLFSSL_ESPIDF
32-
#warning "Problem with wolfSSL user_settings."
33-
#warning "Check components/wolfssl/include"
34+
#error "Problem with wolfSSL user_settings. " \
35+
"Check components/wolfssl/include " \
36+
"and confirm WOLFSSL_USER_SETTINGS is defined, " \
37+
"typically in the component CMakeLists.txt"
3438
#endif
3539

3640
#include <wolfssl/wolfcrypt/types.h>
3741
#include <wolfcrypt/benchmark/benchmark.h>
3842

3943
/* set to 0 for one benchmark,
40-
** set to 1 for continous benchmark loop */
41-
#define BENCHMARK_LOOP 1
44+
** set to 1 for continuous benchmark loop */
45+
#define BENCHMARK_LOOP 0
4246

4347
/* check BENCH_ARGV in sdkconfig to determine need to set WOLFSSL_BENCH_ARGV */
4448
#ifdef CONFIG_BENCH_ARGV
@@ -129,6 +133,7 @@ void my_atmel_free(int slotId)
129133
/* the following are needed by benchmark.c with args */
130134
#ifdef WOLFSSL_BENCH_ARGV
131135
char* __argv[WOLFSSL_BENCH_ARGV_MAX_ARGUMENTS];
136+
#define ARG_BUFF_SIZE 16
132137

133138
int construct_argv()
134139
{
@@ -137,7 +142,7 @@ int construct_argv()
137142
int len = 0;
138143
char *_argv; /* buffer for copying the string */
139144
char *ch; /* char pointer to trace the string */
140-
char buff[16] = { 0 }; /* buffer for a argument copy */
145+
char buff[ARG_BUFF_SIZE] = { 0 }; /* buffer for a argument copy */
141146

142147
ESP_LOGI(TAG, "construct_argv arg:%s\n", CONFIG_BENCH_ARGV);
143148
len = strlen(CONFIG_BENCH_ARGV);
@@ -170,7 +175,7 @@ int construct_argv()
170175
memset(buff, 0, sizeof(buff));
171176
/* copy each args into buffer */
172177
i = 0;
173-
while ((*ch != ' ') && (*ch != '\0') && (i < 16)) {
178+
while ((*ch != ' ') && (*ch != '\0') && (i <= ARG_BUFF_SIZE)) {
174179
buff[i] = *ch;
175180
++i;
176181
++ch;
@@ -193,14 +198,15 @@ int construct_argv()
193198
void app_main(void)
194199
{
195200
int stack_start = 0;
196-
ESP_LOGI(TAG, "---------------- wolfSSL Benchmark Example ------------");
201+
202+
ESP_LOGI(TAG, "---------------- wolfSSL Benchmark Example -------------");
197203
ESP_LOGI(TAG, "--------------------------------------------------------");
198204
ESP_LOGI(TAG, "--------------------------------------------------------");
199205
ESP_LOGI(TAG, "---------------------- BEGIN MAIN ----------------------");
200206
ESP_LOGI(TAG, "--------------------------------------------------------");
201207
ESP_LOGI(TAG, "--------------------------------------------------------");
202208

203-
#ifdef HAVE_VERSION_EXTENDED_INFO
209+
#if defined(HAVE_VERSION_EXTENDED_INFO) && defined(WOLFSSL_HAS_METRICS)
204210
esp_ShowExtendedSystemInfo();
205211
#endif
206212

@@ -236,7 +242,7 @@ void app_main(void)
236242
ESP_LOGI(TAG, "Stack used: %d\n",
237243
stack_start - uxTaskGetStackHighWaterMark(NULL));
238244

239-
#ifdef WOLFSSL_HW_METRICS_DISABLED/* Remove _DISABLED upon #6990 Merge */
245+
#if defined(WOLFSSL_HW_METRICS) && defined(WOLFSSL_HAS_METRICS)
240246
esp_hw_show_metrics();
241247
#endif
242248
} while (BENCHMARK_LOOP);
@@ -249,8 +255,9 @@ void app_main(void)
249255
ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL));
250256
#endif
251257

252-
ESP_LOGI(TAG, "\n\nDone!\n\n"
253-
"If running from idf.py monitor, press twice: Ctrl+]");
258+
#ifdef WOLFSSL_ESPIDF_EXIT_MESSAGE
259+
ESP_LOGI(TAG, WOLFSSL_ESPIDF_EXIT_MESSAGE);
260+
#endif
254261

255262
/* after the test, we'll just wait */
256263
while (1) {

wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
#define WOLFSSL_ESPIDF_BLANKLINE_MESSAGE "."
5252
#endif
5353

54+
/* Optional exit message.
55+
* The WOLFSSL_COMPLETE keyword exits wolfSSL test harness script. */
56+
#define WOLFSSL_ESPIDF_EXIT_MESSAGE \
57+
"\n\nDone!" \
58+
"\n\nWOLFSSL_COMPLETE" \
59+
"\n\nIf running from idf.py monitor, press twice: Ctrl+]"
60+
5461
/* exit codes to be used in tfm.c, sp_int.c, integer.c, etc.
5562
*
5663
* see wolfssl/wolfcrypt/error-crypt.h

0 commit comments

Comments
 (0)