User-Generated Performance Advisory for Cortex M – Newlib vs Newlib-Nano

A big thank you to @eli.hughes who has shared results for their own project in hopes of further helping fellow users when building on an embedded Cortex M platform.

“I had a working project build with Segger Embedded Studio for a Nordic NRF52840 (64MHz Cortex M). We switched our build tooling to use cmake/ninja along with the newlib-nano libraries packaged with ARM GCC tools. One thing I noticed is that our TLS handshake in our application went from 3 seconds to about 16 seconds.

Using the built in wolf test functions, I was able to track down the issue.

While Segger Embedded Studio uses GCC, they have their own builds of the C standard libraries.The wolfcrypt ECC routines are very sensitive to how the C libraries are built.

Results

I could eventually get “better” performance than the SES custom library but had to use NewLib and not NewLib-nano. This results in a larger binary but the performance is much better.   

wolf Test Time 

Segger Embedded Studio w/ custom std libs: 208 seconds

ARM GCC Embedded w/ Newlib-Nano:  608 seconds

ARM GCC Embedded w/ Newlib:  202 seconds

ARM GCC Embedded w/ Newlib &WOLFSSL_SP_ARM_CORTEX_M_ASM :  175 seconds

In addition to using Newlib, I found the macro WOLFSSL_SP_ARM_CORTEX_M_ASM helped quite a bit.  (Appears it has hand tuned ASM routines for SP math).

Apparently, newlib is built with speed optimizations and newlib-nano is built with size optimizations. I was surprised at the stark difference. I have other math heavy routines and the difference in execution speed is only 5% between -03 and -Os.  It seems that the ECC SP routines have some sensitivity to the C library.

Hope this is helpful to anyone building for a Cortex M MCU.” 

To read the original forum post: https://www.wolfssl.com/forums/post5456.html#p5456

Thank you @eli.hughes for sharing these findings. We hope others on the Cortex M will see this. The SP WOLFSSL_SP_ARM_CORTEX_M_ASM option is quite impressive for RSA/DH/ECC math speedups because it uses hand written assembly. At wolfSSL, we love to hear your findings and projects, so please feel free to reach out and keep us posted! 

Additional Resources 

Check out Eli’s article series for NXP on LPC55S69 and stay tuned for an upcoming set on cellular IoT and cloud connectivity. 

If you have any questions or run into any issues, contact us at facts@wolfssl.com, or call us at +1 425 245 8247.

Check out the wolfSSL embedded SSL/TLS library, star us on Github, and learn more about the latest TLS 1.3 is available in wolfSSL.