How to use GNU ARM binutils for cortex-M4? When I try to compile with -mcpu=cortex-M4 -march=armV7e-m I get 'bad value in switches'.
Hi jvanmont,
unfortunately gnuarm4.1.1 seems not to support "-mcpu=cortex-m4 -march=armv7e-m" switches. It might only support -mthumb switch. In order to specify such compile switches, you should use more newer version of the gcc.
Best regards,Yasuhiko Koumoto.
Is there some optimal version of GNU arm for cortex-m4?
Compilers get better over time, in terms of code generation quality. I would suggest trying the latest compiler version you can lay your hands on.
HTH, Pete
do you need the GNU arm? However, it seems to stop the development and the latest version would be 4.2.0. It is a rather older. I think you'd better use wellknown integrated development environments such as mbed, IAR EWARM, Keil IDE, Kinetis Design Studio, and so on. They usually include the GNU Compiler.
Hi jvanmont - sorry for the late reply.
I use gcc-4.8.3 myself; I can use the same arm-none-eabi-gcc to build for Cortex-M0, Cortex-M3 and Cortex-M4.
Building gcc-4.8.3 is a bit more difficult than building a v4.5 and earlier.
-I recommend getting the launchpad version, if you're able to build it. The only reason I had to build my own, is that I'm on a PowerPC based Mac, which none of the well-known toolchains will work for.
If you are using a PowerMac (not Mac Pro), please let me know.
In order to use the --with-multilib-list, you will need to apply two patches: t-arm-elf.patch and cortex-m0-trap.S.patch (they're attached to this post).
If you want to build gcc-4.8.3, then I'll give you some hints for preparing the sources.
To build gcc, do not compile mpfr, mpc and gmp; instead make symlinks to the parent directories, otherwise you'll be waiting half a day until it's built.
If you're building for Mac (or your /usr directory is not writable by you), then you'll need to prefix the 'make install' by sudo.
I also recommend using parallel-builds to save you 3-4 hours.
For instance 'make -j8' instead of just 'make'. The number after -j is twice the number of cores that your computer has.
Patch sources, so we'll get support for all Cortex-M architectures (and ARM7TDMI):
( cd "source/gcc-4.8.3/"; patch -p1 < "archives/t-arm-elf.patch" )
( cd "source/newlib-2.1.0/"; patch -p1 < "archives/cortex-m0-trap.S.patch" )
Create symlinks to used libraries:
ln -s "source/gmp-5.1.3" "source/gcc-4.8.3/gmp"
ln -s "source/mpfr-3.1.2" "source/gcc-4.8.3/mpfr"
ln -s "source/mpc-1.0.2" "source/gcc-4.8.3/mpc"
ln -s "source/libelf-0.8.13" "source/gcc-4.8.3/libelf"
ln -s "source/newlib-2.1.0/newlib" "source/gcc-4.8.3/newlib"
These are my build-lines for binutils:
./configure --target=arm-none-eabi --prefix=/usr/local/arm-none-eabi --disable-nls --disable-libssp --with-gcc --with-gnu-as --with-gnu-ld --enable-multilib --enable-interwork --enable-plugins --with-system-zlib
make && make install
My build-lines for bootstrap gcc:
./configure --target=arm-none-eabi --prefix=/usr/local/arm-none-eabi --disable-nls --with-gcc --with-gnu-as --with-gnu-ld --with-dwarf2 --enable-multilib --enable-interwork --with-newlib --disable-libssp --with-system-zlib --disable-decimal-float --disable-libffi --disable-libmudflap --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r --disable-libstdcxx-pch --without-headers --enable-languages="c,c++"
make all-gcc && make install-gcc
Temporarily add the newly built gcc to the PATH environment variable:
export PATH="$PATH:/usr/local/arm-none-eabi/bin"
My build-lines for newlib:
./configure --target=arm-none-eabi --prefix=/usr/local/arm-none-eabi --enable-interwork --enable-multilib --disable-libssp --disable-nls --enable-newlib-io-long-long --enable-newlib-register-fini --disable-newlib-supplied-syscalls
make CFLAGS_FOR_TARGET="-D__IEEE_BIG_ENDIAN -D__IEEE_BYTES_LITTLE_ENDIAN -D__BUFSIZ__=64" && env "PATH=$PATH" make install || env "PATH=$PATH" make install
(yes, the crazy double-install is most likely necessary, because a directory is missing on the first try)
Show the architectures that your multilib supports; this should include all Cortex-M, plus ARM7TDMI:
arm-none-eabi-gcc -print-multi-lib
My build-lines for final gcc:
./configure --target=arm-none-eabi --prefix=/usr/local/arm-none-eabi --disable-nls --with-gcc --with-gnu-as --with-gnu-ld --with-dwarf2 --enable-multilib --enable-interwork --with-newlib --disable-libssp --with-system-zlib --disable-decimal-float --disable-libffi --disable-libmudflap --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r --disable-libstdcxx-pch --with-headers=yes --enable-languages="c,c++"
make all -Wno-error=deprecated-declarations && make install
If you need more information, please send me a personal message.
Hi Jens,
I'm cross-compiling on a Win8 machine. I have installed gcc-arm-embedded toolchain from the ARM team. Compiler version 4.9.3. It includes the Red Hat newlib version 2.1.0. I try this out in the coocox IDE.
Tnx!
This reply is really for jvanmont. In your specific case, the following has worked for me (on a RPi!): * lowercase commandline * -mcpu=cortex-m4 * -march=armv7-m. You might even get away without the -march option. GCC V4 does not sopport the Cortex -M4; I don't know about GCC V5 (was it ever released?), but any version from v6 onward will. And the GCC Linker automatically generates ELF output. The best ( but most long-winded!) source of information here is the series "Using the GNU Compiler Collection" - there is one for each version of GCC.
jvanmont,
how can I get the compiler? I want cross-compiling environment on Winows 8.
yasuhikokoumoto The toolchain can be picked from this source GCC ARM Embedded in Launchpad
It builds for cortex-M under cygwin env with make.
thank you for the beneficial information! I just wanted such the compiler as supported the thumb-2 instruction set and even Cortex-M7 specific instructions.
Best regards,
Yasuhiko Koumoto.