Problems compiling for ARM

1,059 views
Skip to first unread message

Jørgen Nordmoen

unread,
Aug 27, 2015, 5:43:57 AM8/27/15
to OpenBLAS-users
Hi.

I'm trying to compile OpenBLAS for ARM, specifically for STM32F405, but currently cross-compiling from git doesn't work for me.
I have tried the following command to cross-compile:
make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar HOST=gcc TARGET=ARMV7 USE_THREAD=0

But I get the following error:
/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `
_exit'
/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r'
:
sbrkr
.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `
_write_r':
writer.c:(.text._write_r+0x24): undefined reference to `_write'

/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0x18): undefined reference to `
_close'
/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r'
:
lseekr
.c:(.text._lseek_r+0x24): undefined reference to `_lseek'
/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `
_read_r':
readr.c:(.text._read_r+0x24): undefined reference to `_read'

/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0x20): undefined reference to `
_fstat'
/usr/lib/gcc/arm-none-eabi/5.2.0/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r'
:
isattyr
.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
collect2: error: ld returned 1 exit status


I'm trying to use cblas and lapacke from OpenBlas in a program used for Crazyflie 2.0, but when using the precompiled .so for ARMv7 it doesn't work either. I would like to get cross-compiling to work so if anyone has any suggestions on what is wrong with the above command I would appreciate it.

Zhang Xianyi

unread,
Aug 27, 2015, 11:43:57 AM8/27/15
to Jørgen Nordmoen, OpenBLAS-users
Hi,

I didn't test cross compiling for Cortex-M. I am not sure the assembly codes can run on your MCU.

I suggest you can try OpenBLAS arm C kernels.

1) Edit Makefile.arm,  

ifeq ($(CORE), ARMV5)

CCOMMON_OPT += -marm -march=armv5

FCOMMON_OPT += -marm -march=armv5

endif

You can modify the compiler flags, e.g. -march=armv7e-m


2) Use ARMV5 C kernel target as following.

make TARGET=ARMV5   CC=arm-none-eabi-gcc USE_THREAD=0 HOSTCC=gcc FC=arm-none-eabi-gfortran



--
You received this message because you are subscribed to the Google Groups "OpenBLAS-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openblas-user...@googlegroups.com.
To post to this group, send email to openbla...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jørgen Nordmoen

unread,
Sep 3, 2015, 5:27:36 AM9/3/15
to OpenBLAS-users, nordm...@gmail.com
Thank you for the prompt reply. Unfortunately I still can't get the code to compile. However, there seems to be several problems that can potentially stop this.

First of all, I edited the `Makefile.arm` so that it contained the following:
ifeq ($(CORE), CORETEXM4F)
CCOMMON_OPT
+= -marm -mfpu=neon-vfpv4 -mtune=cortex-m4 -mfloat-abi=hard -march=armv7e-m
FCOMMON_OPT
+= -marm -mfpu=neon-vfpv4 -mtune=cortex-m4 -mfloat-abi=hard -march=armv7e-m
endif
(Note I also added the same options under ARMV5, but I get the same error regardless of using `TARGET=` or `CORE=` )

Then I tried to run the command as following:
make CORE=CORETEXM4F CC=arm-none-eabi-gcc USE_THREAD=0 HOSTCC=gcc AR=arm-none-eabi-ar
which results in the following error:
scal.c:1:0: error: target CPU does not support ARM mode
 
/*********************************************************************/
 
^
Makefile:750: recipe for target 'sscal.o' failed
make
[1]: *** [sscal.o] Error 1
make
[1]: *** Waiting for unfinished jobs....
copy
.c:1:0: error: target CPU does not support ARM mode
 
/*********************************************************************/
 
^
swap
.c:1:0: error: target CPU does not support ARM mode
 
/*********************************************************************/
 
^
Makefile:777: recipe for target 'scopy.o' failed
make
[1]: *** [scopy.o] Error 1
Makefile:795: recipe for target 'sswap.o' failed
make
[1]: *** [sswap.o] Error 1
axpy
.c:1:0: error: target CPU does not support ARM mode
 
/*********************************************************************/
 
^
Makefile:723: recipe for target 'saxpy.o' failed
make
[1]: *** [saxpy.o] Error 1
make
[1]: Leaving directory '/home/username/repos/OpenBLAS/interface'
Makefile:143: recipe for target 'libs' failed
make
: *** [libs] Error 1

In addition, I can't find a Fortran cross-compiler for ARM, which is why I have not included `FC=` in the command ran above. I'm trying to build on ArchLinux, but I can't find any Fortran cross-compiler and in Ubuntu the only cross-compiler I can find is gnueabi which if I'm not mistaken does not work unless Linux is present.

Any suggestion of what the next step should be?

Jørgen Nordmoen

unread,
Sep 3, 2015, 7:39:40 AM9/3/15
to OpenBLAS-users
I got a bit further after some more tries.

Changed the `CORE` configuration above to:
ifeq ($(CORE), CORTEXM4F)

CCOMMON_OPT
+= -marm -mfpu=neon-vfpv4 -mtune=cortex-
m4
FCOMMON_OPT
+= -marm -mfpu=neon-vfpv4 -mtune=cortex-m4
endif

And execute with:
make CORE=CORTEXM4F CC=arm-none-eabi-gcc HOSTCC=gcc USE_THREAD=0 NO_LAPACK=1

But it still will not compile.
In file included from axpy.c:40:0:
../common.h:112:22: fatal error: sys/mman.h: No such file or directory
compilation terminated
.
In file included from copy.c:40:0:
../common.h:112:22: fatal error: sys/mman.h: No such file or directory
compilation terminated
.

Makefile:723: recipe for target 'saxpy.o' failed
make
[1]: *** [saxpy.o] Error 1

make
[1]: *** Waiting for unfinished jobs....
Makefile:777: recipe for target 'scopy.o' failed
make
[1]: *** [scopy.o] Error 1
In file included from scal.c:40:0:
../common.h:112:22: fatal error: sys/mman.h: No such file or directory
compilation terminated
.

Makefile:750: recipe for target 'sscal.o' failed
make
[1]: *** [sscal.o] Error 1
In file included from swap.c:40:0:
../common.h:112:22: fatal error: sys/mman.h: No such file or directory
compilation terminated
.

Makefile:795: recipe for target 'sswap.o' failed
make
[1]: *** [sswap.o] Error 1

make
[1]: Leaving directory '/home/username/repos/OpenBLAS/interface'
Makefile:143: recipe for target 'libs' failed
make
: *** [libs] Error 1
Which seems like an error where Arch Linux has moved or I have not install a needed library.

Zhang Xianyi

unread,
Sep 3, 2015, 9:51:53 AM9/3/15
to Jørgen Nordmoen, OpenBLAS-users
Please don't change CORE.

ifeq ($(CORE), ARMV5)
CCOMMON_OPT 
+= -marm -mfpu=neon-vfpv4 -mtune=cortex-m4 -mfloat-abi=hard -march=armv7e-m
FCOMMON_OPT 
+= -marm -mfpu=neon-vfpv4 -mtune=cortex-m4 -mfloat-abi=hard -march=armv7e-m
endif


make CORE=ARMV5 CC=arm-none-eabi-gcc HOSTCC=gcc USE_THREAD=0 NO_LAPACK=1
Reply all
Reply to author
Forward
0 new messages