Skip to content

Commit 924c0fd

Browse files
authored
Merge pull request #7329 from gojimmypi/PR-Arduino-Build
Ignore build file warnings for Arduino; Update examples
2 parents 6f65d67 + 9057e81 commit 924c0fd

File tree

9 files changed

+122
-68
lines changed

9 files changed

+122
-68
lines changed

IDE/ARDUINO/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ rm -rf /mnt/c/workspace/wolfssl-$USER/IDE/ARDUINO/wolfSSL
129129
Publish wolfSSL from WSL to default Windows local library.
130130

131131
```bash
132+
cd /mnt/c/workspace/wolfssl-$USER/IDE/ARDUINO
132133
rm -rf /mnt/c/Users/$USER/Documents/Arduino/libraries/wolfSSL
133134
rm -rf /mnt/c/workspace/wolfssl-arduino/IDE/ARDUINO/wolfSSL
134135
./wolfssl-arduino.sh INSTALL

IDE/ARDUINO/include.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/README.md
1111
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino
1212
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/README.md
1313
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino
14+
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_version/README.md
15+
EXTRA_DIST+= IDE/ARDUINO/sketches/wolfssl_version/wolfssl_version.ino
1416
EXTRA_DIST+= IDE/ARDUINO/wolfssl.h
1517
EXTRA_DIST+= IDE/ARDUINO/wolfssl-arduino.sh

IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Tested with:
4343
#define REPEAT_CONNECTION 0
4444

4545
/* Edit this with your other TLS host server address to connect to: */
46-
#define WOLFSSL_TLS_SERVER_HOST "192.168.1.34"
46+
#define WOLFSSL_TLS_SERVER_HOST "192.168.1.39"
4747

4848
/* wolfssl TLS examples communicate on port 11111 */
4949
#define WOLFSSL_PORT 11111
@@ -58,7 +58,7 @@ Tested with:
5858
#define RECONNECT_ATTEMPTS 20
5959

6060
/* Optional stress test. Define to consume memory until exhausted: */
61-
#define MEMORY_STRESS_TEST
61+
/* #define MEMORY_STRESS_TEST */
6262

6363
/* Choose client or server example, not both. */
6464
#define WOLFSSL_CLIENT_EXAMPLE
@@ -68,12 +68,12 @@ Tested with:
6868
/* the /workspace directory may contain a private config
6969
* excluded from GitHub with items such as WiFi passwords */
7070
#include MY_PRIVATE_CONFIG
71-
const char* ssid PROGMEM = CONFIG_ESP_WIFI_SSID;
72-
const char* password PROGMEM = CONFIG_ESP_WIFI_PASSWORD;
71+
static const char* ssid PROGMEM = MY_ARDUINO_WIFI_SSID;
72+
static const char* password PROGMEM = MY_ARDUINO_WIFI_PASSWORD;
7373
#else
7474
/* when using WiFi capable boards: */
75-
const char* ssid PROGMEM = "your_SSID";
76-
const char* password PROGMEM = "your_PASSWORD";
75+
static const char* ssid PROGMEM = "your_SSID";
76+
static const char* password PROGMEM = "your_PASSWORD";
7777
#endif
7878

7979
#define BROADCAST_ADDRESS "255.255.255.255"
@@ -135,7 +135,7 @@ Tested with:
135135
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
136136
#define USING_WIFI
137137
#include <SPI.h>
138-
#include <WiFiNINA.h>
138+
#include <WiFiNINA.h> /* Needs Arduino WiFiNINA library installed manually */
139139
WiFiClient client;
140140

141141
#elif defined(ARDUINO_ARCH_RP2040)
@@ -176,21 +176,20 @@ Tested with:
176176
|| defined(HAVE_SERVER_RENEGOTIATION_INFO)
177177
#endif
178178

179-
const char host[] PROGMEM = WOLFSSL_TLS_SERVER_HOST; /* server to connect to */
180-
const int port PROGMEM = WOLFSSL_PORT; /* port on server to connect to */
181-
const int serial_baud PROGMEM = SERIAL_BAUD; /* local serial port to monitor */
179+
static const char host[] PROGMEM = WOLFSSL_TLS_SERVER_HOST; /* server to connect to */
180+
static const int port PROGMEM = WOLFSSL_PORT; /* port on server to connect to */
182181

183-
WOLFSSL_CTX* ctx = NULL;
184-
WOLFSSL* ssl = NULL;
185-
char* wc_error_message = (char*)malloc(80 + 1);
186-
char errBuf[80];
182+
static WOLFSSL_CTX* ctx = NULL;
183+
static WOLFSSL* ssl = NULL;
184+
static char* wc_error_message = (char*)malloc(80 + 1);
185+
static char errBuf[80];
187186

188187
#if defined(MEMORY_STRESS_TEST)
189188
#define MEMORY_STRESS_ITERATIONS 100
190189
#define MEMORY_STRESS_BLOCK_SIZE 1024
191190
#define MEMORY_STRESS_INITIAL (4*1024)
192-
char* memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */
193-
int mem_ctr = 0;
191+
static char* memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */
192+
static int mem_ctr = 0;
194193
#endif
195194

196195
static int EthernetSend(WOLFSSL* ssl, char* msg, int sz, void* ctx);
@@ -202,8 +201,8 @@ static int lng_index PROGMEM = 0; /* 0 = English */
202201
#include <malloc.h>
203202
extern char _end;
204203
extern "C" char *sbrk(int i);
205-
char *ramstart=(char *)0x20070000;
206-
char *ramend=(char *)0x20088000;
204+
static char *ramstart=(char *)0x20070000;
205+
static char *ramend=(char *)0x20088000;
207206
#endif
208207

209208
/*****************************************************************************/
@@ -372,28 +371,31 @@ int setup_network(void) {
372371
#if defined(USING_WIFI)
373372
int status = WL_IDLE_STATUS;
374373

375-
if (WiFi.status() == WL_NO_MODULE) {
376-
Serial.println("Communication with WiFi module failed!");
377-
/* don't continue if no network */
378-
while (true) ;
379-
}
380-
381-
String fv = WiFi.firmwareVersion();
382-
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
383-
Serial.println("Please upgrade the firmware");
384-
}
385-
386374
/* The ESP8266 & ESP32 support both AP and STA. We'll use STA: */
387375
#if defined(ESP8266) || defined(ESP32)
388376
WiFi.mode(WIFI_STA);
377+
#else
378+
String fv;
379+
if (WiFi.status() == WL_NO_MODULE) {
380+
Serial.println("Communication with WiFi module failed!");
381+
/* don't continue if no network */
382+
while (true) ;
383+
}
384+
385+
fv = WiFi.firmwareVersion();
386+
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
387+
Serial.println("Please upgrade the firmware");
388+
}
389389
#endif
390390

391391
Serial.print(F("Connecting to WiFi "));
392392
Serial.print(ssid);
393+
status = WiFi.begin(ssid, password);
393394
while (status != WL_CONNECTED) {
394-
status = WiFi.begin(ssid, password);
395-
delay(5000);
395+
delay(1000);
396396
Serial.print(F("."));
397+
Serial.print(status);
398+
status = WiFi.status();
397399
}
398400

399401
Serial.println(F(" Connected!"));
@@ -598,9 +600,12 @@ int setup_certificates(void) {
598600
/*****************************************************************************/
599601
/*****************************************************************************/
600602
void setup(void) {
601-
Serial.begin(serial_baud);
602-
while (!Serial) {
603+
int i = 0;
604+
Serial.begin(SERIAL_BAUD);
605+
while (!Serial && (i < 10)) {
603606
/* wait for serial port to connect. Needed for native USB port only */
607+
delay(1000);
608+
i++;
604609
}
605610
Serial.println(F(""));
606611
Serial.println(F(""));
@@ -623,10 +628,10 @@ void setup(void) {
623628

624629
setup_hardware();
625630

626-
setup_datetime();
627-
628631
setup_network();
629632

633+
setup_datetime();
634+
630635
setup_wolfssl();
631636

632637
setup_certificates();

IDE/ARDUINO/sketches/wolfssl_server/wolfssl_server.ino

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ Tested with:
6868
/* the /workspace directory may contain a private config
6969
* excluded from GitHub with items such as WiFi passwords */
7070
#include MY_PRIVATE_CONFIG
71-
const char* ssid PROGMEM = CONFIG_ESP_WIFI_SSID;
72-
const char* password PROGMEM = CONFIG_ESP_WIFI_PASSWORD;
71+
static const char* ssid PROGMEM = MY_ARDUINO_WIFI_SSID;
72+
static const char* password PROGMEM = MY_ARDUINO_WIFI_PASSWORD;
7373
#else
7474
/* when using WiFi capable boards: */
75-
const char* ssid PROGMEM = "your_SSID";
76-
const char* password PROGMEM = "your_PASSWORD";
75+
static const char* ssid PROGMEM = "your_SSID";
76+
static const char* password PROGMEM = "your_PASSWORD";
7777
#endif
7878

7979
#define BROADCAST_ADDRESS "255.255.255.255"
@@ -135,7 +135,7 @@ Tested with:
135135
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
136136
#define USING_WIFI
137137
#include <SPI.h>
138-
#include <WiFiNINA.h>
138+
#include <WiFiNINA.h> /* Needs Arduino WiFiNINA library installed manually */
139139
WiFiClient client;
140140
WiFiServer server(WOLFSSL_PORT);
141141
#elif defined(ARDUINO_ARCH_RP2040)
@@ -178,19 +178,18 @@ Tested with:
178178

179179

180180
/* we expect our IP address from DHCP */
181-
const int serial_baud = SERIAL_BAUD; /* local serial port to monitor */
182181

183-
WOLFSSL_CTX* ctx = NULL;
184-
WOLFSSL* ssl = NULL;
185-
char* wc_error_message = (char*)malloc(80 + 1);
186-
char errBuf[80];
182+
static WOLFSSL_CTX* ctx = NULL;
183+
static WOLFSSL* ssl = NULL;
184+
static char* wc_error_message = (char*)malloc(80 + 1);
185+
static char errBuf[80];
187186

188187
#if defined(MEMORY_STRESS_TEST)
189188
#define MEMORY_STRESS_ITERATIONS 100
190189
#define MEMORY_STRESS_BLOCK_SIZE 1024
191190
#define MEMORY_STRESS_INITIAL (4*1024)
192-
char* memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */
193-
int mem_ctr = 0;
191+
static char* memory_stress[MEMORY_STRESS_ITERATIONS]; /* typically 1K per item */
192+
static int mem_ctr = 0;
194193
#endif
195194

196195
static int EthernetSend(WOLFSSL* ssl, char* msg, int sz, void* ctx);
@@ -202,8 +201,8 @@ static int lng_index PROGMEM = 0; /* 0 = English */
202201
#include <malloc.h>
203202
extern char _end;
204203
extern "C" char *sbrk(int i);
205-
char *ramstart=(char *)0x20070000;
206-
char *ramend=(char *)0x20088000;
204+
static char *ramstart=(char *)0x20070000;
205+
static char *ramend=(char *)0x20088000;
207206
#endif
208207

209208
/*****************************************************************************/
@@ -372,28 +371,31 @@ int setup_network(void) {
372371
#if defined(USING_WIFI)
373372
int status = WL_IDLE_STATUS;
374373

375-
if (WiFi.status() == WL_NO_MODULE) {
376-
Serial.println("Communication with WiFi module failed!");
377-
/* don't continue if no network */
378-
while (true) ;
379-
}
380-
381-
String fv = WiFi.firmwareVersion();
382-
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
383-
Serial.println("Please upgrade the firmware");
384-
}
385-
386374
/* The ESP8266 & ESP32 support both AP and STA. We'll use STA: */
387375
#if defined(ESP8266) || defined(ESP32)
388376
WiFi.mode(WIFI_STA);
377+
#else
378+
String fv;
379+
if (WiFi.status() == WL_NO_MODULE) {
380+
Serial.println("Communication with WiFi module failed!");
381+
/* don't continue if no network */
382+
while (true) ;
383+
}
384+
385+
fv = WiFi.firmwareVersion();
386+
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
387+
Serial.println("Please upgrade the firmware");
388+
}
389389
#endif
390390

391391
Serial.print(F("Connecting to WiFi "));
392392
Serial.print(ssid);
393+
status = WiFi.begin(ssid, password);
393394
while (status != WL_CONNECTED) {
394-
status = WiFi.begin(ssid, password);
395-
delay(5000);
395+
delay(1000);
396396
Serial.print(F("."));
397+
Serial.print(status);
398+
status = WiFi.status();
397399
}
398400

399401
Serial.println(F(" Connected!"));
@@ -582,9 +584,12 @@ int setup_certificates(void) {
582584
/*****************************************************************************/
583585
/*****************************************************************************/
584586
void setup(void) {
587+
int i = 0;
585588
Serial.begin(SERIAL_BAUD);
586-
while (!Serial) {
589+
while (!Serial && (i < 10)) {
587590
/* wait for serial port to connect. Needed for native USB port only */
591+
delay(1000);
592+
i++;
588593
}
589594

590595
Serial.println(F(""));
@@ -608,10 +613,10 @@ void setup(void) {
608613

609614
setup_hardware();
610615

611-
setup_datetime();
612-
613616
setup_network();
614617

618+
setup_datetime();
619+
615620
setup_wolfssl();
616621

617622
setup_certificates();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Arduino Basic Hello World
2+
3+
This example simply compiles in wolfSSL and shows the current version number.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <Arduino.h>
2+
#include <wolfssl.h>
3+
#include <wolfssl/version.h>
4+
5+
/* Choose a monitor serial baud rate: 9600, 14400, 19200, 57600, 74880, etc. */
6+
#define SERIAL_BAUD 115200
7+
8+
/* Arduino setup */
9+
void setup() {
10+
Serial.begin(SERIAL_BAUD);
11+
while (!Serial) {
12+
/* wait for serial port to connect. Needed for native USB port only */
13+
}
14+
Serial.println(F(""));
15+
Serial.println(F(""));
16+
Serial.println(F("wolfSSL setup complete!"));
17+
}
18+
19+
/* Arduino main application loop. */
20+
void loop() {
21+
Serial.print("wolfSSL Version: ");
22+
Serial.println(LIBWOLFSSL_VERSION_STRING);
23+
delay(60000);
24+
}

IDE/ARDUINO/wolfssl-arduino.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
ROOT_DIR="/wolfssl"
3030

3131
# The Arduino Version will initially have a suffix appended during fine tuning stage.
32-
WOLFSSL_VERSION_ARUINO_SUFFIX="-Arduino.2"
32+
WOLFSSL_VERSION_ARUINO_SUFFIX="-Arduino.3"
3333

3434
# For verbose copy, set CP_CMD="-v", otherwise clear it: CP_CMD="cp"
3535
# Do not set to empty string, as copy will fail with this: CP_CMD=""
@@ -241,6 +241,10 @@ if [ "$THIS_DIR" = "ARDUINO" ]; then
241241
$CP_CMD ./sketches/wolfssl_server/wolfssl_server.ino ".${EXAMPLES_DIR}"/wolfssl_server/wolfssl_server.ino || exit 1
242242
$CP_CMD ./sketches/wolfssl_server/README.md ".${EXAMPLES_DIR}"/wolfssl_server/README.md || exit 1
243243

244+
echo "Copy wolfssl_server example...."
245+
mkdir -p .${EXAMPLES_DIR}/wolfssl_version
246+
$CP_CMD ./sketches/wolfssl_version/wolfssl_version.ino ".${EXAMPLES_DIR}"/wolfssl_version/wolfssl_version.ino || exit 1
247+
$CP_CMD ./sketches/wolfssl_version/README.md ".${EXAMPLES_DIR}"/wolfssl_version/README.md || exit 1
244248
else
245249
echo "ERROR: You must be in the IDE/ARDUINO directory to run this script"
246250
exit 1
@@ -265,7 +269,7 @@ sed s/"$VERSION_PLACEHOLDER"/"$WOLFSSL_VERSION"/ "$PREPEND_FILE" > "$PREPEND_FIL
265269
cat "$PREPEND_FILE.tmp" ${TOP_DIR}/README.md > PREPENDED_README.md
266270

267271
# Here we'll insert the wolfSSL version into the `library.properties.tmp` file, along with an Arduino version suffix.
268-
# The result should be something like version=5.6.601 (for the 1st incremental version on top of 5.6.6)
272+
# The result should be something like version=5.6.6.Arduino.1 (for the 1st incremental version on top of 5.6.6)
269273
sed s/"$VERSION_PLACEHOLDER"/"$WOLFSSL_VERSION"/ "$PROPERTIES_FILE_TEMPLATE" > "library.properties.tmp"
270274
sed -i.backup s/"$ARDUINO_VERSION_SUFFIX_PLACEHOLDER"/"$WOLFSSL_VERSION_ARUINO_SUFFIX"/ "library.properties.tmp"
271275

examples/configs/user_settings_arduino.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
*/
2626

2727
/* Define a macro to display user settings version in example code: */
28-
#define WOLFSSL_USER_SETTINGS_ID "Arduino user_settings.h v5.6.6 Rev 5"
28+
#define WOLFSSL_USER_SETTINGS_ID "Arduino user_settings.h v5.6.7"
29+
30+
/* Due to limited build control, we'll ignore file warnings. */
31+
/* See https://github.com/arduino/arduino-cli/issues/631 */
32+
#undef WOLFSSL_IGNORE_FILE_WARN
33+
#define WOLFSSL_IGNORE_FILE_WARN
2934

3035
#define NO_FILESYSTEM
3136
#define USE_CERT_BUFFERS_2048

wolfssl/wolfcrypt/settings.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@
266266
/* #define WOLFSSL_MAXQ108X */
267267

268268
#if defined(ARDUINO)
269+
/* Due to limited build control, we'll ignore file warnings. */
270+
/* See https://github.com/arduino/arduino-cli/issues/631 */
271+
#undef WOLFSSL_IGNORE_FILE_WARN
272+
#define WOLFSSL_IGNORE_FILE_WARN
273+
269274
/* we don't have the luxury of compiler options, so manually define */
270275
#if defined(__arm__)
271276
#undef WOLFSSL_ARDUINO

0 commit comments

Comments
 (0)