| Thread overview | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 15, 2015 Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Hi, Today is my first D-day. I haven't even written any d-code yet, but I've got the compiler for my PPC-based Mac (yes, it's old). I'm familiar with compiling toolchains for ARM Cortex-M0, M3 and M4. Is there any information on how to build a cross-gdc targetting these architectures ? Eg. the compiler will be built and run on my PowerMac, but I'd like it to generate ARM Cortex-M3 code for instance. | ||||
January 15, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jens Bauer | It seems I've found it... http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler -It also seems I have to use gcc-4.9, as the gcc-4.8 branch does not seem to exist in the git repository ? | |||
January 15, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jens Bauer | On 15 January 2015 at 16:49, Jens Bauer via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> It seems I've found it...
>
> http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler
>
> -It also seems I have to use gcc-4.9, as the gcc-4.8 branch does not seem to exist in the git repository ?
That should be gdc-4.8, gdc-4.9
| |||
January 15, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On Thursday, 15 January 2015 at 16:58:34 UTC, Iain Buclaw via Digitalmars-d wrote:
> On 15 January 2015 at 16:49, Jens Bauer via Digitalmars-d
>> -It also seems I have to use gcc-4.9, as the gcc-4.8 branch does not seem to exist in the git repository ?
>
> That should be gdc-4.8, gdc-4.9
I just tried again, and this time it looks like it's going to be successful.
Thank you for pointing out the mistake. :)
| |||
January 16, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jens Bauer | 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. Has anyone used newlib with a Cortex-M based GDC toolchain ? | |||
January 16, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jens Bauer | On Friday, 16 January 2015 at 10:04:55 UTC, Jens Bauer wrote: > 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. Has anyone used newlib with a Cortex-M based GDC toolchain ? I wrote the those instructions on the wiki, but I don't have experience building a multilib toolchain, or building one with newlib. I recommend going to https://launchpad.net/gcc-arm-embedded and downloading the source code package. After extracting the archive, you'll find a three bash scripts that do the build. It's an extremely complicated script, but inside you can find all the necessary commands for multilib and newlib builds. That's the resource I used to figure it out and write those instructions. My goal is to use D without having to rely on a C standard library, and I've demonstrated that it is feasible and even desirable. Therefore, the instructions on the wiki don't include a C library like newlib. I don't think D needs to leverage the C standard library, and as you're finding out, more dependencies = more problems. I view libgcc as part of the toolchain itself, so I will be leveraging that in the future. If you want to use the the C library, though, check out minlibd: https://bitbucket.org/timosi/minlibd. That project has some documentation for building a toolchain: https://bitbucket.org/timosi/minlibd/wiki/gdc_cross_compiler The other option would be to use crosstools-ng: http://crosstool-ng.org/. But, I had a hell of time with that last time I tried: http://forum.dlang.org/post/ptedovhanscsgshlemlb@forum.dlang.org Mike | |||
January 16, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jens Bauer | On Friday, 16 January 2015 at 10:04:55 UTC, Jens Bauer wrote: > Build failed on final gcc. > > But following the above mentioned instructions seem to suggest disabling multilib and using libgcc instead of newlib. Also, libgcc is not a replacement for newlib. I'm not an expert on the toolchain but my understanding is that libgcc contains the implementations for some of GCC's builtins. Like I said in my last post, it's really part of the toolchain itself. https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html Mike | |||
January 16, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jens Bauer | 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. | |||
January 17, 2015 Re: Cross compiler for embedded microcontrollers ? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Timo Sintonen | Thank you both Mike and Timo for clearing these things up. :) (I had the impression that multilib replaced glibcc, not the other way round - but clearly that's not what it was about). I've spent around 3 years on getting my toolchain working (!) -This is because I'm on a PowerPC based Mac. I can't just run some "do-it-for-you" script that other people uses for their toolchains; they all fail. So I had to do everything the hard way. I have multilib working, but I don't have it working with a toolchain that includes GDC. My toolchain is still alpha, and it will not work on Mac Pro with clang, but it might be useful for people wanting alternatives to the other toolchains. So hereby the first public reference to it: http://toolchain.gpio.dk/ Caveat: I may be experimentally changing it while you're viewing it, so you may get real annoyed with me, if you're in the middle of a build, and I've been messing with the Web-page and making draft-changes there. The original purpose of the page was to have a step-by-step guide for myself. Note: Although it's "prepared" for gdc, there's no steps (currently) for a successful build of gcc with gdc. But I do believe that one day, there will be a lot of people using D for embedded instead of C, as it's a far more suitable language for small devices. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply