Cross compiler for embedded microcontrollers ?

Timo Sintonen via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 16 10:20:38 PST 2015


On Friday, 16 January 2015 at 10:04:55 UTC, Jens Bauer wrote:

> Has anyone used newlib with a Cortex-M based GDC toolchain ?

As Mike pointed out, my minlibd project is a good starting point. 
It contains a fully functional example for stm32f4

> Build failed on final gcc.
>
> I normally use newlib and multilib, because I'm developing for 
> Cortex-M0, Cortex-M3 and Cortex-M4 and would like to be able to 
> switch between those and use the same compiler.
> But following the above mentioned instructions seem to suggest 
> disabling multilib and using libgcc instead of newlib.

Libgcc is not libc

Libgcc is gcc internal library. It contains functions for those c 
language features that can not be represented as a simple machine 
instruction pattern. The compiler generates calls to these 
functions and users should never call these directly.
Libc contains the standard c library functions like fopen and 
printf. Glibc is the original gnu libc. Newlib is a smaller 
alternative for libc and better suitable for small systems. Libc 
or newlib is needed to build the compiler but the application 
needs it only if its features are used. I have not needed libc in 
my cortex programs.

Both libgcc and libc are included automatically unless --nostdlib 
option is used or if there is a custom linker script.

The multilib building is a bit tricky. I have not succeeded to 
build m0/m3/m4 libraries at the same time. Gcc developers have 
always assumed that there is no Arm processor with fpu and thumb. 
Now we have Cortex-m4...

If you have succeeded with building the libraries please share 
your experiences. If you have failed, please ask this in 
gcc-users list and report here in d.gnu list what they answered.


More information about the Digitalmars-d mailing list