Topic: Error flagged in ARM Cortex-M "sp_cortexm.c" assembly speedup

I am using the WolfCrypt library (vers 5.7.2) ECC functions in a bare metal project based on a Cortex-M33 processor. I want to use the Cortex-M assembly speedup so I am building ecc.c with sp_cortexm.c. Following various examples and community posts my settings.h file specifies:

/* Use single precision math only */
#define WOLFSSL_SP
#define WOLFSSL_SP_SMALL
#define WOLFSSL_HAVE_SP_ECC
#define WOLFSSL_SP_MATH     /* only SP math - eliminates integer/tfm math code, so only standard curves/key sizes are supported */
#define WOLFSSL_SP_ASM      /* enable the assembly speedup */
#define WOLFSSL_SP_ARM_CORTEX_M_ASM /* optional cortex-m speedups */

This configuration builds with just a single error: "r7 cannot be used in 'asm' here" in sp_cortexm.c at line 30931. Any suggestions as to what the cause might be would be much appreciated.

Share

Re: Error flagged in ARM Cortex-M "sp_cortexm.c" assembly speedup

Can you try version 5.7.4 or the latest of the master branch on gitubhb?  I noticed there have been changes as line 30931 on master has the following:

        "LDR    r6, [%[a], #188]\n\t"

Warm regards, Anthony

Share

Re: Error flagged in ARM Cortex-M "sp_cortexm.c" assembly speedup

Hi Mark,

This error with r7 is becuase the cortex-m uses it when building with debug. To get around this you can add

-fomit-frame-pointer

to your CFLAGS.

I added a note in the STM32Cube pack README.md regarding this:
https://github.com/wolfSSL/wolfssl/tree … pack-usage

If seeing `error: r7 cannot be used in 'asm'` add `-fomit-frame-pointer` to the CFLAGS. This only happens in debug builds, because r7 is used for debug.

Thanks,
David Garske, wolfSSL

Share

Re: Error flagged in ARM Cortex-M "sp_cortexm.c" assembly speedup

Hi David,

Thanks for the feedback. The easiest approach seemed to be to switch to a release build which removed the error. I then had a couple more errors which I fixed as follows (in case it helps anyone else):

A number of errors of "selected processor does not support `umaal ...' in Thumb mode." I tried to turn thumb mode off but after some searching discovered "All Cortex-M processors, including M33, are Thumb only. They cannot execute ARM instructions." On examining the sp_cortexm.c file I found a flag
    #define WOLFSSL_SP_NO_UMAAL
which when set removed the errors. After that I just had to include misc.c and sp_int.c and the project built without errors!

Next stage is to test some ECC crypto ;-).

Mark

Share