Introduce Espressif wolfcrypt warmup #9227
Open
+132
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the Espressif-specific version of #9203
I tend to agree that this may not belong in the
wolfCrypt_Init(), but the code does need to be available and consistent.I plan to use this in all the Espressif examples.
Description
Adds a
esp_sdk_wolfssl_warmup()warmup, call as desired, enabled by default, disable withNO_WOLFCRYPT_WARMUP.To use, call this early in the application startup:
Reason
The random number generator and AES functions were observed allocating long term (perhaps permanent?) heap memory. This PR "warms up" wolfCrypt by calling some sample code early, ensuring (hoping?) any heap allocations are at the edge of the heap and not in the middle.
A long term heap allocation in the middle of the heap, say after reading a large object such as a certificate, may interfere with the long term maximum memory availability.
This PR also makes the wolfcrypt test result more pretty.
Background
I've been optimizing wolfssl for small embedded targets. Some time ago, I introduced a heap discrepancy alert in the wolfcrypt tests. It was intended to find memory leaks after repeatedly running the tests, for example #8506
See the wolfcrypt/test/test.c around line 154 for the
PRINT_HEAP_CHECKPOINTimplementation forWOLFSSL_ESPIDFtargets.There's been a nagging reminder in the tests:
As it only occurs on the first pass of these tests, I did not consider it a memory leak. Still, it's not pretty. But until recently "not pretty" did not warrant attention. Until recently when considering the location of the heap object and no memory available even with a seemingly large quality of total heap space.
Fixes zd# n/a
Testing
How did you test?
Tested locally on ESP32 targets
Checklist