Topic: Compilation problem for cross compiling

Hello my friends, I am going to make an example with wolfssl library and FreeRTOS

my environment is :
Host Ubuntu
Target STM32f446 Nucleo-64 (ARM cortex M4 )
IDE System Workbench for STM32

so I realized first I need to compile the library for my environment so I installed arm-none-eabi-gcc toolchain on my ubuntu then with this configuration I tried to build the library (this configuration comes from manual section 2.6.1)

./configure --host=arm-none-eabi \
CC=arm-none-eabi-gcc LD=arm-none-eabi-ld \
AR=arm-none-eabi-ar RANLIB=arm-none-eabi-ranlib \
CFLAGS="-DNO_WOLFSSL_DIR \
-DWOLFSSL_USER_IO -DNO_WRITEV \
-mcpu=cortex-m4 -mthumb -Os \
-specs=rdimon.specs" CPPFLAGS="-I./"

So it was not successful and I received this error

 CC       wolfcrypt/test/testsuite_testsuite_test-test.o
  CC       examples/client/testsuite_testsuite_test-client.o
In file included from examples/client/client.c:47:0:
./wolfssl/test.h:143:14: fatal error: netdb.h: No such file or directory
     #include <netdb.h>
              ^~~~~~~~~
compilation terminated.
make[2]: *** [examples/client/testsuite_testsuite_test-client.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/mohsen/wolfssl-4.8.1'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/mohsen/wolfssl-4.8.1'
make: *** [all] Error 2

I didn't find any solution for that so I tried to use another configuration which was mentioned inspection Building with configure in github (https://github.com/wolfSSL/wolfssl/tree … DE/GCC-ARM)
also I changed the -march=armv8-a to -march=armv7-m

./configure \
--host=arm-non-eabi \
CC=arm-none-eabi-gcc \
AR=arm-none-eabi-ar \
STRIP=arm-none-eabi-strip \
RANLIB=arm-none-eabi-ranlib \
--prefix=/home/mohsen/default-wolfssl-arm7 \
CFLAGS="-march=armv7-m --specs=nosys.specs \
-DHAVE_PK_CALLBACKS -DWOLFSSL_USER_IO -DNO_WRITEV" \
--disable-filesystem --enable-fastmath \
--disable-shared

It was successful so I linked this library to my IDE but when I tried to use any wolfssl function like MD5 I received this error.

In file included from /home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/arm-none-eabi/include/dirent.h:7:0,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/wc_port.h:723,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/types.h:35,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/md5.h:30,
                 from ../src/main.c:4:
/home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/arm-none-eabi/include/sys/dirent.h:10:2: error: #error "<dirent.h> not supported"
 #error "<dirent.h> not supported"
  ^~~~~
In file included from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/types.h:35:0,
                 from /home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/md5.h:30,
                 from ../src/main.c:4:
/home/mohsen/wolfssl-arm7/include/wolfssl/wolfcrypt/wc_port.h:788:9: error: unknown type name 'DIR'
         DIR*   dir;
         ^~~
make: *** [src/main.o] Error 1

What do you think where is my mistake?

Share

Re: Compilation problem for cross compiling

Hello rahmanikivi724,

I would definitely recommend using our GCC-ARM example as you found, since it is set up for ARM platforms like yours.
Try defining NO_WOLFSSL_DIR to skip using DIR/dirent.h, and let me know if it helps.  You will want to include it in your CFLAGS, prefixed by -D.

Thanks,
Kareem

Share

Re: Compilation problem for cross compiling

thanks for your answer on such short notice,I did that  also I uncomment 

#define FREERTOS

in the wolfssl/wolfcrypt/setting.h

then I receive this error

Building target: 01_Hello_library.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -L/home/mohsen/wolfssl-arm7/lib -specs=rdimon.specs -lc -lrdimon -T"/home/mohsen/workspace/01_Hello_library/LinkerScript.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "01_Hello_library.elf" @"objects.list"  -lwolfssl -lm
/home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: error: 01_Hello_library.elf uses VFP register arguments, /home/mohsen/wolfssl-arm7/lib/libwolfssl.a(src_libwolfssl_la-md5.o) does not
/home/mohsen/Ac6/SystemWorkbench/plugins/fr.ac6.mcu.externaltools.arm-none.linux64_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/mohsen/wolfssl-arm7/lib/libwolfssl.a(src_libwolfssl_la-md5.o)
collect2: error: ld returned 1 exit status
make: *** [01_Hello_library.elf] Error 1

Share

Re: Compilation problem for cross compiling

i solved the problem with this configuration

./configure \
--host=arm-non-eabi \
CC=arm-none-eabi-gcc LD=arm-none-eabi-ld \
AR=arm-none-eabi-ar RANLIB=arm-none-eabi-ranlib\
STRIP=arm-none-eabi-strip \
RANLIB=arm-none-eabi-ranlib \
--prefix=/home/mohsen/wolfssl-m4-flag-hard \
CFLAGS="--specs=nosys.specs -mcpu=cortex-m4 -mthumb \
-mfloat-abi=hard -mfpu=fpv4-sp-d16 -Os \
-DNO_WOLFSSL_DIR -DHAVE_PK_CALLBACKS -DWOLFSSL_USER_IO -DNO_WRITEV" \
--disable-filesystem --enable-fastmath \
--disable-shared

Share