3

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?

bilaljo
  • 358
  • 1
  • 6
  • 13
  • 1
    Why do you believe it should be supported on a bare-metal (I presume) Cortex-M4? – Eugene Sh. Jan 27 '22 at 22:28
  • Which model stm32? See: https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html you probably need FPU support which is optional on an M4. – Craig Estey Jan 27 '22 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. – bilaljo Jan 28 '22 at 06:50
  • @CraigEstey I am using an STM32L432KC, but it is not my final choice. Just for testing if the compiling of gsl etc. works. – bilaljo Jan 28 '22 at 06:51
  • Sorry I missed to put a link to the referenced tutorial: https://www.linkedin.com/pulse/cross-compiling-gcc-toolchain-arm-cortex-m-processors-ijaz-ahmad – bilaljo Jan 28 '22 at 08:56

2 Answers2

2

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).

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Ali Rahman
  • 31
  • 6
  • 2
    Not 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. – Willis Hershey Dec 20 '22 at 14:41
1

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.

bilaljo
  • 358
  • 1
  • 6
  • 13
  • As in this post described, it is needed to add as linker flag the linker script for the desired MCU during cross-compiling: https://stackoverflow.com/questions/71011160/hardfault-with-stm32-caused-through-gsl/71065982#71065982 – bilaljo Feb 10 '22 at 13:30