Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Arduino Support: ESP32, Due #7177

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

gojimmypi
Copy link
Contributor

Description

This PR improves support for the Arduino platform.

I'll be testing other Arduino boards, but I've added the help wanted label to invite others to test these changes with various other devices.

Of particular interest, gated sections added to:

  • src/internal.c (only a placeholder reminder / not part of "else" gating)
  • wolfcrypt/src/random.c (more board-specific implementation will be needed here)
  • wolfssl/wolfcrypt/settings.h (only AVR, ARM, and Espressif at this time)
  • wolfssl/wolfcrypt/tfm.h (just a spelling correction)
  • wolfssl/wolfcrypt/wc_port.h (only basic Arduino support, likely needs work for other boards)
  • wolfssl/ssl.h (only a placeholder reminder & adjacent cleanup)
  • wolfssl/test.h (only a placeholder reminder; test.h not yet working in Arduino)
  • wolfssl/wolfio.h (only Espressif at this time)

Fixes zd# may help with 17001, although more ESP8266 work is known to be needed.

See also #6360 and wolfSSL/Arduino-wolfSSL#1

Testing

How did you test?

Primarily tested in the Arduino environment, as well as the usual:

./configure --enable-all
make clean
make && make test

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What hardware have you tested with?

#define WOLFSSL_ARDUINO

/* Math library (remove this to use normal math)*/
# if [ ! -f ".${ROOT_SRC_DIR}/user_settings.h" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out and still here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, that was an oversight. good catch, deleted.

#define WOLFSSL_SM4
*/

// #define WOLFSSL_MEMORY_STORAGE __FlashStringHelper *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is WOLFSSL_MEMORY_STORAGE? Please document

Copy link
Contributor Author

@gojimmypi gojimmypi Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOLFSSL_MEMORY_STORAGE is an experimental macro for the Arduino-specific F(string_literal) macro class to help improve memory storage.

I'll review and either add more detail or remove for now.

*edit: I've removed the WOLFSSL_MEMORY_STORAGE macro for now.

src/internal.c Outdated
@@ -2314,6 +2314,12 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
ctx->CBIORecvFrom = uIPRecvFrom;
}
#endif
#elif defined(ARDUINO)
#if defined(__AVR__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need this at all? Seems like requiring WOLFSSL_USER_IO is the better option. Then you can remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, nice. excellent suggestion, thank you. changed.

wolfcrypt/src/random.c Show resolved Hide resolved
wolfcrypt/src/random.c Show resolved Hide resolved
`WC_SHA512` should be used for the enum name.


# wolfSSL Release 5.6.6 (Dec 19, 2023)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer a link to the ChangeLog.md and not duplicating.

Copy link
Contributor Author

@gojimmypi gojimmypi Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different from the change log.

My intention for the PREPENDED_README.md is to add some prepended text to the beginning of the library README.md published in the Official wolfSSL Arduino Library to indicate the Arduino-specific nature.

This prepended text might have Arduino-specific release information, outside of the normal wolfSSL versions, that are needed to be tagged as noted in the Arduino Library Specifications and noted in the requirements:

The library repository must have a Git tag (or release) and must have been compliant with all the above requirements at the time of that tag.

There is however, an argument that the PREPENDED_README.md file is only a temporary file for the published wolfSSL Arduino README.md and could be excluded here?

edit: I've removed the programmatically generated PREPENDED_README.md and added the name to .gitignore.

@gojimmypi
Copy link
Contributor Author

gojimmypi commented Jan 26, 2024

What hardware have you tested with?

So far I've successfully tested with two different ESP32 devices and an ARM-based Arduino Due.

I have an Arduino Uno rev 3 with an Ethernet Shield. I gave up trying to fit TLS into the 8KB RAM, but we might be able to do other things.

I tried a Arduino Mega & gave up for the same small memory reason. I've ben focused on the TLS client & server examples.

I have a Arduino Uno R4 WiFi on my workbench that is known to not work yet. (Renesas RA4M1 + Espressif ESP32-S3)

I have a variety of other non-Arduino devices that could be tested. There's quite a list of Arduino and compatible systems on wikipedia.

The Due is fairly easy to get going. Each of the ESP32 dev boards were different, and neither worked out of the box. Both of the ESP32 devices needed manual settings adjustment. For instance:

Board 1 ESP32 Dev Module Board 2 DOIT ESP32 Devkit V1
image image

*edit: just to clarify: I've tested with some other boards, but the source for those updated examples is still WIP. I'll be creating a separate PR for the Arduino Client and Server examples in the coming weeks,

@gojimmypi gojimmypi marked this pull request as draft January 29, 2024 16:43
@gojimmypi gojimmypi force-pushed the PR-Arduino-Update branch 5 times, most recently from 1f31b9e to 105c4cb Compare January 29, 2024 19:21
@gojimmypi gojimmypi requested a review from dgarske January 29, 2024 19:36
@gojimmypi gojimmypi marked this pull request as ready for review January 29, 2024 19:36
wolfcrypt/src/random.c Show resolved Hide resolved
examples/configs/user_settings_arduino.h Show resolved Hide resolved
@dgarske dgarske removed their assignment Jan 30, 2024
@gojimmypi gojimmypi requested a review from dgarske January 31, 2024 18:04
examples/configs/user_settings_arduino.h Show resolved Hide resolved
wolfcrypt/src/random.c Show resolved Hide resolved
wolfcrypt/src/random.c Show resolved Hide resolved
@dgarske dgarske removed their assignment Jan 31, 2024
@dgarske
Copy link
Contributor

dgarske commented Feb 1, 2024

Retest this please

dgarske
dgarske previously approved these changes Feb 1, 2024
@dgarske dgarske assigned wolfSSL-Bot and unassigned dgarske Feb 1, 2024
@gojimmypi
Copy link
Contributor Author

retest this please

@gojimmypi
Copy link
Contributor Author

@dgarske if you could kindly re-approve; looks like your approval was dismissed when I pushed the additional commit to fix the build complaint about C++ style comments. Thanks @bandi13 for pointing it out.

dgarske
dgarske previously approved these changes Feb 7, 2024
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Lets find an engineer to also try this out.

@dgarske dgarske removed their assignment Feb 7, 2024
@night1rider
Copy link
Contributor

night1rider commented Feb 7, 2024

I used our internal testing for the Intel Galileo, and was able to produce the same results as the old version ./wolfssl-arduino.sh.
This is our simple client server hello test adapted for the Galileo.

This test does the following:

  • Pulls the requested repo for wolfssl
  • Navigates to IDE/ARDUINO and runs ./wolfssl-arduino.sh INSTALL
  • pull downs the Arduino toolchain/ide and places the generated IDE/ARDUINO/wolfSSL library folder into the appropriate directory for the toolchain/ide and updates user_settings.h
  • compiles the wolfssl client example in IDE/ARDUINO/sketches/wolfssl_client/wolfssl_client.ino
  • programs the Galileo and starts a server for the client to connect to to preform a client server hello

I made some suggestions for the README directly to Jim, these suggestions where due to the confusion of using option 1 for step 1. This has been clarified as of posting this comment and the README updated

I have not tested with a ESP32/Arduino DUE since I lack the hardware to test the functionality of that portion of the PR.

@gojimmypi
Copy link
Contributor Author

Jenkins retest this please.

@dgarske dgarske merged commit 6f88ed0 into wolfSSL:master Feb 13, 2024
110 checks passed
@gojimmypi gojimmypi deleted the PR-Arduino-Update branch October 9, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants