I am using a STM32 MCU with arm cortex m4 and want to use the gsl-2.7.1. However, I already tried for example the command ./configure --prefix=/home/user_name/gsl_arm --target=arm-none-eabi and every other suggestion that I could find on the internet and toolchain-tutorials, but in the best case I got during linking with the build library an error like "could not recognize the symbols". In the worst case, the suggested options for autoconfig were not recognized (for example, to specify the cpu). Does anyone have an idea how I have to crosscompile it?
-
1Why do you believe it should be supported on a bare-metal (I presume) Cortex-M4?– Eugene Sh.Jan 27, 2022 at 22:28
-
Which model stm32? See: st.com/en/microcontrollers-microprocessors/… you probably need FPU support which is optional on an M4.– Craig EsteyJan 27, 2022 at 23:27
-
@EugeneSh.: It is not? In this tutorial somebody builds the gcc toolchain with arm-none-eabi, so I thought it would be for GSL the same way.– bilaljoJan 28, 2022 at 6:50
-
@CraigEstey I am using an STM32L432KC, but it is not my final choice. Just for testing if the compiling of gsl etc. works.– bilaljoJan 28, 2022 at 6:51
-
Sorry I missed to put a link to the referenced tutorial: linkedin.com/pulse/…– bilaljoJan 28, 2022 at 8:56
3 Answers
There is a small mistake in the accepted answer.
Note that you have to use software floating point, since some libraries are only working with this.
Software floating pointing is not a strict requirement, and you can indeed compile GSL with a hard floating point Application Binary Interface (ABI) .
The compiler flags variable CFLAGS has been misspelled as CCFLAGS. Hence the specified compiler flags are ignored. This is problematic as GSL's configure script generates makefiles for nested modules in addition to the main makefile for the entire libary.
Consequently, modules such as ieee-utils,siman etc within the GSL directory are compiled with the default floating-point ABI flag (softfp).
Since compiler flags are also passed as parameters to the linker, compilation of the GSL leads to the mismatch as the expectation of a hard fp ABI clashes with the aforementioned modules being compiled for a softfp ABI.
I was able to compile the GSL with a hard floating point ABI and generate a static library for bare metal firmware development on a BeagleBone Black (ARM Cortex-A8).
-
2Not having sufficient reputation to comment, is not an excuse to use the answer section as the comment section. You seem to know what you're talking about, but you should edit your answer so that it is an answer so it doesn't get removed. Dec 20, 2022 at 14:41
I am glad to say that I was able to cross compile the GSL for Arm Cortex-M4. If you call autoconf with the following options:
COREFLAGS="-mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=soft"
./configure --prefix=/home/$(whoami)/gsl_arm CC=arm-none-eabi-gcc \
CXX=arm-none-eabi-gcc LD=arm-none-eabi-gcc AR=arm-none-eabi-ar \
OBJCOPY=arm-none-eabi-objcopy CCFLAGS="$COREFLAGS" CXXFLAGS="$COREFLAGS" \
LDFLAGS="--specs=nano.specs --specs=nosys.specs $COREFLAGS" \
--host=x86_64-unknown-linux-gnu
The host is the host for my case, and make differ. Note that you have to use software floating point, since some libraries are only working with this.
-
As in this post described, it is needed to add as linker flag the linker script for the desired MCU during cross-compiling: stackoverflow.com/questions/71011160/…– bilaljoFeb 10, 2022 at 13:30
I also cross compiled gsl for Arm Cortex-M4 and I had to add the RANLIB flag with the corresponding path as well, building on Darwin. That's because otherwise the compiler will use the native xcode ranlib program.