Topic: Building for Arm7m from Ubuntu

I'm on a Ubuntu 22.04.4 LTS machine.  I have no problems building wolfSSL for my OS.
./configure
make
sudo make install

The above runs perfectly.

But, what I really need to do is cross-compile for an arm7m target.

I used the following command to create my makefile:
./configure --host=arm-non-eabi CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld STRIP=arm-none-eabi-strip \
RANLIB=arm-none-eabi-ranlib  --prefix=$HOME/wolfssl-arm \
CFLAGS="-march=armv7-m --specs=nosys.specs -DHAVE_PK_CALLBACKS -DWOLFSSL_USER_IO -DNO_WRITEV" \
--disable-filesystem --enable-fastmath --disable-shared

Creating my makefile also works fine.

When I try to run make I get many undefined references such as:
CCLD     wolfcrypt/test/testwolfcrypt
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: wolfcrypt/benchmark/benchmark.o: in function `bench_stats_asym_finish_ex.constprop.0':
benchmark.c:(.text+0x292): undefined reference to `clock_gettime'
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: wolfcrypt/benchmark/benchmark.o: in function `bench_stats_sym_finish.constprop.0':
benchmark.c:(.text+0x472): undefined reference to `clock_gettime'
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: wolfcrypt/benchmark/benchmark.o: in function `bench_hmac.constprop.0':
benchmark.c:(.text+0x730): undefined reference to `clock_gettime'
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: benchmark.c:(.text+0x774): undefined reference to `__aeabi_read_tp'
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld: benchmark.c:(.text+0x7cc): undefined reference to `clock_gettime'

I assume I have some missing libraries, but no matter what I do I can't get the libraries into the make process to fix this issue.

I've also tried to make changes in <wolfssl_root>/IDE/GCC-ARM/Makefile.common.  Is this a factor, could corruption here affect my build. 
Any help would be much appreciated.

Share

Re: Building for Arm7m from Ubuntu

Hi dcanthony,

For a bare metal ARM target, rather than using ./configure I would recommend using our GCC-ARM example: https://github.com/wolfSSL/wolfssl/tree … DE/GCC-ARM  This includes a user_settings.h file which defines the macro WOLFSSL_USER_CURRTIME, allowing it to define a custom custom_time function which does not depend on clock_gettime.  You can find this function in Source/wolf_main.c.  Note that you will need to implement your own hw_get_time_sec function which returns the RTC value if you are trying to verify the dates in certificates.

What modifications did you make to Makefile.common?

Thanks,
Kareem

Share

Re: Building for Arm7m from Ubuntu

I was mistakenly using ./configure and make from the root wolfssl directory and at the same time I was also modifying Makefile.common.  I started everything over from the GitHub link you provided and I was successful in building for arm7m.  Of course now I need to find a target to run on.

One point of feedback I was getting an error related to libwolfssl.a
make[1]: Entering directory '/home/dave/Downloads/wolfssl/IDE/GCC-ARM'
make[1]: *** No rule to make target 'Build/wolfcrypt_first.o', needed by 'Build/libwolfssl.a'.  Stop.

I did notice that this option was dependent upon FIPS being defind.  I did have to comment out:
FIPS?=1

I'm assuming I still have a valid build, but would appeciate any feedback on that.  Other info I saw in GitHub seemed to imply that FIPS is a separate license.

Share

Re: Building for Arm7m from Ubuntu

Well, I think I spoke too soon.  I did a make clean, to make sure I was fully building for my target.

My Makefile.common contains:
ARCHFLAGS ?= -march=armv7 -mthumb -mabi=aapcs -DUSE_WOLF_ARM_STARTUP

When I build I was getting this error:
Error: selected processor does not support requested special purpose register -- `mrs r0,psp'

I removed the offending lines from armtarget.c:
       " mrs r0, psp     \n"  /* otherwise: stack pointer is in PSP */
        " mrs r0, msp     \n"  /* load stack pointer into R0 */

After this removal I get valid *.elf and *.hex files in my Build directory. Of course I have no idea what I've now done to the HardFault_Handler() function

Share

Re: Building for Arm7m from Ubuntu

Still learning a ton here.  I chanced my ARCHFLAGS to -mcpu=cortex-m3 -mthumb -mabi=aapcs -DUSE_WOLF_ARM_STARTUP
and I was able to put mrs instructions back into armtarget.c

Share